feat!(txpool,payload): track intrinsic state gas in pool and exclude it from protocol gas limits (TIP-1016)#2740
Conversation
…it from protocol gas limits (TIP-1016)
| non_aa_state_gas += gas_params.tx_tip1000_auth_account_creation_state_gas(); | ||
| } | ||
| } | ||
| transaction.set_intrinsic_state_gas(non_aa_state_gas); |
There was a problem hiding this comment.
state_gas+regular_gas <= gas_limit do we have this check
There was a problem hiding this comment.
good catch, added check ptal
crates/payload/builder/src/lib.rs
Outdated
| // The remaining `shared_gas_limit` is reserved for validator subblocks and must not | ||
| // be consumed by proposer's pool transactions. | ||
| if cumulative_gas_used + pool_tx.gas_limit() > non_shared_gas_limit { | ||
| if cumulative_gas_used + tx_execution_gas > non_shared_gas_limit { |
There was a problem hiding this comment.
can we use consistent terminology here, gas vs gaslimit is always needlessly confusing
There was a problem hiding this comment.
yep, changed to tx_execution_gas_limit
crates/payload/builder/src/lib.rs
Outdated
| // TIP-1016: For T2+ transactions, use execution_gas_limit (gas_limit minus state gas) | ||
| // for protocol limit checks. State gas does NOT count against protocol limits. | ||
| // For pre-T2, execution_gas_limit() == gas_limit() (state gas is 0). |
There was a problem hiding this comment.
this is the builder, but I dont see a protocol check that's enforcing this
There was a problem hiding this comment.
indeed, updated comment
| /// Set during validation for T2+ transactions. The state gas portion does NOT count | ||
| /// against protocol limits (block/transaction execution gas caps), only against | ||
| /// the user's `gas_limit`. | ||
| intrinsic_state_gas: OnceLock<u64>, |
There was a problem hiding this comment.
isnt this problematic, because the intrinsic gas is hardfork specific, right?
so it's possible that a tx survives a hardfork boundary, making this incorrect fpr future blocks?
There was a problem hiding this comment.
good catch, added comment about it, lmk if that is enough
|
Closes CHAIN-790
Builds on top of #2714
Computes and caches intrinsic state gas during transaction validation so the payload builder can exclude it from protocol gas limits, ensuring storage creation gas only counts against the user's gas_limit.
Transaction pool
intrinsic_state_gas: OnceLock<u64>toTempoPooledTransactionand exposeset_intrinsic_state_gas(),intrinsic_state_gas(), andexecution_gas_limit()(=gas_limit - state_gas).intrinsic_state_gasstays 0 soexecution_gas_limit() == gas_limit().Payload builder
execution_gas_limit()instead ofgas_limit()for protocol limit checks (non_shared_gas_limit,general_gas_limit). State gas only counts against the user'sgas_limit, not the block's execution gas capacity.Test utilities
TxBuilderto useself.chain_idinstead of hardcoded1when building AA transactions.chain_id()setter method.