Skip to content

Commit

Permalink
fix: use precompile const (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 28, 2024
1 parent a6b6297 commit 451aa95
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
cargo nextest run \
--locked \
--workspace \
-E 'kind(test)'
-E 'kind(test)' \
--no-tests=warn
integration-success:
name: integration success
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
cargo nextest run \
--locked \
--workspace \
-E "(kind(lib) | kind(bin) | kind(proc-macro)) & !package(odyssey-e2e-tests)"
-E "(kind(lib) | kind(bin) | kind(proc-macro)) & !package(odyssey-e2e-tests)" \
--no-tests=warn
doc:
name: doc tests
Expand Down
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 451aa95

Please sign in to comment.