diff --git a/crates/interpreter/src/instructions/host.rs b/crates/interpreter/src/instructions/host.rs index cfc62c5814..5dea16ee1b 100644 --- a/crates/interpreter/src/instructions/host.rs +++ b/crates/interpreter/src/instructions/host.rs @@ -254,7 +254,14 @@ pub fn create( ); // EIP-3860: Limit and meter initcode if SPEC::enabled(SHANGHAI) { - if len > MAX_INITCODE_SIZE { + // Limit is set as double of max contract bytecode size + let max_initcode_size = host + .env() + .cfg + .limit_contract_code_size + .map(|limit| limit.saturating_mul(2)) + .unwrap_or(MAX_INITCODE_SIZE); + if len > max_initcode_size { interpreter.instruction_result = InstructionResult::CreateInitcodeSizeLimit; return; } diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index a1417ef225..36b252f771 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -407,7 +407,15 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB, // EIP-3860: Limit and meter initcode let initcode_cost = if SPEC::enabled(SHANGHAI) && self.data.env.tx.transact_to.is_create() { let initcode_len = self.data.env.tx.data.len(); - if initcode_len > MAX_INITCODE_SIZE { + // Limit is set as double of max contract bytecode size + let max_initcode_size = self + .data + .env + .cfg + .limit_contract_code_size + .map(|limit| limit.saturating_mul(2)) + .unwrap_or(MAX_INITCODE_SIZE); + if initcode_len > max_initcode_size { return Err(InvalidTransaction::CreateInitcodeSizeLimit.into()); } if crate::USE_GAS {