Skip to content

Implement calldata cost floor (EIP-7623) #79

@mw2000

Description

@mw2000

Summary

Implement the calldata cost floor pricing from EIP-7623 (Prague). Transactions with high calldata relative to execution must pay a minimum "floor" cost, discouraging data-heavy transactions that don't do proportional computation.

Specification

Floor Cost Calculation

STANDARD_TOKEN_COST = 4   (per calldata byte — same as today for zero bytes)
FLOOR_TOKEN_COST = 10     (per calldata byte for floor calculation)

tokens = zero_bytes * 4 + nonzero_bytes * 16   (standard intrinsic cost component)
floor_tokens = total_bytes * FLOOR_TOKEN_COST   (floor cost component)

floor_gas = 21000 + floor_tokens + access_list_cost
standard_gas = 21000 + tokens + access_list_cost

intrinsic_gas = max(standard_gas, floor_gas)

In practice: if a transaction has a lot of calldata but uses little execution gas, it pays the floor price (10 gas per byte) instead of the standard price (4/16 per zero/non-zero byte).

Effective Gas Calculation

At end of transaction:

if execution_gas_used < floor_gas:
    effective_gas = floor_gas  # Pay the floor
else:
    effective_gas = execution_gas_used  # Pay standard

Implementation Guide

  1. Update EEVM.Transaction.IntrinsicGas to calculate both standard and floor costs
  2. Add floor comparison at transaction end — the actual gas charged is max(standard_execution_gas, floor_gas)
  3. Gate behind hardfork config — only active for Prague+
  4. Tests: calldata-heavy tx pays floor, computation-heavy tx pays standard, edge cases at boundary

Acceptance Criteria

  • Floor cost calculated correctly: 21000 + total_bytes * 10
  • Transactions pay max(standard_gas, floor_gas)
  • Calldata-heavy transactions pay more under floor pricing
  • Computation-heavy transactions unaffected
  • Gated to Prague+ hardfork
  • Tests pass

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    eipEIP specification implementationgasGas metering and cost rulespraguePrague/Pectra hardfork features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions