-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(executor): Expose full revm Handler (#475)
* feat(executor): Expose full `revm` Handler Improves the API around the `revm` handler in the `StatelessL2BlockExecutor` to allow for a custom `HandleRegister` to be passed into the `StatelessL2BlockExecutorBuilder`. * doc lint lint
- Loading branch information
Showing
11 changed files
with
93 additions
and
151 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,49 @@ | ||
//! Contains the [KonaHandleRegister] function for registering the FPVM-accelerated precompiles. | ||
//! | ||
//! [KonaHandleRegister]: kona_executor::KonaHandleRegister | ||
|
||
use alloc::sync::Arc; | ||
use kona_mpt::{TrieDB, TrieDBFetcher, TrieDBHinter}; | ||
use revm::{ | ||
handler::register::EvmHandler, precompile::PrecompileSpecId, primitives::SpecId, | ||
ContextPrecompiles, State, | ||
}; | ||
|
||
mod bn128_pair; | ||
mod ecrecover; | ||
mod kzg_point_eval; | ||
|
||
/// The [KonaHandleRegister] function for registering the FPVM-accelerated precompiles. | ||
/// | ||
/// [KonaHandleRegister]: kona_executor::KonaHandleRegister | ||
pub(crate) fn fpvm_handle_register<F, H>( | ||
handler: &mut EvmHandler<'_, (), &mut State<&mut TrieDB<F, H>>>, | ||
) where | ||
F: TrieDBFetcher, | ||
H: TrieDBHinter, | ||
{ | ||
let spec_id = handler.cfg.spec_id; | ||
|
||
handler.pre_execution.load_precompiles = Arc::new(move || { | ||
let mut ctx_precompiles = | ||
ContextPrecompiles::new(PrecompileSpecId::from_spec_id(spec_id)).clone(); | ||
|
||
// Extend with FPVM-accelerated precompiles | ||
let override_precompiles = [ | ||
ecrecover::FPVM_ECRECOVER, | ||
bn128_pair::FPVM_ECPAIRING, | ||
kzg_point_eval::FPVM_KZG_POINT_EVAL, | ||
]; | ||
ctx_precompiles.extend(override_precompiles); | ||
|
||
// Ensure the secp256r1 P256verify precompile is enabled in the FJORD spec | ||
if spec_id.is_enabled_in(SpecId::FJORD) { | ||
ctx_precompiles.extend([ | ||
// EIP-7212: secp256r1 P256verify | ||
revm::precompile::secp256r1::P256VERIFY, | ||
]); | ||
} | ||
|
||
ctx_precompiles | ||
}); | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.