| title | PEEPanEIP-3855: PUSH0 Instruction | ||||
|---|---|---|---|---|---|
| type | slide | ||||
| slideOptions |
|
Hugo de la Cruz Romero -- github.com/hugo-dc
Alex Beregszaszi github.com/axic
--
A protocol research team focusing on the EVM. Website: ipsilon.xyz
- Status: Review
- Considered for inclusion in
Shanghai Network Upgrade
- Usage of constant value
0- Value of zero frequently used by many instructions expecting offsets as inputs.
- Examples:
- Opcodes dealing with offsets:
CALLDATACOPYCODECOPYEXTCODECOPY- etc.
CALL*: Setting zeros as return data parameters when the contract prefers usingRETURNDATA*to retreive the results.
- Opcodes dealing with offsets:
- New opcode
PUSH0with a cost of2gas (base). - It is introduced as the instruction number
0x5f.
| Hex | Name |
|---|---|
| ... | ... |
0x5f |
PUSH0 |
0x60 |
PUSH1 |
| ... | PUSHn |
0X7f |
PUSH32 |
- Reduce gas usage and contract code size:
PUSH1 00~60 00: 400 gas for deployment, 3 gas for runtime.PUSH0~5f: 200 gas for deployment, 2 gas for runtime.
- Reduce risk of contracts (mis)using instructions as an optimisation measure.
PCMSIZECALLDATASIZERETURNDATASIZECODESIZECALLVALUESELFBALANCE
- EIP-2733 (Withdrawn)
- If implemented, would have changed the behaviour of
RETURNDATASIZEsuch that it may not be guaranteed to be zero at the beginning of the call frame.
- If implemented, would have changed the behaviour of
- Traced transactions in two different nodes syncing mainnet:
- Geth Node 1: Syncing at block ~8M
- Geth Node 2: Syncing at block ~12M
- Result: Histogram of Opcode usage, with special column for
PUSH1 00(PUSH0):




0: solved byPUSH01: largely used in loops, could be solved byINC/DEC2: mostly used by old contracts to emulate shifts31and32: are mostly used by the ABI en/decoder in Solidity
INCto increase-by-one the top item,DECto decrease- Useful for loops, where this is done with
PUSH1 1 ADD - Pro: saves 2x200 gas for deployment, and at least costs half runtime
- Con: too much of a CISC direction


