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§
Sourcefn state_root(&self, hashed_state: HashedPostState) -> ProviderResult<B256>
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.
Sourcefn state_root_from_nodes(&self, input: TrieInput) -> ProviderResult<B256>
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.
Sourcefn state_root_with_updates(
&self,
hashed_state: HashedPostState,
) -> ProviderResult<(B256, TrieUpdates)>
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.
Sourcefn state_root_from_nodes_with_updates(
&self,
input: TrieInput,
) -> ProviderResult<(B256, TrieUpdates)>
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.