From eb7c6b050c8e8bf1ff0d2f837d78036429c0d583 Mon Sep 17 00:00:00 2001 From: sprites0 <199826320+sprites0@users.noreply.github.com> Date: Tue, 15 Jul 2025 22:53:47 +0000 Subject: [PATCH] fix: Use correct hardforks for PrecompilesMap PrecompilesMap.set_spec simply returns false while EthPrecompiles doesn't. Since create_evm* already receives spec id, we can utilize the fork information here when initiating PrecompilesMap. In a long term, implementing own PrecompilesProvider wrapping PrecompilesMap can be considered, but for now the problem can be handled like this. --- src/node/evm/factory.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/node/evm/factory.rs b/src/node/evm/factory.rs index 843ae2192..7a08ab3e9 100644 --- a/src/node/evm/factory.rs +++ b/src/node/evm/factory.rs @@ -14,8 +14,8 @@ use revm::{ result::{EVMError, HaltReason}, TxEnv, }, - handler::EthPrecompiles, inspector::NoOpInspector, + precompile::{PrecompileSpecId, Precompiles}, Inspector, }; @@ -38,15 +38,14 @@ impl EvmFactory for HlEvmFactory { db: DB, input: EvmEnv, ) -> Self::Evm { + let spec_id = *input.spec_id(); HlEvm { inner: Context::hl() .with_block(input.block_env) .with_cfg(input.cfg_env) .with_db(db) .build_hl_with_inspector(NoOpInspector {}) - .with_precompiles(PrecompilesMap::from_static( - EthPrecompiles::default().precompiles, - )), + .with_precompiles(hl_precompiles(spec_id)), inspect: false, } } @@ -60,16 +59,20 @@ impl EvmFactory for HlEvmFactory { input: EvmEnv, inspector: I, ) -> Self::Evm { + let spec_id = *input.spec_id(); HlEvm { inner: Context::hl() .with_block(input.block_env) .with_cfg(input.cfg_env) .with_db(db) .build_hl_with_inspector(inspector) - .with_precompiles(PrecompilesMap::from_static( - EthPrecompiles::default().precompiles, - )), + .with_precompiles(hl_precompiles(spec_id)), inspect: true, } } } + +fn hl_precompiles(spec_id: HlSpecId) -> PrecompilesMap { + let spec = PrecompileSpecId::from_spec_id(spec_id.into()); + PrecompilesMap::from_static(Precompiles::new(spec)) +}