mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
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.
This commit is contained in:
@ -14,8 +14,8 @@ use revm::{
|
|||||||
result::{EVMError, HaltReason},
|
result::{EVMError, HaltReason},
|
||||||
TxEnv,
|
TxEnv,
|
||||||
},
|
},
|
||||||
handler::EthPrecompiles,
|
|
||||||
inspector::NoOpInspector,
|
inspector::NoOpInspector,
|
||||||
|
precompile::{PrecompileSpecId, Precompiles},
|
||||||
Inspector,
|
Inspector,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,15 +38,14 @@ impl EvmFactory for HlEvmFactory {
|
|||||||
db: DB,
|
db: DB,
|
||||||
input: EvmEnv<HlSpecId>,
|
input: EvmEnv<HlSpecId>,
|
||||||
) -> Self::Evm<DB, NoOpInspector> {
|
) -> Self::Evm<DB, NoOpInspector> {
|
||||||
|
let spec_id = *input.spec_id();
|
||||||
HlEvm {
|
HlEvm {
|
||||||
inner: Context::hl()
|
inner: Context::hl()
|
||||||
.with_block(input.block_env)
|
.with_block(input.block_env)
|
||||||
.with_cfg(input.cfg_env)
|
.with_cfg(input.cfg_env)
|
||||||
.with_db(db)
|
.with_db(db)
|
||||||
.build_hl_with_inspector(NoOpInspector {})
|
.build_hl_with_inspector(NoOpInspector {})
|
||||||
.with_precompiles(PrecompilesMap::from_static(
|
.with_precompiles(hl_precompiles(spec_id)),
|
||||||
EthPrecompiles::default().precompiles,
|
|
||||||
)),
|
|
||||||
inspect: false,
|
inspect: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,16 +59,20 @@ impl EvmFactory for HlEvmFactory {
|
|||||||
input: EvmEnv<HlSpecId>,
|
input: EvmEnv<HlSpecId>,
|
||||||
inspector: I,
|
inspector: I,
|
||||||
) -> Self::Evm<DB, I> {
|
) -> Self::Evm<DB, I> {
|
||||||
|
let spec_id = *input.spec_id();
|
||||||
HlEvm {
|
HlEvm {
|
||||||
inner: Context::hl()
|
inner: Context::hl()
|
||||||
.with_block(input.block_env)
|
.with_block(input.block_env)
|
||||||
.with_cfg(input.cfg_env)
|
.with_cfg(input.cfg_env)
|
||||||
.with_db(db)
|
.with_db(db)
|
||||||
.build_hl_with_inspector(inspector)
|
.build_hl_with_inspector(inspector)
|
||||||
.with_precompiles(PrecompilesMap::from_static(
|
.with_precompiles(hl_precompiles(spec_id)),
|
||||||
EthPrecompiles::default().precompiles,
|
|
||||||
)),
|
|
||||||
inspect: true,
|
inspect: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hl_precompiles(spec_id: HlSpecId) -> PrecompilesMap {
|
||||||
|
let spec = PrecompileSpecId::from_spec_id(spec_id.into());
|
||||||
|
PrecompilesMap::from_static(Precompiles::new(spec))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user