Skip to content

Commit 9f821ec

Browse files
authored
feat: added P256Verify precompile to 0x100 (#126)
Closes #125 Added `P256Verify` precompile to the `0x100` address and a test to check its availability at both the addresses The test is currently failing, and I'm not entirely sure about my implementation of test function. It might be causing the test to fail. lmk of any suggestions @onbjerg
1 parent 016be2c commit 9f821ec

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

crates/node/src/evm.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ use reth_revm::{
2929
},
3030
ContextPrecompiles, Database, Evm, EvmBuilder, GetInspector,
3131
};
32-
use revm_precompile::{secp256r1::p256_verify, u64_to_address, PrecompileWithAddress};
32+
use revm_precompile::{
33+
secp256r1::{p256_verify, P256VERIFY as REVM_P256VERIFY},
34+
u64_to_address, PrecompileWithAddress,
35+
};
3336
use revm_primitives::{CfgEnvWithHandlerCfg, Precompile, TxEnv};
3437
use std::sync::Arc;
3538

@@ -53,7 +56,7 @@ impl OdysseyEvmConfig {
5356
}
5457

5558
fn precompiles() -> impl Iterator<Item = PrecompileWithAddress> {
56-
[P256VERIFY].into_iter()
59+
[P256VERIFY, REVM_P256VERIFY].into_iter()
5760
}
5861

5962
/// Sets the precompiles to the EVM handler
@@ -344,4 +347,19 @@ mod tests {
344347

345348
assert_eq!(cfg_env.chain_id, chain_spec.chain().id());
346349
}
350+
351+
#[test]
352+
fn test_p256verify_precompile_availability() {
353+
let evm = EvmBuilder::default()
354+
.with_empty_db()
355+
.optimism()
356+
// add additional precompiles
357+
.append_handler_register(OdysseyEvmConfig::set_precompiles)
358+
.build();
359+
360+
// loading the precompiles from pre execution instead of the evm context directly, as they are only set pre-execution in the context
361+
let precompiles = evm.handler.pre_execution().load_precompiles();
362+
assert!(precompiles.contains(&u64_to_address(0x14)));
363+
assert!(precompiles.contains(&u64_to_address(0x100)));
364+
}
347365
}

0 commit comments

Comments
 (0)