Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic data primitives BlockExecutionStrategy #12946

Closed
Tracked by #12358
emhane opened this issue Nov 28, 2024 · 1 comment
Closed
Tracked by #12358

Generic data primitives BlockExecutionStrategy #12946

emhane opened this issue Nov 28, 2024 · 1 comment
Labels
A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain

Comments

@emhane
Copy link
Member

emhane commented Nov 28, 2024

Describe the feature

Make BlockExecutionStrategy generic over data primitives

/// Defines the strategy for executing a single block.
pub trait BlockExecutionStrategy<DB>
where
DB: Database,
{
/// The error type returned by this strategy's methods.
type Error: From<ProviderError> + core::error::Error;
/// Initialize the strategy with the given transaction environment overrides.
fn init(&mut self, _tx_env_overrides: Box<dyn TxEnvOverrides>) {}
/// Applies any necessary changes before executing the block's transactions.
fn apply_pre_execution_changes(
&mut self,
block: &BlockWithSenders,
total_difficulty: U256,
) -> Result<(), Self::Error>;
/// Executes all transactions in the block.
fn execute_transactions(
&mut self,
block: &BlockWithSenders,
total_difficulty: U256,
) -> Result<ExecuteOutput, Self::Error>;
/// Applies any necessary changes after executing the block's transactions.
fn apply_post_execution_changes(
&mut self,
block: &BlockWithSenders,
total_difficulty: U256,
receipts: &[Receipt],
) -> Result<Requests, Self::Error>;
/// Returns a reference to the current state.
fn state_ref(&self) -> &State<DB>;
/// Returns a mutable reference to the current state.
fn state_mut(&mut self) -> &mut State<DB>;
/// Sets a hook to be called after each state change during execution.
fn with_state_hook(&mut self, _hook: Option<Box<dyn OnStateHook>>) {}
/// Returns the final bundle state.
fn finish(&mut self) -> BundleState {
self.state_mut().merge_transitions(BundleRetention::Reverts);
self.state_mut().take_bundle()
}
/// Validate a block with regard to execution results.
fn validate_block_post_execution(
&self,
_block: &BlockWithSenders,
_receipts: &[Receipt],
_requests: &Requests,
) -> Result<(), ConsensusError> {
Ok(())
}
}

Additional context

No response

@emhane emhane added A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain labels Nov 28, 2024
@Rjected
Copy link
Member

Rjected commented Nov 29, 2024

Fixed by #12994

@Rjected Rjected closed this as completed Nov 29, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Reth Tracker Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants