KIP 223: Transaction data gas cost reduction
Author | Lake, Ollie, Sawyer |
---|---|
Discussions-To | https://github.com/kaiachain/kips/issues/22 |
Status | Draft |
Type | Core |
Created | 2024-10-18 |
Updated | 2025-03-05 |
Abstract
Adjust Kaia’s transaction data (calldata) gas cost model to align with EIP-7623, introducing a floor cost for calldata and thereby skipping EIP-2028. By doing so, Kaia can achieve better compatibility with Ethereum’s post-Prague ecosystem and toolchain.
Motivation
After Ethereum’s Prague hard fork, which includes EIP-7623, many Ethereum-oriented tools and SDKs assume the updated calldata pricing model. If Kaia maintained its previous gas cost rules, developers using Ethereum SDKs or tools (e.g. ERC-4337 bundlers) would encounter mismatches in gas estimates and transaction validity. Adopting the EIP-7623 calldata pricing model in Kaia eliminates these incompatibilities, allowing seamless use of Ethereum ecosystem software on Kaia.
Specification
Parameter | Value |
---|---|
STANDARD_TOKEN_COST |
4 |
TOTAL_COST_FLOOR_PER_TOKEN |
10 |
Let tokens_in_calldata = zero_bytes_in_calldata + nonzero_bytes_in_calldata * 4
.
Let isContractCreation
be a boolean indicating the respective event.
Let execution_gas_used
be the gas used for EVM execution with the gas refund subtracted.
Let INITCODE_WORD_COST
be 2 as defined in EIP-3860.
Let tx_gas
be the base intrinsic gas for the transaction type (default 21000, additional 10000 for fee-delegated transactions or 15000 for fee-delegation with ratio transactions).
Let sig_validate_gas
be the gas used for signature validation (gas used to verify signatures for fee-delegated transactions or AccountKey transactions).
tx.gasUsed = (
tx_gas
+ sig_validate_gas
+ 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 transaction must pay at minimum TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
gas for the calldata portion via the floor cost. If the standard cost (including execution) is higher than the floor-based cost, that higher cost applies; otherwise, the floor cost takes precedence, ensuring data-heavy, low-compute transactions pay more.
Rationale
Because Kaia supports multiple customized transaction formats (e.g., fee-delegated transactions), intrinsic gas is split into tx_gas
and sig_validate_gas
. This ensures that gas used for the transaction type and signature validation is calculated separately. As a result, tx_gas
and sig_validate_gas
is outside of the maximum function, so that we can apply the floor cost only to the calldata portion.
Other than that, we follow the EIP-7623 spec for the calldata gas cost calculation. The numbers in EIP-7623 were chosen to reduce the maximum block size while minimizing the impact on regular transactions. However, Kaia does not impose a block gas limit, so that particular rationale does not apply here. Instead, we adopt these parameters primarily for compatibility with Ethereum.
Backward Compatibility
The calldata gas repricing is backwards incompatible since the hardfork.
SDKs and Wallets will be able to continue their operations with no change as they usually depend on the estimated gas cost from the eth_estimateGas
API.
References
Copyright
Copyright and related rights waived via CC0.