pub trait SnapStateVerifier {
// Required methods
fn start_trie_rebuild(
&self,
write: SnapWrite,
chunk: u64,
cancel: &CancellationToken,
) -> Result<(), SnapSyncError>
where Self: MetadataWriter + StageCheckpointWriter + DBProvider;
fn verify_completeness(
&self,
write: SnapWrite,
chunk: u64,
cancel: &CancellationToken,
) -> Result<(), SnapSyncError>
where Self: DBProvider;
fn publish_snap_state(&self, pivot: u64) -> Result<(), SnapSyncError>
where Self: BlockWriter + PruneCheckpointWriter + StageCheckpointWriter + DBProvider<Tx: DbTxMut>;
fn is_trie_rebuild_started(
&self,
write: SnapWrite,
) -> Result<bool, SnapSyncError>;
fn verify_state_root(
&self,
write: SnapWrite,
) -> Result<VerifiedSnapState, SnapSyncError>
where Self: BlockHashReader + HeaderProvider + MetadataWriter + StageCheckpointReader;
}Expand description
Decides whether downloaded state can be trusted as the node’s state.
Verification writes join the caller’s transaction, so a refused check changes nothing.
Required Methods§
Sourcefn start_trie_rebuild(
&self,
write: SnapWrite,
chunk: u64,
cancel: &CancellationToken,
) -> Result<(), SnapSyncError>where
Self: MetadataWriter + StageCheckpointWriter + DBProvider,
fn start_trie_rebuild(
&self,
write: SnapWrite,
chunk: u64,
cancel: &CancellationToken,
) -> Result<(), SnapSyncError>where
Self: MetadataWriter + StageCheckpointWriter + DBProvider,
Hands complete state to the merkle stage, which rebuilds its trie from scratch.
Progress the stage recorded before the hand-off describes other state, so it is discarded. The hand-off is recorded for this attempt and pivot, so only a rebuild of this state counts.
Sourcefn verify_completeness(
&self,
write: SnapWrite,
chunk: u64,
cancel: &CancellationToken,
) -> Result<(), SnapSyncError>where
Self: DBProvider,
fn verify_completeness(
&self,
write: SnapWrite,
chunk: u64,
cancel: &CancellationToken,
) -> Result<(), SnapSyncError>where
Self: DBProvider,
Refuses to finish while any downloaded state is still pending. Storage commits with its accounts, so it needs no separate check.
Sourcefn publish_snap_state(&self, pivot: u64) -> Result<(), SnapSyncError>where
Self: BlockWriter + PruneCheckpointWriter + StageCheckpointWriter + DBProvider<Tx: DbTxMut>,
fn publish_snap_state(&self, pivot: u64) -> Result<(), SnapSyncError>where
Self: BlockWriter + PruneCheckpointWriter + StageCheckpointWriter + DBProvider<Tx: DbTxMut>,
Publishes the state downloaded at pivot: makes it the node’s state at that block, so the
pipeline resumes at pivot + 1 instead of executing from genesis.
- Moves the stages the downloaded state covers to
pivot. - Records history below
pivotas pruned. - Clears body indices, database receipts and transaction lookups, so transaction numbers
restart at 0 above
pivot.RocksDBlookups are cleared immediately, not on commit.
Publishing is not verification: the merkle stage and Finish wait for the trie rebuild.
It cannot be undone, the node must not unwind below pivot, and the caller resets the
static files to pivot in the same commit.
Sourcefn is_trie_rebuild_started(
&self,
write: SnapWrite,
) -> Result<bool, SnapSyncError>
fn is_trie_rebuild_started( &self, write: SnapWrite, ) -> Result<bool, SnapSyncError>
Returns whether write’s state was handed to the merkle stage, so a resumed sync does not
reset its rebuild.
Sourcefn verify_state_root(
&self,
write: SnapWrite,
) -> Result<VerifiedSnapState, SnapSyncError>where
Self: BlockHashReader + HeaderProvider + MetadataWriter + StageCheckpointReader,
fn verify_state_root(
&self,
write: SnapWrite,
) -> Result<VerifiedSnapState, SnapSyncError>where
Self: BlockHashReader + HeaderProvider + MetadataWriter + StageCheckpointReader,
Accepts the state once the merkle stage has rebuilt its trie up to the pivot.
The stage checks the root against the pivot header, which must commit to the root the state was downloaded against.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".