Skip to content

Commit

Permalink
fix: use precompile const
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Nov 28, 2024
1 parent a6b6297 commit abb919b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions crates/node/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ use reth_revm::{
},
ContextPrecompiles, Database, Evm, EvmBuilder, GetInspector,
};
use revm_precompile::secp256r1;
use revm_primitives::{CfgEnvWithHandlerCfg, TxEnv};
use revm_precompile::{secp256r1::p256_verify, u64_to_address, PrecompileWithAddress};
use revm_primitives::{CfgEnvWithHandlerCfg, Precompile, TxEnv};
use std::sync::Arc;

/// P256 verify precompile address.
pub const P256VERIFY_ADDRESS: u64 = 0x14;

/// [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212#specification) secp256r1 precompile.
pub const P256VERIFY: PrecompileWithAddress =
PrecompileWithAddress(u64_to_address(P256VERIFY_ADDRESS), Precompile::Standard(p256_verify));

/// Custom EVM configuration
#[derive(Debug, Clone)]
pub struct OdysseyEvmConfig {
Expand All @@ -43,6 +50,10 @@ impl OdysseyEvmConfig {
Self { chain_spec }
}

fn precompiles() -> impl Iterator<Item = PrecompileWithAddress> {
[P256VERIFY].into_iter()
}

/// Sets the precompiles to the EVM handler
///
/// This will be invoked when the EVM is created via [`ConfigureEvm::evm`] or
Expand All @@ -61,7 +72,7 @@ impl OdysseyEvmConfig {
let mut loaded_precompiles: ContextPrecompiles<DB> =
ContextPrecompiles::new(PrecompileSpecId::from_spec_id(spec_id));

loaded_precompiles.extend(secp256r1::precompiles());
loaded_precompiles.extend(Self::precompiles());

loaded_precompiles
});
Expand Down

0 comments on commit abb919b

Please sign in to comment.