EIPs Explained

EIP-3651 · Final · Core · 2021-07-12

EIP-3651: Warm COINBASE

Makes the block producer's address (COINBASE) warm at the start of every transaction, so paying or checking it costs 100 gas instead of a 2,600-gas cold access.

What problem does it solve?

EIP-2929 split account access into cold (first touch in a transaction, 2,600 gas) and warm (already touched, 100 gas). A few addresses start warm automatically: the sender (tx.origin), the recipient (tx.to) and the precompiles.

The block producer's address, returned by the COINBASE opcode, was not on that list, even though clients always load it anyway because it receives the transaction fees. That made a popular pattern overpriced: searchers and bundlers often pay the block producer directly with ETH (block.coinbase.transfer(...)) as a conditional payment that only happens if the transaction succeeds. Paying 2,600 gas for that first touch pushed people toward alternatives such as paying in ERC-20 tokens, while the authors argue ETH should be the primary way to pay for transactions.

How it works

The whole specification is one line: at the start of transaction execution, the accessed_addresses set is initialised to also include the address returned by COINBASE (0x41).

Effects:

  • The first BALANCE, EXTCODESIZE, EXTCODEHASH, CALL etc. targeting block.coinbase in a transaction is charged the warm price (100) instead of the cold price (2,600).
  • Nothing else changes: the COINBASE opcode itself still costs the same, and no new opcode or transaction field is added.
  • It is consistent with the rationale for the existing warm set: these are the accounts a client must load anyway to validate and execute the transaction.

The change shipped in the Shanghai upgrade alongside EIP-3855 (PUSH0) and EIP-3860 (initcode limits).

Sample code

A conditional "tip the builder" pattern that benefits from the warm coinbase:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract PayBuilder {
    /// Runs some logic and only pays the block producer if it succeeds.
    function executeAndTip(address target, bytes calldata data) external payable {
        (bool ok, ) = target.call(data);
        require(ok, "inner call failed"); // revert => no tip is paid

        // Since EIP-3651 this first access to block.coinbase is warm (100 gas),
        // not cold (2,600 gas).
        (bool sent, ) = block.coinbase.call{value: msg.value}("");
        require(sent, "tip failed");
    }
}

Things to know

  • Status: Final, live on mainnet since Shanghai.
  • Savings are 2,500 gas only on the first access in a transaction; later accesses were already warm.
  • You no longer need to list block.coinbase in an EIP-2930 access list to get the warm price.
  • Since the Merge, COINBASE is the fee recipient chosen by the block proposer/builder, not a miner, but the logic of the EIP is unchanged.

#gas #evm #core #shanghai #coinbase

Details

Authors
William Morriss (@wjmelements)
Status
Final
Type
Standards Track / Core
Created
2021-07-12
Requires
Required by

Machine-readable: Markdown · JSON