EIP-2045 EVM opcode particle gas costs (Particle gas costs for EVM opcodes)

No call decision · Fees & gas · EIP status Stagnant · created 2019-05-17

A proposal to split the gas cost of computation opcodes such as ADD and MUL in the EVM into units smaller than 1 gas, called 'particles', allowing them to be priced more precisely and lowered further than today.

Why it is needed

Today's EVM has a minimum gas unit of 1, so the prices of computation opcodes such as ADD and MUL have already been lowered to around 3 to 8 gas, leaving almost no room to lower them further. Benchmarks show that computation opcodes are priced relatively high compared to storage I/O opcodes such as SLOAD and SSTORE, so increasing transaction throughput requires lowering these prices further. One could also increase throughput by raising the block gas limit, but that causes state to grow faster, which in turn requires raising storage opcode prices as well, risking breaking the gas accounting or economic assumptions of already-deployed contracts. So, to keep storage prices unchanged while still lowering computation opcode prices more precisely, this proposal introduces 'particles', a unit smaller than 1 gas.

What changes

Today

After EIP-2045

Who is affected

In depth

Definition of the particle unit

This EIP adds a new counter called particlesUsed to the EVM, separate from the existing gasUsed. 1 gas is defined as 10000 particles (PARTICLES_PER_GAS), and particlesUsed only increases when an opcode cheaper than 1 gas, i.e. an opcode priced in particle units, is executed. Once particlesUsed exceeds the equivalent of 1 gas (10000), that amount is moved to gasUsed and the remainder stays in particlesUsed.

A more performant implementation approach

The Python example in the specification is meant to aid understanding, and a more efficient implementation is proposed that multiplies both opcode gas costs and gasLimit by 10000, uses only a single particlesUsed counter, and converts to gas at the end of execution via ceil(particlesUsed/PARTICLES_PER_GAS). It also notes that using a power-of-two ratio such as 8192 or 16384 instead of 10000 could be faster, and states that this specification is a draft that may change based on feedback.

Examples of per-opcode price changes

Examples are given showing DUP and SWAP dropping from 3 gas to 3000 particles (0.3 gas), ADD and SUB from 3 gas to 6000 particles (0.6 gas), and MUL from 5 gas to 5000 particles (0.5 gas). Based on benchmark analysis, other computation opcodes are explained to see similar price reductions.

Limited to internal EVM implementation details

The particle concept does not change user-facing systems such as the transaction gas limit or block gas limit. Only the internal EVM logic that charges gas per opcode execution is affected, while other areas such as the block header or transaction format remain unchanged. It explains that the term particle itself need not be exposed to ordinary users or most contract authors, and only EVM implementers and developers focused on gas optimization need to know about it.

Relationship to Ewasm

The term 'particle' first appeared in a proposal within Ewasm for counting low-cost wasm instructions in a way compatible with EVM gas costs. This EIP borrows only the name from that concept and proposes applying it to EVM opcodes as a new minimum gas unit, and it states explicitly that it is unrelated to Ewasm itself.

Motivation: price reductions instead of raising the block gas limit

There are two ways to increase a block's transaction throughput: raising the block gas limit or lowering transaction gas costs. Raising the limit alone accelerates state growth, which would require raising the price of storage opcodes such as SSTORE and CREATE by the same proportion, and citing EIP-2035, it notes that this could break the gas economy assumptions of already-deployed contracts or violate invariants during execution. The motivation is that lowering only the price of computation opcodes while leaving storage prices unchanged can increase throughput without these side effects.

Backwards Compatibility and Status

It is stated that this change is not backwards compatible and can only be activated via a hard fork. The Test Cases and Implementation sections are both left empty as TODO, and no call records or fork inclusion decisions have been confirmed. This EIP's status is Stagnant, and the source states that the PARTICLES_PER_GAS value of 10000 and the detailed opcode prices are still at the draft stage and may change based on future feedback.

Original EIP · ← EIPs