-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(executor): Generic precompile overrides
## Overview Adds a generic route for overriding precompiles in the `StatelessL2BlockExecutor`. This allows for different consumers to override the various precompiles in a way that suits their own needs.
- Loading branch information
Showing
4 changed files
with
93 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! Contains the [PrecompileOverride] trait. | ||
use kona_mpt::{TrieDB, TrieDBFetcher, TrieDBHinter}; | ||
use revm::{db::State, handler::register::EvmHandler}; | ||
|
||
/// A trait for defining precompile overrides during execution. | ||
pub trait PrecompileOverride<F, H> | ||
where | ||
F: TrieDBFetcher, | ||
H: TrieDBHinter, | ||
{ | ||
/// Set the precompiles to use during execution. | ||
fn set_precompiles(handler: &mut EvmHandler<'_, (), &mut State<TrieDB<F, H>>>); | ||
} | ||
|
||
/// Default implementation of [PrecompileOverride], which does not override any precompiles. | ||
#[derive(Debug, Default)] | ||
pub struct NoPrecompileOverride; | ||
|
||
impl<F, H> PrecompileOverride<F, H> for NoPrecompileOverride | ||
where | ||
F: TrieDBFetcher, | ||
H: TrieDBHinter, | ||
{ | ||
fn set_precompiles(_: &mut EvmHandler<'_, (), &mut State<TrieDB<F, H>>>) { | ||
// Do nothing | ||
} | ||
} |