EIP-3855: Add PUSH0 OpCode #4963
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
EIP-3855 introduces a new Ethereum Virtual Machine (EVM) instruction called
PUSH0that pushes the value zero onto the stack. Before this improvement, pushing zero required usingPUSH1 0, which takes 2 bytes of bytecode and costs 3 gas at runtime. The newPUSH0opcode (represented by0x5f) accomplishes the same task using only 1 byte and costs just 2 gas, making smart contracts more efficient and cheaper to deploy and execute.The motivation for this change comes from how frequently zero values are used in smart contracts. Many EVM operations need zero as an input parameter—for example, when making contract calls where you want to specify zero offsets or when using return data functions. Previously, every time a contract needed to push zero onto the stack, it had to use the more expensive
PUSH1 0instruction. WithPUSH0, developers can write more gas-efficient code, and the smaller bytecode size also reduces deployment costs.This PR implements EIP-3855 and can be activated at a specific epoch through the
EIP3855Epochconfiguration parameter. When enabled, the EVM interpreter includes thePUSH0opcode in its jump table, allowing smart contracts to use this more efficient instruction. This is part of Harmony's ongoing effort to align with Ethereum improvements while maintaining its own epoch-based upgrade mechanism.