Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bins/revme/src/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion crates/interpreter/src/instructions/host_env.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use revm_primitives::U256;

use crate::{
gas, interpreter::Interpreter, primitives::Spec, primitives::SpecId::*, Host, InstructionResult,
};
Expand All @@ -6,7 +8,7 @@ pub fn chainid<SPEC: Spec>(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) {
Expand Down
6 changes: 3 additions & 3 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
Expand Down