diff --git a/src/standard/config.rs b/src/standard/config.rs index 63300bab..ace618da 100644 --- a/src/standard/config.rs +++ b/src/standard/config.rs @@ -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 { @@ -150,6 +152,7 @@ impl Config { has_ext_code_hash: false, has_base_fee: false, has_push0: false, + eip_5656_enabled: false, } } @@ -203,6 +206,7 @@ impl Config { has_ext_code_hash: true, has_base_fee: false, has_push0: false, + eip_5656_enabled: false, } } @@ -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 @@ -299,6 +304,7 @@ impl Config { has_ext_code_hash: true, has_base_fee, has_push0, + eip_5656_enabled, } } } @@ -315,6 +321,7 @@ struct DerivedConfigInputs { disallow_executable_format: bool, warm_coinbase_address: bool, max_initcode_size: Option, + eip_5656_enabled: bool, } impl DerivedConfigInputs { @@ -329,6 +336,7 @@ impl DerivedConfigInputs { disallow_executable_format: false, warm_coinbase_address: false, max_initcode_size: None, + eip_5656_enabled: false, } } @@ -343,6 +351,7 @@ impl DerivedConfigInputs { disallow_executable_format: true, warm_coinbase_address: false, max_initcode_size: None, + eip_5656_enabled: false, } } @@ -357,6 +366,7 @@ impl DerivedConfigInputs { disallow_executable_format: true, warm_coinbase_address: false, max_initcode_size: None, + eip_5656_enabled: false, } } @@ -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, } } } diff --git a/src/standard/gasometer/mod.rs b/src/standard/gasometer/mod.rs index d3d189d2..377d3303 100644 --- a/src/standard/gasometer/mod.rs +++ b/src/standard/gasometer/mod.rs @@ -349,7 +349,10 @@ fn dynamic_opcode_cost( 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 {