reth_storage_api

Trait StateRootProvider

Source
pub trait StateRootProvider: Send + Sync {
    // Required methods
    fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>;
    fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>;
    fn state_root_with_updates(
        &self,
        hashed_state: HashedPostState,
    ) -> ProviderResult<(B256, TrieUpdates)>;
    fn state_root_from_nodes_with_updates(
        &self,
        input: TrieInput,
    ) -> ProviderResult<(B256, TrieUpdates)>;
}
Expand description

A type that can compute the state root of a given post state.

Required Methods§

Source

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

Returns the state root of the BundleState on top of the current state.

§Note

It is recommended to provide a different implementation from state_root_with_updates since it affects the memory usage during state root computation.

Source

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

Returns the state root of the HashedPostState on top of the current state but re-uses the intermediate nodes to speed up the computation. It’s up to the caller to construct the prefix sets and inform the provider of the trie paths that have changes.

Source

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

Returns the state root of the HashedPostState on top of the current state with trie updates to be committed to the database.

Source

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

Returns state root and trie updates. See StateRootProvider::state_root_from_nodes for more info.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + StateRootProvider + ?Sized> StateRootProvider for &'a T
where &'a T: Send + Sync,

Source§

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

Source§

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

Source§

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

Source§

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

Source§

impl<T: StateRootProvider + ?Sized> StateRootProvider for Box<T>
where Box<T>: Send + Sync,

Source§

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

Source§

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

Source§

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

Source§

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

Source§

impl<T: StateRootProvider + ?Sized> StateRootProvider for Arc<T>
where Arc<T>: Send + Sync,

Source§

fn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>

Source§

fn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>

Source§

fn state_root_with_updates( &self, hashed_state: HashedPostState, ) -> ProviderResult<(B256, TrieUpdates)>

Source§

fn state_root_from_nodes_with_updates( &self, input: TrieInput, ) -> ProviderResult<(B256, TrieUpdates)>

Implementors§