Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
77c61a6
add benching util
iovoid Sep 9, 2025
37fadd9
edit root cargo.toml
iovoid Sep 9, 2025
731f5ef
basic pathbased impl
iovoid Sep 10, 2025
29850f8
improve serialization
iovoid Sep 10, 2025
4f8e956
read optimization
iovoid Sep 10, 2025
fa27f76
fixes
iovoid Sep 11, 2025
9bda718
start fixing snapsync
iovoid Sep 11, 2025
fd66967
cleanup
iovoid Sep 11, 2025
26a5715
validate node fetches
iovoid Sep 11, 2025
aa86d98
fix opening hash
iovoid Sep 11, 2025
675ee90
fix state healing node fetch
iovoid Sep 11, 2025
60e3476
Merge branch 'main' into pathbased_testing
iovoid Sep 16, 2025
cc54cd9
fix merge
iovoid Sep 16, 2025
e3103f0
cleanup
iovoid Sep 16, 2025
fd0a71c
remove contains_X_node APIs
iovoid Sep 16, 2025
148655f
lint
iovoid Sep 16, 2025
0592338
heal terminal leaves too
iovoid Sep 16, 2025
8aa3966
fix rocksdb test
iovoid Sep 17, 2025
175de2d
save rollback logs
iovoid Sep 17, 2025
454db9b
Revert "save rollback logs"
iovoid Sep 18, 2025
8eac9a9
re-add full-path leaves
iovoid Sep 18, 2025
2678119
lint&fix
iovoid Sep 18, 2025
cfda5fb
basic trie layer implementation
iovoid Sep 18, 2025
a23275d
add passthrough for trie wrapper, for now
iovoid Sep 18, 2025
e1b301c
flush batch to cache instead of db
iovoid Sep 19, 2025
5c34ee8
Merge branch 'main' into pathbased_testing
iovoid Sep 19, 2025
e4f5a18
clippy
iovoid Sep 19, 2025
3af5e60
fix insert ordering
iovoid Sep 19, 2025
b8d5a78
better find the state root
iovoid Sep 19, 2025
840cb3d
fix storage handling
iovoid Sep 19, 2025
77458d4
fix insert-after-remove
iovoid Sep 22, 2025
fad5ba5
revert head to last state
iovoid Sep 23, 2025
9935d98
direct trie and fixes
iovoid Sep 24, 2025
a011a3e
fix incorrect miss
iovoid Sep 24, 2025
5f41620
snapsync fixes
iovoid Sep 25, 2025
63f01dc
Merge branch 'main' into pathbased_testing
iovoid Sep 25, 2025
dede3ab
also delete from db
iovoid Sep 25, 2025
fa28ad7
add healing logic
iovoid Sep 26, 2025
fa47749
healing fixes
iovoid Sep 29, 2025
ee75c19
docs: add comment
MegaRedHand Sep 29, 2025
6136bf8
refactor: add delete_range function in Store
MegaRedHand Sep 29, 2025
2b077da
Revert "refactor: add delete_range function in Store"
MegaRedHand Sep 29, 2025
fc02510
delete range improvement
iovoid Sep 29, 2025
aa63a77
Reapply "refactor: add delete_range function in Store"
MegaRedHand Sep 29, 2025
9e06da7
fix extension range delete
iovoid Sep 29, 2025
8750945
fix: add logs and add fix to storage healing
MegaRedHand Sep 29, 2025
0c6ba6e
fix delete path calculation
iovoid Sep 29, 2025
3a01580
Improved logs for speed
fedacking Sep 29, 2025
e5645dd
Update storage_healing.rs
fedacking Sep 29, 2025
ef27dc6
test: add test for computing subtree ranges
MegaRedHand Sep 29, 2025
49e817f
chore: comment out spammy print
MegaRedHand Sep 29, 2025
dce6506
Merge branch 'main' into pathbased_testing
MegaRedHand Sep 29, 2025
63eec48
perf: remove unnecessary clone
MegaRedHand Sep 29, 2025
f688021
fix: use full path when computing storage range
MegaRedHand Sep 30, 2025
5d45a41
chore: remove logs
MegaRedHand Sep 30, 2025
d4cdc9c
chore: remove commented print
MegaRedHand Sep 30, 2025
2d81017
do not return empty value nodes
iovoid Sep 30, 2025
9f0a639
Merge branch 'main' into pathbased_testing
MegaRedHand Sep 30, 2025
bb0464f
fix: remove nodes when writing empty
MegaRedHand Sep 30, 2025
9387932
refactor: improve InconsistentTree error messages
MegaRedHand Sep 30, 2025
8cfbe4c
move storage healing to db thread
iovoid Sep 30, 2025
f058dd6
also delete leaf-related paths
iovoid Oct 1, 2025
7dd5d73
chore: enable warn-on-block feature in spawned
MegaRedHand Oct 1, 2025
5c0a47c
fix
MegaRedHand Oct 1, 2025
f80e1b5
chore: disable warn-on-block again
MegaRedHand Oct 1, 2025
62dba3c
fix failed insertion error
iovoid Oct 1, 2025
ca69f55
Change vec for btreemap on nodes to write state healing
gianbelinche Oct 1, 2025
2753a9a
avoid costly deletions when not needed
iovoid Oct 1, 2025
dd45f7d
Merge branch 'main' into pathbased_testing
MegaRedHand Oct 2, 2025
cd889eb
Add delete range batch
gianbelinche Oct 2, 2025
36d7a40
Add delete ranges log
gianbelinche Oct 2, 2025
f8150c4
fix deleting the wrong nodes
iovoid Oct 2, 2025
389c8d4
Merge branch 'main' into pathbased_testing
MegaRedHand Oct 2, 2025
4a17209
remove unneeded apply_prefix
iovoid Oct 2, 2025
bbbe4eb
feat: add failed block hash to log
MegaRedHand Oct 2, 2025
844247f
also free peers in healing
iovoid Oct 3, 2025
e626ca0
avoid concurrent writes
iovoid Oct 3, 2025
a950ce2
Merge branch 'pathbased_testing' into pathbased_change_db_test
iovoid Oct 3, 2025
31b0590
regnerate snapshot from leaves after healing
iovoid Oct 3, 2025
bafbcc0
rename and update val
iovoid Oct 6, 2025
c60a57c
fixes
iovoid Oct 7, 2025
986f059
disable snapshots
iovoid Oct 7, 2025
d99b01a
restore snap cycle size
iovoid Oct 7, 2025
c703e13
remove spammy log
iovoid Oct 7, 2025
a82b75c
chore: run cargo fmt
MegaRedHand Oct 7, 2025
c0ee61e
chore: remove libmdbx
MegaRedHand Oct 7, 2025
78cbe11
Merge branch 'main' into path_based
MegaRedHand Oct 7, 2025
889a696
chore: fix some clippy issues
MegaRedHand Oct 7, 2025
5fb1428
chore: add some changes from old branch
MegaRedHand Oct 7, 2025
c8a0671
chore: remove unused delete_range functions
MegaRedHand Oct 7, 2025
6b994c3
fix: implement eth_getProof again
MegaRedHand Oct 7, 2025
bd49420
fix bug in storage insertion
iovoid Oct 8, 2025
d595a6a
Merge branch 'main' into path_based
MegaRedHand Oct 8, 2025
ac7edd4
re-enable snapshots
iovoid Oct 8, 2025
9236bea
fix: implement new functionality for InMemoryDb
MegaRedHand Oct 8, 2025
12357f6
chore: remove get_node_checked
MegaRedHand Oct 8, 2025
3a9a443
chore: UNCOMMENT CONDITION
MegaRedHand Oct 8, 2025
0253eae
chore: fix lints
MegaRedHand Oct 8, 2025
0573013
fix leaf regen path
iovoid Oct 8, 2025
c7732cf
fix: update Trie::get_node
MegaRedHand Oct 8, 2025
f79ac75
chore: update archive_sync
MegaRedHand Oct 8, 2025
b28da0f
chore: bump max diff-layers to 128
MegaRedHand Oct 8, 2025
160381a
chore: ignore unused parameter
MegaRedHand Oct 8, 2025
449dbe5
chore: fix lint issue and add comment
MegaRedHand Oct 8, 2025
8721a47
Path based merge optimizations (#4825)
MegaRedHand Oct 9, 2025
95dcfec
Merge branch 'path_based' into pathbased_regen_leafs
pablodeymo Oct 9, 2025
44a4fdc
fix import
iovoid Oct 15, 2025
0a76511
split snapshot to separate table
iovoid Oct 15, 2025
285bb60
implement snapshoot
iovoid Oct 15, 2025
24c102a
launch in thread
iovoid Oct 15, 2025
92dc4f4
fixes
iovoid Oct 15, 2025
01ae76a
read empty last_written is missing
iovoid Oct 16, 2025
1ab221b
refactor snapshooter into separate thread
iovoid Oct 16, 2025
093b987
conditionally advance iterators
iovoid Oct 16, 2025
a317224
add logging
iovoid Oct 16, 2025
be14f5f
add debug logging
iovoid Oct 16, 2025
965474b
add logging and improve locked trie
iovoid Oct 16, 2025
8c48e34
empty snapshot table before starting
iovoid Oct 16, 2025
f504301
fix snapshot adding condition
iovoid Oct 16, 2025
811daf4
block until continue
iovoid Oct 16, 2025
10bb130
fix last_written advance
iovoid Oct 16, 2025
c65f10f
wait until write to signal snapshotter
iovoid Oct 16, 2025
bea428f
mark snapshot as complete when done
iovoid Oct 16, 2025
87a56e5
cleanup
iovoid Oct 16, 2025
6032348
Merge branch 'main' into pathbased_regen_versioning
iovoid Oct 16, 2025
8681ca8
fix merge
iovoid Oct 16, 2025
f477f81
remove unwanted changes
iovoid Oct 16, 2025
08424a6
fix duplicated wait
iovoid Oct 16, 2025
7856ee4
add docs
iovoid Oct 16, 2025
6bb4c64
fix fkv-done marker
iovoid Oct 17, 2025
f07ff1a
rename snapshot->FlatKeyValue
iovoid Oct 17, 2025
d692dba
save last fkv batch
iovoid Oct 17, 2025
88b65cc
check done marker
iovoid Oct 17, 2025
0dc67db
Merge branch 'main' into pathbased_regen_versioning
iovoid Oct 17, 2025
8059482
Merge branch 'main' into pathbased_regen_versioning
iovoid Oct 17, 2025
e688e36
fmt
iovoid Oct 17, 2025
ea12776
fix tests
iovoid Oct 17, 2025
cf89733
ignore fkv in test
iovoid Oct 17, 2025
036684d
Merge branch 'main' into pathbased_regen_versioning
iovoid Oct 17, 2025
1197e92
Merge remote-tracking branch 'origin/main' into pathbased_regen_versi…
Oppen Oct 18, 2025
09c5625
perf: preprocess code for jump destinations
Oppen Oct 18, 2025
2b86dfc
fix mask
Oppen Oct 18, 2025
1f6a807
fix mask for real
Oppen Oct 18, 2025
575a8a8
fix count
Oppen Oct 18, 2025
411e3d0
fix count
Oppen Oct 18, 2025
e307c90
restore missing check
Oppen Oct 18, 2025
1b4a9cb
remove unused filter code
Oppen Oct 18, 2025
5d9d05a
remove more unused code
Oppen Oct 18, 2025
791a5e1
off-by-one
Oppen Oct 18, 2025
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/ethrex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ethrex-sdk = { workspace = true, optional = true }
ethrex-storage.workspace = true
ethrex-storage-rollup = { workspace = true, optional = true }
ethrex-vm.workspace = true

ethrex-trie.workspace = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was removed in main:

Suggested change
ethrex-trie.workspace = true

tikv-jemallocator = { version = "0.6.0", optional = true, features = [
"stats",
"unprefixed_malloc_on_supported_platforms",
Expand Down
15 changes: 3 additions & 12 deletions crates/common/trie/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ pub trait TrieDB: Send + Sync {
fn put(&self, key: Nibbles, value: Vec<u8>) -> Result<(), TrieError> {
self.put_batch(vec![(key, value)])
}
fn flatkeyvalue_computed(&self, _key: Nibbles) -> bool {
false
}
}

/// InMemory implementation for the TrieDB trait, with get and put operations.
Expand Down Expand Up @@ -102,15 +105,3 @@ impl TrieDB for InMemoryTrieDB {
Ok(())
}
}

pub fn nibbles_to_fixed_size(nibbles: Nibbles) -> [u8; 33] {
let node_hash_ref = nibbles.to_bytes();
let original_len = node_hash_ref.len();

let mut buffer = [0u8; 33];

// Encode the node as [node_path..., original_len]
buffer[32] = nibbles.len() as u8;
buffer[..original_len].copy_from_slice(&node_hash_ref);
buffer
}
3 changes: 3 additions & 0 deletions crates/common/trie/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ impl NodeRef {
Node::Leaf(_) => {}
}
let hash = *hash.get_or_init(|| node.compute_hash());
if let Node::Leaf(leaf) = node.as_ref() {
acc.push((path.concat(&leaf.partial), leaf.value.clone()));
}
acc.push((path.clone(), node.encode_to_vec()));

*self = hash.into();
Expand Down
17 changes: 17 additions & 0 deletions crates/common/trie/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ impl Trie {
pub fn get(&self, pathrlp: &PathRLP) -> Result<Option<ValueRLP>, TrieError> {
let path = Nibbles::from_bytes(pathrlp);

if pathrlp.len() == 32
&& !self.pending_removal.contains(&path)
&& self.db().flatkeyvalue_computed(path.clone())
{
let Some(value_rlp) = self.db.get(path)? else {
return Ok(None);
};
if value_rlp.is_empty() {
return Ok(None);
}
return Ok(Some(value_rlp));
}

Ok(match self.root {
NodeRef::Node(ref node, _) => node.get(self.db.as_ref(), path)?,
NodeRef::Hash(hash) if hash.is_valid() => Node::decode(
Expand Down Expand Up @@ -138,6 +151,10 @@ impl Trie {
if !self.root.is_valid() {
return Ok(None);
}
if path.len() == 32 {
self.pending_removal.insert(Nibbles::from_bytes(path));
}

// If the trie is not empty, call the root node's removal logic.
let (node, value) = self
.root
Expand Down
4 changes: 4 additions & 0 deletions crates/common/trie/trie_sorted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ mod test {
let computed_data = computed_data.lock().unwrap();
let expected_data = expected_data.lock().unwrap();
for (k, v) in expected_data.iter() {
// skip flatkeyvalues, we don't want them
if k.last().cloned() == Some(16) {
continue;
}
assert!(computed_data.contains_key(k));
assert_eq!(*v, computed_data[k]);
}
Expand Down
2 changes: 2 additions & 0 deletions crates/networking/p2p/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ impl Syncer {
}
*METRICS.heal_end_time.lock().await = Some(SystemTime::now());

store.generate_flatkeyvalue()?;

debug_assert!(validate_state_root(store.clone(), pivot_header.state_root).await);
debug_assert!(validate_storage_root(store.clone(), pivot_header.state_root).await);

Expand Down
2 changes: 2 additions & 0 deletions crates/storage/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,6 @@ pub trait StoreEngine: Debug + Send + Sync + RefUnwindSafe {

/// Clear all headers downloaded during fullsync
async fn clear_fullsync_headers(&self) -> Result<(), StoreError>;

fn generate_flatkeyvalue(&self) -> Result<(), StoreError>;
}
2 changes: 2 additions & 0 deletions crates/storage/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ pub enum StoreError {
TryInto(#[from] std::num::TryFromIntError),
#[error("Update batch contains no blocks")]
UpdateBatchNoBlocks,
#[error("Pivot changed")]
PivotChanged,
}
12 changes: 9 additions & 3 deletions crates/storage/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,10 @@ impl Store {
pub async fn clear_fullsync_headers(&self) -> Result<(), StoreError> {
self.engine.clear_fullsync_headers().await
}

pub fn generate_flatkeyvalue(&self) -> Result<(), StoreError> {
self.engine.generate_flatkeyvalue()
}
}

pub struct AccountProof {
Expand Down Expand Up @@ -1456,17 +1460,19 @@ mod tests {
F: FnOnce(Store) -> Fut,
Fut: std::future::Future<Output = ()>,
{
let nonce: u64 = H256::random().to_low_u64_be();
let path = format!("store-test-db-{nonce}");
// Remove preexistent DBs in case of a failed previous test
if !matches!(engine_type, EngineType::InMemory) {
remove_test_dbs("store-test-db");
remove_test_dbs(&path);
};
// Build a new store
let store = Store::new("store-test-db", engine_type).expect("Failed to create test db");
let store = Store::new(&path, engine_type).expect("Failed to create test db");
// Run the test
test_func(store).await;
// Remove store (if needed)
if !matches!(engine_type, EngineType::InMemory) {
remove_test_dbs("store-test-db");
remove_test_dbs(&path);
};
}

Expand Down
6 changes: 6 additions & 0 deletions crates/storage/store_db/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,12 @@ impl StoreEngine for Store {
self.inner()?.fullsync_headers.clear();
Ok(())
}

fn generate_flatkeyvalue(&self) -> Result<(), StoreError> {
// FlatKeyValue currently not supported for the InMemory DB
// Silently ignoring the request to build the FlatKeyValue is harmless
Ok(())
}
}

impl Debug for Store {
Expand Down
Loading
Loading