EIP-7623: Increase calldata cost

Anmol DhimanAnmol Dhiman
3 min read

Why this EIP neeeded?

  • The current calldata cost allows a maximum block size of 7.15 MB, while the average block size remains around 100 KB.
  • The goal is to reduce the maximum calldata usage by increasing its cost.
  • This primarily impacts data-centric applications that rely on storing large amounts of data on-chain.
  • Raising calldata costs makes heavy calldata transactions more expensive, discouraging their use and creating room for more blobs and regular transactions, which could eventually lead to an increase in the block gas limit.
  • Since the block gas limit hasn’t increased since EIP-1559 and calldata costs have remained unchanged since EIP-2028, EIP-4844 introduces blobs as a more efficient alternative for data availability.
  • Because calldata remains permanently stored on-chain, it should be deprioritized in favor of blobs, which provide a more scalable solution.

EIP Proposal and Functioning

Introducing the Following Fields

ParameterValue
STANDARD_TOKEN_COST4
TOTAL_COST_FLOOR_PER_TOKEN10

Current Gas Calculation Formula

The total gas usage for a transaction is currently determined by:

tx.gasUsed = (
    21000
    + STANDARD_TOKEN_COST * tokens_in_calldata
    + execution_gas_used
    + isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata))
)
  • Calldata Cost:

    • 0x00 bytes → 4 gas
    • 0x01 - 0xFF bytes → 16 gas
  • Where:

    • 21000 → Base gas cost for updating the sender's nonce.
    • tokens_in_calldata → zero_bytes_in_calldata + (nonzero_bytes_in_calldata * 4).
    • isContractCreation → Boolean indicating if a contract is being created.
    • execution_gas_used → Gas required for executing opcodes in the transaction.
    • INITCODE_WORD_COST → 2 gas (as per EIP-3860).

Updated Gas Calculation Formula

tx.gasUsed = (
    21000
    +
    max(
        STANDARD_TOKEN_COST * tokens_in_calldata
        + execution_gas_used
        + isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata)),
        TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
    )
)

Effects

  • The increase in calldata costs reduces the maximum possible block size, making room for more transactions and blobs introduced in EIP-4844.
  • Data-centric applications relying heavily on calldata for on-chain storage will face higher costs.
  • Encourages the use of blobs instead of calldata for data availability, aligning with Ethereum's scalability goals.

Key Changes

Before this EIP:

  • Zero bytes (0x00) cost4 gas
  • Non-zero bytes (0x01 - 0xFF) cost16 gas

After this EIP:

  • Zero bytes (0x00) cost10 gas
  • Non-zero bytes (0x01 - 0xFF) cost40 gas

Implementation Considerations

  • Wallets & node software must update their gas estimation logic to incorporate TOTAL_COST_FLOOR_PER_TOKEN.

Risks & Mitigations

Risks

  1. Wallets and node operators must update their gas estimation logic; failure to do so may result in transaction failures and unnecessary gas expenditure.

Mitigation

  1. Implement the updated gas estimation formula in the codebase.
0
Subscribe to my newsletter

Read articles from Anmol Dhiman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Anmol Dhiman
Anmol Dhiman

Prev - @kleros || ETHBangkok'24 🏆 || ETHIndia'23 🏆 || SSIP AKAMH'22 🏆 || Blockchain Security Researcher