Skip to content

Ephemeral MARF #6365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
Draft

Conversation

jcnelson
Copy link
Member

Description

Implements #6350 by re-implementing WritableMarfStore as an enum of a persistent disk-backed variant (the one we currently have), and a new ephemeral variant in which writes are committed to a RAM-backed Sqlite store, and in which reads will hit both the in-RAM sqlite store and an internal ReadOnlyMarfStore handle. This feature will be used to allow the node to replay blocks without the possibility of committing them to disk.

Applicable issues

Additional info (benefits, drawbacks, caveats)

A caveat: blocks produced with the ephemeral variant will not have the same state root hash as they would have had they been produced with the persistent variant. This is a consequence of the fact that the new block's MARF key/value pairs and side-storage live in a separate MARF, whose trie is not linked to the disk-backed parent trie. This is acceptable because the purpose of this PR is to allow the node to replay already-processed blocks in order to extract the transaction receipts. The node already knows the "true" state root hash.

This PR is a draft until it has enough test coverage.

Checklist

  • Test coverage for new or modified code paths
  • Changelog is updated
  • Required documentation changes (e.g., docs/rpc/openapi.yaml and rpc-endpoints.md for v2 endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo
  • New integration test(s) added to bitcoin-tests.yml

@jcnelson jcnelson requested a review from rdeioris August 11, 2025 14:48
@aldur aldur linked an issue Aug 11, 2025 that may be closed by this pull request
/// Otherwise, use the disk-backed one.
fn get_open_chain_tip_height(&mut self) -> u32 {
if let EphemeralTip::RAM(..) = &self.open_tip {
self.ephemeral_marf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this computes the RAM tip height and then discards it. Should we return that value + base_tip_height (similar to get_current_block_height)?

I added an invariant prop_ephemeral_tip_height_matches_current in the companion PR; it fails here and passes with this change: https://github.com/jcnelson/stacks-core/pull/1/files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Chainstate] Add support for an ephemeral MARF
2 participants