Skip to content

Compute gas with uint32 #1719

Open
Open

Description

@chfast

Every gas counter in evmone is int64_t, but all per-transaction gas quantities fit in 32 bits.

EIP-7825 caps a transaction's gas limit at TX_MAX_GAS_LIMIT = 2^24 (MAX_TX_GAS_LIMIT, test/state/transaction.hpp), and block gas limits are far below 2^32. A pending EIP-8037 change would additionally cap tx.gas itself at 2^32-1, so the whole two-dimensional budget stays inside an unsigned 32-bit integer.

Candidates:

  • gas_left threaded through the interpreter and Result / TermResult
  • StateGas::left and StateGas::spilled (lib/evmone/state_gas.hpp)
  • evmc_message::gas, evmc_message::state_gas
  • evmc_result::gas_left, gas_refund, state_gas_left, state_gas_spilled

Two things to settle first:

  • The interpreter relies on gas going negative ((gas_left -= cost) < 0). An unsigned counter needs a borrow-based check instead, e.g. __builtin_usub_overflow.
  • The evmc_* fields are public ABI, so changing them is a breaking change.

Activity

  1. added
    optimization
    on Sep 16, 2026
  2. added a commit that references this issue on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    optimization

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions