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

fix: use precompile const #106

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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