You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(l1): overlay + read cascade for deep reorgs (#6687)
> Part of the deep-reorg support effort tracked in #6685. This is PR 2
of 4, stacked on #6686. Adds the in-memory consumer of the journal; no
orchestration yet.
## Summary
- Adds `Overlay` struct in `crates/storage/layering.rs` that aggregates
reverse-diffs from `STATE_HISTORY[D..=T]` (descending, older-entry-wins)
to reconstruct virtual state at pivot `T-1`.
- Extends `TrieLayerCache` with optional overlay field and wires
`TrieWrapper::get` to cascade: layer cache -> overlay -> disk.
- 14 new unit tests; 30 storage tests total pass on both InMemory and
RocksDB backends.
## What's in this PR
- `Overlay` struct: walks the journal range descending, applies
older-entry-wins semantics, holds a bloom filter for fast miss
short-circuits.
- `OverlayCf` enum + `classify_by_key_length`: routes CF entries to the
right column family using the same key-length logic as PR 1's
`classify_trie_key`.
- `OverlayError::InvalidRange { from_block, to_block }`: hard error for
swapped caller args (not an I/O error variant).
- `TrieLayerCache` set/clear/lookup accessors for the overlay field.
- `TrieWrapper::get` cascade hook integrated into the existing read
path.
- 14 unit tests: descending-range load, older-wins, bloom miss, hash
mismatch, missing entry, swapped-args hard error,
single-entry-at-genesis, empty-but-present round trip, CF
classification, no-overlay short-circuit, set/clear, iter_all_entries.
## What's NOT in this PR
- Orchestration: `apply_fork_choice_with_deep_reorg`,
`install_overlay_for_reorg`, and the reorg-in-progress flag are in PR 3.
- The 128-block reorg cap is not lifted; that's PR 4.
- `from_block` accessor rename (triggers clippy `wrong_self_convention`,
suppressed); deferred to PR 3.
- Swapping `AtomicBloomFilter` for a non-atomic variant during
construction for perf; deferred to PR 3 or PR 4.
## Test plan
- `cargo fmt` clean.
- `cargo clippy` clean.
- 14 new tests added in `crates/storage/layering.rs`.
- `cargo test -p ethrex-storage` passes all 30 tests on both InMemory
and RocksDB backends.
## References
- Parent issue: #6685
- PR 1 (state history journal): #6686
---------
Co-authored-by: ilitteri <ivanlitteri@hotmail.com>
Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com>
Copy file name to clipboardExpand all lines: cmd/ethrex/cli.rs
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -460,6 +460,14 @@ pub struct Options {
460
460
env = "ETHREX_PRECOMPUTE_WITNESSES"
461
461
)]
462
462
pubprecompute_witnesses:bool,
463
+
#[arg(
464
+
long = "max-reorg-depth",
465
+
value_name = "MAX_REORG_DEPTH",
466
+
help = "Optional operator override for the maximum reorg depth. Omit for finality-bounded cap. Set to 0 to disable deep reorgs entirely. Set to d to reject reorgs of depth > d.",
0 commit comments