Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7f94df2
add squash logic and squash-aware trie lookups
francesco-stacks Mar 30, 2026
04f3aad
Merge branch 'feat/marf-squash-foundation' into feat/marf-squash-engine
francesco-stacks Mar 31, 2026
d142bf5
Merge branch 'feat/marf-squash-foundation' into feat/marf-squash-engine
francesco-stacks Apr 2, 2026
60e19dc
Merge branch 'feat/marf-squash-foundation' into feat/marf-squash-engine
francesco-stacks Apr 2, 2026
3ac2225
add changelog fragment
francesco-stacks Apr 2, 2026
a4007b4
Merge branch 'feat/marf-squash-foundation' into feat/marf-squash-engine
francesco-stacks Apr 27, 2026
eb62b95
Merge branch 'upstream-develop' into feat/marf-squash-engine
francesco-stacks May 8, 2026
8eb6275
refactor: stream blobs child-before-parent like dump_consume
francesco-stacks May 8, 2026
5db9691
refactor: remove unused code
francesco-stacks May 8, 2026
8b8832d
use is_squashed where possible
francesco-stacks May 11, 2026
70eafc0
use is_inline_child_ptr where possible
francesco-stacks May 11, 2026
cb393af
merge update_inline_child_ptrs and remap_ptrs_to_blob_offsets
francesco-stacks May 11, 2026
d38f8bd
feat: disable proofs for squashed marfs
francesco-stacks May 11, 2026
50d601b
feat: disable blocks lookups before squash height
francesco-stacks May 11, 2026
56cba88
error if output marf db or blobs already exist
francesco-stacks May 11, 2026
23ba282
varius nits and improved tests
francesco-stacks May 11, 2026
ce22a2a
rename InlineOnlyBlockMap -> BackptrFreeBlockMap
francesco-stacks May 11, 2026
0d24e87
fix: atomically commit squash finalization in a single sql transaction
francesco-stacks May 11, 2026
4e6dcad
remove compute_blob_offsets; stream_squash_blob computes its own offsets
francesco-stacks May 11, 2026
c207c61
reject leaf iteration below squash height
francesco-stacks May 11, 2026
67a8ffa
build NodeStore temp paths with PathBuf
francesco-stacks May 11, 2026
6eb0265
track writer offsets without per-node stream_position
francesco-stacks May 11, 2026
88d8a06
split MARF squash internals
francesco-stacks May 11, 2026
06a84b3
Merge branch 'develop' into feat/marf-squash-engine
francesco-stacks May 11, 2026
f1736df
crc: clear db and blobs on failure. improve logged info
francesco-stacks May 12, 2026
6e175b8
crc: user a single writer
francesco-stacks May 12, 2026
71ed7da
avoid copying hash when possible
francesco-stacks May 12, 2026
a642873
various nits
francesco-stacks May 12, 2026
e820a0e
crc: rename update_inline_child_ptrs -> resolve_inline_child_offsets
francesco-stacks May 12, 2026
a7e5652
simplify some gates for squashed marf
francesco-stacks May 12, 2026
20739d6
add read_squashed_block_root_hash_by_hash and give more consistent na…
francesco-stacks May 12, 2026
70a1aa1
crc: query Trie before SQL side tables
francesco-stacks May 12, 2026
db15da7
crc: remove redundant squash guard
francesco-stacks May 12, 2026
35f9d01
clippy
francesco-stacks May 12, 2026
cd0a433
crc: add cleanup log on error
francesco-stacks May 13, 2026
13186f1
crc: internalize reader into NodeStore
francesco-stacks May 13, 2026
2289f6b
Merge branch 'develop' into feat/marf-squash-engine
francesco-stacks May 13, 2026
fcb3f3a
crc: re-add comment
francesco-stacks May 13, 2026
820e32e
crc: remove old retry and open Reader at creation time
francesco-stacks May 13, 2026
6324b34
skip redundand seek in overwrite_node, collapse finish_writing and flush
francesco-stacks May 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/marf-squash-engine.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add MARF squash engine (`squash_to_path`) and squash-aware trie lookups for root hashes and block heights
17 changes: 16 additions & 1 deletion stackslib/src/chainstate/stacks/index/marf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use rusqlite::{Connection, Transaction};
use stacks_common::types::chainstate::{TrieHash, TRIEHASH_ENCODED_SIZE};
use stacks_common::util::hash::Sha512Trunc256Sum;

pub use super::squash::{
SquashStats, MARF_SQUASHED_BLOCK_ROOT_HASH_KEY, MARF_SQUASH_HEIGHT_KEY, MARF_SQUASH_ROOT_KEY,
};
use super::storage::ReopenedTrieStorageConnection;
use crate::chainstate::stacks::index::bits::{get_leaf_hash, get_node_hash};
use crate::chainstate::stacks::index::node::{
Expand All @@ -35,7 +38,9 @@ use crate::chainstate::stacks::index::storage::{
TrieStorageTransaction,
};
use crate::chainstate::stacks::index::trie::Trie;
use crate::chainstate::stacks::index::{Error, MARFValue, MarfTrieId, TrieLeaf, TrieMerkleProof};
use crate::chainstate::stacks::index::{
trie_sql, Error, MARFValue, MarfTrieId, TrieLeaf, TrieMerkleProof,
};
use crate::util_lib::db::Error as db_error;

pub const BLOCK_HASH_TO_HEIGHT_MAPPING_KEY: &str = "__MARF_BLOCK_HASH_TO_HEIGHT";
Expand Down Expand Up @@ -1341,6 +1346,16 @@ impl<T: MarfTrieId> MARF<T> {
}
}

// In a squashed MARF, OWN_BLOCK_HEIGHT_KEY returns the squash
// height H for every block in the squashed range. Use the
// side-table when available.
if storage.squash_info().is_some() {
if let Some(h) = trie_sql::read_squash_block_height(storage.sqlite_conn(), block_hash)?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume that in the vast majority of cases, this function is going to becalled with the chain tip or very close to it.

If that's true, wouldn't it be better if we tried the MARF first, and only fall back to SQL later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe this is a valid point. In normal operations that will be the case. we'll mostly read from the squash during clarity lookups, block replay, and the RPC endpoints in general. Anyway I did the change , it was a bit more involved than I expected, because the sql lookup first removed a couple of edge cases 70a1aa1

{
return Ok(Some(h));
}
}
Comment thread
francesco-stacks marked this conversation as resolved.
Outdated

let marf_value = if block_hash == current_block_hash {
MARF::get_by_key(storage, current_block_hash, OWN_BLOCK_HEIGHT_KEY)?
} else {
Expand Down
1 change: 1 addition & 0 deletions stackslib/src/chainstate/stacks/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub mod marf;
pub mod node;
pub mod profile;
pub mod proofs;
pub mod squash;
pub mod storage;
pub mod trie;
pub mod trie_sql;
Expand Down
Loading
Loading