pub trait BlockExecutionStrategy {
type DB: Database;
type Primitives: NodePrimitives;
type Error: From<ProviderError> + Error;
// Required methods
fn apply_pre_execution_changes(
&mut self,
block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
) -> Result<(), Self::Error>;
fn execute_transactions(
&mut self,
block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
) -> Result<ExecuteOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>;
fn apply_post_execution_changes(
&mut self,
block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
receipts: &[<Self::Primitives as NodePrimitives>::Receipt],
) -> Result<Requests, Self::Error>;
fn state_ref(&self) -> &State<Self::DB>;
fn state_mut(&mut self) -> &mut State<Self::DB>;
// Provided methods
fn init(&mut self, _tx_env_overrides: Box<dyn TxEnvOverrides>) { ... }
fn with_state_hook(&mut self, _hook: Option<Box<dyn OnStateHook>>) { ... }
fn finish(&mut self) -> BundleState { ... }
fn validate_block_post_execution(
&self,
_block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
_receipts: &[<Self::Primitives as NodePrimitives>::Receipt],
_requests: &Requests,
) -> Result<(), ConsensusError> { ... }
}
Expand description
Defines the strategy for executing a single block.
Required Associated Types§
Sourcetype Primitives: NodePrimitives
type Primitives: NodePrimitives
Primitive types used by the strategy.
Sourcetype Error: From<ProviderError> + Error
type Error: From<ProviderError> + Error
The error type returned by this strategy’s methods.
Required Methods§
Sourcefn apply_pre_execution_changes(
&mut self,
block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
) -> Result<(), Self::Error>
fn apply_pre_execution_changes( &mut self, block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<(), Self::Error>
Applies any necessary changes before executing the block’s transactions.
Sourcefn execute_transactions(
&mut self,
block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
) -> Result<ExecuteOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
fn execute_transactions( &mut self, block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<ExecuteOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
Executes all transactions in the block.
Sourcefn apply_post_execution_changes(
&mut self,
block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
receipts: &[<Self::Primitives as NodePrimitives>::Receipt],
) -> Result<Requests, Self::Error>
fn apply_post_execution_changes( &mut self, block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, receipts: &[<Self::Primitives as NodePrimitives>::Receipt], ) -> Result<Requests, Self::Error>
Applies any necessary changes after executing the block’s transactions.
Provided Methods§
Sourcefn init(&mut self, _tx_env_overrides: Box<dyn TxEnvOverrides>)
fn init(&mut self, _tx_env_overrides: Box<dyn TxEnvOverrides>)
Initialize the strategy with the given transaction environment overrides.
Sourcefn with_state_hook(&mut self, _hook: Option<Box<dyn OnStateHook>>)
fn with_state_hook(&mut self, _hook: Option<Box<dyn OnStateHook>>)
Sets a hook to be called after each state change during execution.
Sourcefn validate_block_post_execution(
&self,
_block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>,
_receipts: &[<Self::Primitives as NodePrimitives>::Receipt],
_requests: &Requests,
) -> Result<(), ConsensusError>
fn validate_block_post_execution( &self, _block: &BlockWithSenders<<Self::Primitives as NodePrimitives>::Block>, _receipts: &[<Self::Primitives as NodePrimitives>::Receipt], _requests: &Requests, ) -> Result<(), ConsensusError>
Validate a block with regard to execution results.