Skip to content

Commit

Permalink
add flag for eip-5656
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusrodri committed May 14, 2024
1 parent f304e83 commit 3f15f92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/standard/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ pub struct Config {
pub has_base_fee: bool,
/// Has PUSH0 opcode. See [EIP-3855](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3855.md)
pub has_push0: bool,
/// Enables MCOPY instruction. See [EIP-5656](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-5656.md)
pub eip_5656_enabled: bool,
}

impl Config {
Expand Down Expand Up @@ -150,6 +152,7 @@ impl Config {
has_ext_code_hash: false,
has_base_fee: false,
has_push0: false,
eip_5656_enabled: false,
}
}

Expand Down Expand Up @@ -203,6 +206,7 @@ impl Config {
has_ext_code_hash: true,
has_base_fee: false,
has_push0: false,
eip_5656_enabled: false,
}
}

Expand Down Expand Up @@ -237,6 +241,7 @@ impl Config {
disallow_executable_format,
warm_coinbase_address,
max_initcode_size,
eip_5656_enabled,
} = inputs;

// See https://eips.ethereum.org/EIPS/eip-2929
Expand Down Expand Up @@ -299,6 +304,7 @@ impl Config {
has_ext_code_hash: true,
has_base_fee,
has_push0,
eip_5656_enabled,
}
}
}
Expand All @@ -315,6 +321,7 @@ struct DerivedConfigInputs {
disallow_executable_format: bool,
warm_coinbase_address: bool,
max_initcode_size: Option<usize>,
eip_5656_enabled: bool,
}

impl DerivedConfigInputs {
Expand All @@ -329,6 +336,7 @@ impl DerivedConfigInputs {
disallow_executable_format: false,
warm_coinbase_address: false,
max_initcode_size: None,
eip_5656_enabled: false,
}
}

Expand All @@ -343,6 +351,7 @@ impl DerivedConfigInputs {
disallow_executable_format: true,
warm_coinbase_address: false,
max_initcode_size: None,
eip_5656_enabled: false,
}
}

Expand All @@ -357,6 +366,7 @@ impl DerivedConfigInputs {
disallow_executable_format: true,
warm_coinbase_address: false,
max_initcode_size: None,
eip_5656_enabled: false,
}
}

Expand All @@ -372,6 +382,7 @@ impl DerivedConfigInputs {
warm_coinbase_address: true,
// 2 * 24576 as per EIP-3860
max_initcode_size: Some(0xC000),
eip_5656_enabled: false,
}
}
}
5 changes: 4 additions & 1 deletion src/standard/gasometer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ fn dynamic_opcode_cost<H: RuntimeBackend>(
len: U256::from_big_endian(&stack.peek(3)?[..]),
}
}
Opcode::CALLDATACOPY | Opcode::CODECOPY | Opcode::MCOPY => GasCost::VeryLowCopy {
Opcode::MCOPY if config.eip_5656_enabled => GasCost::VeryLowCopy {
len: U256::from_big_endian(&stack.peek(2)?[..]),
},
Opcode::CALLDATACOPY | Opcode::CODECOPY => GasCost::VeryLowCopy {
len: U256::from_big_endian(&stack.peek(2)?[..]),
},
Opcode::EXP => GasCost::Exp {
Expand Down

0 comments on commit 3f15f92

Please sign in to comment.