diff --git a/bins/revme/src/statetest/runner.rs b/bins/revme/src/statetest/runner.rs index 55c388796e..1a8f81ffa7 100644 --- a/bins/revme/src/statetest/runner.rs +++ b/bins/revme/src/statetest/runner.rs @@ -172,7 +172,7 @@ pub fn execute_test_suit( } let mut env = Env::default(); // cfg env. SpecId is set down the road - env.cfg.chain_id = U256::from(1); // for mainnet + env.cfg.chain_id = 1; // for mainnet // block env env.block.number = unit.env.current_number; diff --git a/crates/interpreter/src/instructions/host_env.rs b/crates/interpreter/src/instructions/host_env.rs index e3d7d5fc6a..f666a59e83 100644 --- a/crates/interpreter/src/instructions/host_env.rs +++ b/crates/interpreter/src/instructions/host_env.rs @@ -1,3 +1,5 @@ +use revm_primitives::U256; + use crate::{ gas, interpreter::Interpreter, primitives::Spec, primitives::SpecId::*, Host, InstructionResult, }; @@ -6,7 +8,7 @@ pub fn chainid(interpreter: &mut Interpreter, host: &mut dyn Host) { // EIP-1344: ChainID opcode check!(interpreter, SPEC::enabled(ISTANBUL)); gas!(interpreter, gas::BASE); - push!(interpreter, host.env().cfg.chain_id); + push!(interpreter, U256::from(host.env().cfg.chain_id)); } pub fn coinbase(interpreter: &mut Interpreter, host: &mut dyn Host) { diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index d9e41ba308..99e4cfb949 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -80,7 +80,7 @@ pub enum CreateScheme { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[non_exhaustive] pub struct CfgEnv { - pub chain_id: U256, + pub chain_id: u64, pub spec_id: SpecId, /// Bytecode that is created with CREATE/CREATE2 is by default analysed and jumptable is created. /// This is very beneficial for testing and speeds up execution of that bytecode if called multiple times. @@ -188,7 +188,7 @@ pub enum AnalysisKind { impl Default for CfgEnv { fn default() -> CfgEnv { CfgEnv { - chain_id: U256::from(1), + chain_id: 1, spec_id: SpecId::LATEST, perf_analyse_created_bytecodes: Default::default(), limit_contract_code_size: None, @@ -308,7 +308,7 @@ impl Env { // Check if the transaction's chain id is correct if let Some(tx_chain_id) = self.tx.chain_id { - if U256::from(tx_chain_id) != self.cfg.chain_id { + if tx_chain_id != self.cfg.chain_id { return Err(InvalidTransaction::InvalidChainId); } }