Skip to content

EIP-7623 Increase calldata cost#2756

Merged
anvacaru merged 15 commits into
masterfrom
eip-7623
Jul 4, 2025
Merged

EIP-7623 Increase calldata cost#2756
anvacaru merged 15 commits into
masterfrom
eip-7623

Conversation

@anvacaru
Copy link
Copy Markdown
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 four 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.
<gasLimit>: the gas limit of the block
<gasUsed>: tracks the gas consumed up to the current point.
<txGasLimit>: maximum amount of gas allowed to be executed by the transaction.

  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 is updated with the maximum value between GLIMIT-GAVAIL and 21000 +TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata.

Comment thread kevm-pyk/src/kevm_pyk/kproj/evm-semantics/driver.md Outdated
@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