EIP-5027
Removes the limit on smart contract code size with new, dynamic gas metering.
In 2016, via EIP-170, Ethereum imposed
a 24,576
-byte limit on smart contract code size (referenced as MAX_CODE_SIZE
and computed as 0x6000: 2**14 + 2**13
).
The rationale to support this decision was primarily fueled by preventing Denial-of-service (DoS) attacks introduced by increasingly large and complex smart contracts.
Since then, smart contract applications have become only increasingly complex in nature, with developers adopting complex patterns to circumnavigate code size limits, with countless developer-hours being wasted on needless optimization.
EIP-5027
removes the limit on contract code size altogether, instead charging an
escalating 2600
gas to load each incremental 24,576
-byte blocks of contract
code.
EIP Specification
Constant | Value |
---|---|
FORK_BLKNUM | 0 |
CODE_SIZE_UNIT | 24576 |
COLD_ACCOUNT_CODE_ACCESS_COST_PER_UNIT | 2600 |
CREATE_DATA_GAS | 200 |
If block.number >= FORK_BLKNUM
, the contract creation initialization can
return data with any length, but the contract-related opcodes will take extra
gas as defined below:
-
For
CODESIZE/CODECOPY/EXTCODESIZE/EXTCODEHASH
, the gas is unchanged. -
For
CREATE/CREATE2
, if the newly created contract size >CODE_SIZE_UNIT
, the opcodes will take extra write gas as(CODE_SIZE - CODE_SIZE_UNIT) * CREATE_DATA_GAS
. -
For
EXTCODECOPY/CALL/CALLCODE/DELEGATECALL/STATICCALL
, if the contract code size >CODE_SIZE_UNIT
, then the opcodes will take extra gas as(CODE_SIZE - 1) // CODE_SIZE_UNIT * COLD_ACCOUNT_CODE_ACCESS_COST_PER_UNIT
If the contract is not in accessed_code_in_addresses
or 0
if the contract is
in accessed_code_in_addresses
, where //
is the integer divide operator, and
accessed_code_in_addresses: Set[Address]
is a transaction-context-wide set
similar to access_addresses
and accessed_storage_keys
.
When transaction execution begins, accessed_code_in_addresses
will include
tx.sender
, tx.to
, and all precompiles.
When CREATE/CREATE2/EXTCODECOPY/CALL/CALLCODE/DELEGATECALL/STATICCALL
is
called, immediately add the address to accessed_code_in_addresses
.