Skip to main content

SnapStateVerifier

Trait SnapStateVerifier 

Source
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 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.

Writes join the caller’s transaction, so a refused check changes nothing.

Required Methods§

Source

fn start_trie_rebuild( &self, write: SnapWrite, chunk: u64, cancel: &CancellationToken, ) -> Result<(), SnapSyncError>

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.

Source

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.

Source

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.

Source

fn verify_state_root( &self, write: SnapWrite, ) -> Result<VerifiedSnapState, SnapSyncError>

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".

Implementors§