Skip to content

EIP-7623 Increase calldata cost #2756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 4, 2025
Merged

EIP-7623 Increase calldata cost #2756

merged 15 commits into from
Jul 4, 2025

Conversation

anvacaru
Copy link
Contributor

@anvacaru anvacaru commented May 7, 2025

Summary of changes:

  • Added Ctxfloor function to calculate floor price for transactions
  • Modified #finalizeTx to take an additional parameter for floor gas cost
  • Updated intrinsic gas calculation with maxInt to use the higher of the standard calculation or the floor price
  • Implemented helper function #tokensInCalldata to count zero and non-zero bytes
  • Added required schedule constant and flag
  • Updated transaction processing in driver.md to pass floor calculation to finalizeTx

Reasoning:
There are three cells used for gas computation
<gas>: gas available for current message
<callGas>: gas explicitly allocated for a particular call or sub-call in the EVM.

  1. When #loadTx starts a transaction, it takes the gasLimit value of the transaction and subtracts the 21000 + (STANDARD_TOKEN_COST * tokens_in_calldata) + isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata)). The result is then stored in the <gas> cell.
  2. During the execution of the message, #deductGas will subtract from <gas> the cost of executing each opcode.
  3. In #finalizeTx(false) rules, the refund mechanism is executed, and then the block gas used cell is incremented by GLIMIT - GAVAIL, which accounts for both the initial gas subtracted in loadTx, execution costs, and any refunds available.

To apply the new 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
    )
)

The gasUsed value with the maximum value in between GLIMIT-GAVAIL and 21000 +TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata.

@anvacaru anvacaru merged commit 5a72ed6 into master Jul 4, 2025
12 checks passed
@anvacaru anvacaru deleted the eip-7623 branch July 4, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants