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
9 changes: 8 additions & 1 deletion crates/interpreter/src/instructions/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,14 @@ pub fn create<const IS_CREATE2: bool, SPEC: Spec>(
);
// 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;
}
Expand Down
10 changes: 9 additions & 1 deletion crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down