EIP-2045 · Stagnant · Core · 2019-05-17
EIP-2045: Particle gas costs for EVM opcodes
Proposed a sub-gas unit called the particle (1 gas = 10,000 particles) so cheap computational opcodes like ADD and DUP could be priced below 1 gas.
What problem does it solve?
Benchmarks of optimised EVM implementations suggested that pure computation (ADD, MUL, DUP, SWAP…) is overpriced compared with storage access (SLOAD, SSTORE). Making computation cheaper would let more transactions fit in a block without raising the gas limit, which would also speed up state growth.
But there is little room to cut: the minimum cost is 1 gas and these opcodes already cost 2–8 gas. You cannot make DUP 10× cheaper when it costs 3.
EIP-2045 introduces a finer unit so costs can go below 1 gas.
How it works
- A new counter
particlesUsedruns alongsidegasUsed. 1 gas = 10,000 particles (PARTICLES_PER_GAS). - Opcodes priced in particles add to
particlesUsed. Whenever it reaches 10,000, one gas is moved intogasUsedand the remainder stays in the particle counter. - Opcodes priced in whole gas work as before.
- Suggested new prices from the spec:
DUP/SWAP3 gas → 3,000 particles (0.3 gas);ADD/SUB3 gas → 6,000 particles;MUL5 gas → 5,000 particles.
Particles are an internal EVM detail. Transaction gas limits, block gas limits, headers and receipts all stay in whole gas, so users and most contract authors would not see them.
The spec notes a faster implementation could keep a single counter scaled by 10,000 and round up at the end, and that a power-of-two ratio (8192 or 16384) might be more efficient. The numbers were explicitly a draft.
Sample code
The core accounting loop, adapted from the spec:
PARTICLES_PER_GAS = 10_000
def charge(state, opcode):
if opcode.gas_fee:
state.gas_used += opcode.gas_fee
elif opcode.particle_fee:
state.particles_used += opcode.particle_fee
if state.particles_used >= PARTICLES_PER_GAS:
state.gas_used += 1
state.particles_used %= PARTICLES_PER_GAS
if state.gas_used > state.gas_limit:
raise OutOfGas()
# e.g. ten DUP1s at 3,000 particles each = 30,000 particles = 3 gas (vs 30 today)
Things to know
- Status is Stagnant; it was never scheduled for a hard fork. It would require one, as it changes gas accounting.
- The "particle" name comes from earlier Ewasm gas-costing work, but this proposal is about the EVM, not Ewasm.
- Instead of making computation cheaper, Ethereum mostly raised the cost of state access (EIP-1884, EIP-2929) to correct the same imbalance.
- EIP-2035 is the related, also stagnant, proposal on repricing
SLOAD/SSTOREfor stateless clients.