pub trait StatelessTrie: Debug {
// Required methods
fn new(
witness: &ExecutionWitness,
pre_state_root: B256,
) -> Result<(Self, B256Map<Bytecode>), StatelessValidationError>
where Self: Sized;
fn account(
&self,
address: Address,
) -> Result<Option<TrieAccount>, ProviderError>;
fn storage(
&self,
address: Address,
slot: U256,
) -> Result<U256, ProviderError>;
fn calculate_state_root(
&mut self,
state: HashedPostState,
) -> Result<B256, StatelessValidationError>;
}
Expand description
Trait for stateless trie implementations that can be used for stateless validation.
Required Methods§
Sourcefn new(
witness: &ExecutionWitness,
pre_state_root: B256,
) -> Result<(Self, B256Map<Bytecode>), StatelessValidationError>where
Self: Sized,
fn new(
witness: &ExecutionWitness,
pre_state_root: B256,
) -> Result<(Self, B256Map<Bytecode>), StatelessValidationError>where
Self: Sized,
Initialize the stateless trie using the ExecutionWitness
Sourcefn account(
&self,
address: Address,
) -> Result<Option<TrieAccount>, ProviderError>
fn account( &self, address: Address, ) -> Result<Option<TrieAccount>, ProviderError>
Returns the TrieAccount
that corresponds to the Address
This method will error if the ExecutionWitness
is not able to guarantee
that the account is missing from the Trie and the witness was complete.
Sourcefn storage(&self, address: Address, slot: U256) -> Result<U256, ProviderError>
fn storage(&self, address: Address, slot: U256) -> Result<U256, ProviderError>
Returns the storage slot value that corresponds to the given (address, slot) tuple.
This method will error if the ExecutionWitness
is not able to guarantee
that the storage was missing from the Trie and the witness was complete.
Sourcefn calculate_state_root(
&mut self,
state: HashedPostState,
) -> Result<B256, StatelessValidationError>
fn calculate_state_root( &mut self, state: HashedPostState, ) -> Result<B256, StatelessValidationError>
Computes the new state root from the HashedPostState
.