-
Notifications
You must be signed in to change notification settings - Fork 97
Description
User Story
As a transaction sender (developer/user),
I want the relay to correctly validate transaction gas limits according to EIP-7623 and EIP-7702,
So that my transactions are not rejected when they should be valid, and invalid transactions are caught early before being submitted to the network.
Context
EIP-7623 is part of the Pectra upgrade and introduces a conditional floor price for calldata to reduce maximum block size. The formula changes from:
21000
+ STANDARD_TOKEN_COST * tokens_in_calldata
+ execution_gas_used
+ isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata))
To:
21000
+
max(
STANDARD_TOKEN_COST * tokens_in_calldata
+ isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata))
+ PER_EMPTY_ACCOUNT_COST * authorization list length,
TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
)
In relay currently:
constants.TX_BASE_COST + constants.TX_DATA_ZERO_COST * zeros + constants.ISTANBUL_TX_DATA_NON_ZERO_COST * nonZeros
Should change to:
constants.TX_BASE_COST +
Math.max(
constants.TX_DATA_ZERO_COST * zeros +
constants.ISTANBUL_TX_DATA_NON_ZERO_COST * nonZeros +
(isType4Transaction ? constants.PER_EMPTY_ACCOUNT_COST * authorizationListLength : 0),
constants.TOTAL_COST_FLOOR_PER_TOKEN * tokens
)
Technical Requirements
- Update
transactionIntrinsicGasCost()method in precheck validation - Add floor price constants:
TOTAL_COST_FLOOR_PER_TOKEN = 10 - Calculate tokens from calldata bytes
- Validate gas limit meets floor requirement
- Update error messages for clarity
- Add comprehensive test coverage
Acceptance Criteria
Given a transaction with calldata is submitted to the relay,
When the intrinsic gas cost is calculated,
Then the relay must apply the EIP-7623 floor pricing formula:
- Calculate
tokens = zero_bytes + 4 × non_zero_bytes - Validate
gasLimit >= 21000 + max(intrinsic_gas, 10 × tokens) - Reject transactions that don't meet the floor price requirement
Given a data-heavy transaction (minimal execution, large calldata),
When the gas limit only covers standard pricing (4/16 gas per byte),
Then the transaction must be rejected with an appropriate error message indicating insufficient gas for calldata floor price.
Given a regular transaction (significant execution, reasonable calldata),
When the gas limit covers standard intrinsic costs,
Then the transaction is validated successfully and the floor price does not apply.