Skip to content

Commit

Permalink
feat: added P256Verify precompile to 0x100 (#126)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Dhruv-2003 authored Jan 12, 2025
1 parent 016be2c commit 9f821ec
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions crates/node/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ use reth_revm::{
},
ContextPrecompiles, Database, Evm, EvmBuilder, GetInspector,
};
use revm_precompile::{secp256r1::p256_verify, u64_to_address, PrecompileWithAddress};
use revm_precompile::{
secp256r1::{p256_verify, P256VERIFY as REVM_P256VERIFY},
u64_to_address, PrecompileWithAddress,
};
use revm_primitives::{CfgEnvWithHandlerCfg, Precompile, TxEnv};
use std::sync::Arc;

Expand All @@ -53,7 +56,7 @@ impl OdysseyEvmConfig {
}

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

/// Sets the precompiles to the EVM handler
Expand Down Expand Up @@ -344,4 +347,19 @@ mod tests {

assert_eq!(cfg_env.chain_id, chain_spec.chain().id());
}

#[test]
fn test_p256verify_precompile_availability() {
let evm = EvmBuilder::default()
.with_empty_db()
.optimism()
// add additional precompiles
.append_handler_register(OdysseyEvmConfig::set_precompiles)
.build();

// loading the precompiles from pre execution instead of the evm context directly, as they are only set pre-execution in the context
let precompiles = evm.handler.pre_execution().load_precompiles();
assert!(precompiles.contains(&u64_to_address(0x14)));
assert!(precompiles.contains(&u64_to_address(0x100)));
}
}

0 comments on commit 9f821ec

Please sign in to comment.