EIP-3860
EIP-3860 proposes changes to the maximum size limit of initcode in Ethereum, as well as the introduction of a gas charge for every 32-byte chunk of initcode, as part of the Shanghai hard fork of the Shapella Upgrade. This proposal was made to ensure that the initcode is fairly charged, with costs being proportional to the length of the initcode.
Overview
On July 16th, 2021, EIP-3860 was created to update the initcode in order to minimize risk. The lack of a limit on the size of initcode has caused lengthy discussions for some EVM proposals, influencing the design, or even causing a delay or cancellation of a feature. By introducing a limit, the proposal aims to simplify EVM engines by setting explicit limits, such as code size, code offsets, and jump offsets, to fit 16 bits. [1][3]
Initcode is the code that is executed during the creation of a new contract, and the current maximum value for initcode was set to 24576 bytes in EIP-170. However, EIP-3860 proposes that the new maximum value of initcode should be increased to 49152 bytes, which is twice the current maximum size. This change would double the maximum contract size and enable contracts to have more sophisticated functionality. [1]
Details
The gas cost per byte of initcode will add 0.0625 gas, and the cost of deploying gas to the contract will also increase slightly. Additionally, there is an extra gas cost of 2 for every 32-byte chunk of initcode, which is meant to represent the cost of jumpdest-analysis during contract creation. [2]
The EIP-3860 proposal sets rules for creating new programs on the Ethereum blockchain. Two important rules are INITCODE_WORD_COST, which is a cost of 2, and MAX_INITCODE_SIZE, which is twice the size of the maximum code size allowed. If a transaction's program code is larger than MAX_INITCODE_SIZE, the transaction is invalid. Also, the cost of the program code is included in the total cost of the transaction, and if the transaction doesn't have enough gas to cover the cost, it's invalid. For the CREATE and CREATE2 instructions, there's an extra gas cost that's deducted before the program code is executed. The cost constant for INITCODE_WORD_COST is determined by performance benchmarks, with a baseline of KECCAK256 hashing in geth 1.10.9. [2]
Authors
- Martin Holst Swende
- Paweł Bylica
- Alex Beregszaszi
- Andrei Maiboroda