Skip to main content

Crate reth_snap_sync

Crate reth_snap_sync 

Source
Expand description

snap/2 state synchronization for EIP-8189.

Coordinates a state bootstrap that starts from a recent pivot block, downloads accounts, storage and bytecode authenticated against that pivot’s state root, and advances the pivot with EIP-7928 block access lists as the chain moves past it.

This crate owns download progress only. Authenticated downloads come from reth-downloaders, and verified state is handed back to node integration once its trie root matches the target header.

Downloaded state goes into the hashed state tables, owned by an attempt record that commits with it. Scheduling, in-flight requests and cancellation stay in memory.

use reth_snap_sync::SnapPivotPolicy;

let policy = SnapPivotPolicy::default();
// Without a finalized block, anchor at the EIP's example distance.
assert_eq!(policy.pivot_block(1_000, None), Some(936));
// A recent finalized block is anchored to directly.
assert_eq!(policy.pivot_block(1_000, Some(950)), Some(950));
// Stalled finality falls back to the example distance.
assert_eq!(policy.pivot_block(1_000, Some(500)), Some(936));
// A chain shorter than the head distance has no pivot yet.
assert_eq!(policy.pivot_block(4, None), None);

Structs§

SnapGeneration
One attempt at downloading state, anchored to the pivot block it targets.
SnapPivotPolicy
Distance and history bounds that decide where a generation is anchored.
SnapSyncSession
One snap synchronization attempt, from the pivot it targets to the work it owns.
SnapWrite
What a write presents to prove it belongs to the attempt owning the persisted state.

Enums§

SnapPhase
The stage a SnapGeneration has reached.
SnapSyncError
Error returned while assembling a snap state generation.
SnapSyncSessionState
What a SnapSyncSession is doing.

Traits§

SnapAttemptStore
Persistence for the attempt that owns downloaded snap state.