Skip to content

Comments

feat!(txpool,payload): track intrinsic state gas in pool and exclude it from protocol gas limits (TIP-1016)#2740

Open
fgimenez wants to merge 6 commits intofgimenez/chain-789-handler-state-gasfrom
fgimenez/chain-790
Open

feat!(txpool,payload): track intrinsic state gas in pool and exclude it from protocol gas limits (TIP-1016)#2740
fgimenez wants to merge 6 commits intofgimenez/chain-789-handler-state-gasfrom
fgimenez/chain-790

Conversation

@fgimenez
Copy link
Member

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

  • Add intrinsic_state_gas: OnceLock<u64> to TempoPooledTransaction and expose set_intrinsic_state_gas(), intrinsic_state_gas(), and execution_gas_limit() (= gas_limit - state_gas).
  • During validation, compute and cache intrinsic state gas for T2+ transactions (both AA and non-AA paths). Sources include new-account creation, CREATE calls, 2D nonce keys, and EIP-7702 auth list entries.
  • For pre-T2, intrinsic_state_gas stays 0 so execution_gas_limit() == gas_limit().

Payload builder

  • Use execution_gas_limit() instead of gas_limit() for protocol limit checks (non_shared_gas_limit, general_gas_limit). State gas only counts against the user's gas_limit, not the block's execution gas capacity.

Test utilities

  • Fix TxBuilder to use self.chain_id instead of hardcoded 1 when building AA transactions.
  • Add chain_id() setter method.

@fgimenez fgimenez requested a review from rakita February 17, 2026 16:31
@fgimenez fgimenez added A-txpool S-breaking-stf This PR includes a breaking STF change labels Feb 17, 2026
@fgimenez fgimenez added the A-block-building Related to block building label Feb 17, 2026
@fgimenez fgimenez requested a review from mattsse as a code owner February 17, 2026 16:31
non_aa_state_gas += gas_params.tx_tip1000_auth_account_creation_state_gas();
}
}
transaction.set_intrinsic_state_gas(non_aa_state_gas);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state_gas+regular_gas <= gas_limit do we have this check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, added check ptal

Copy link
Contributor

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rakita upcoming revm now returns intrinsic gas as part of the evm output right? which means tracking this in the pooled tx is no longer necessary after we bump?

// 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use consistent terminology here, gas vs gaslimit is always needlessly confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, changed to tx_execution_gas_limit

Comment on lines 372 to 374
// 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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the builder, but I dont see a protocol check that's enforcing this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, added comment about it, lmk if that is enough

@github-actions
Copy link

github-actions bot commented Feb 18, 2026

⚠️ Changelog not found.

A changelog entry is required before merging. We've generated a suggested changelog based on your changes:

Preview
---
tempo-payload-builder: patch
tempo-revm: patch
tempo-transaction-pool: patch
---

Implemented TIP-1016 state gas handling across the payload builder, EVM handler, and transaction pool. State gas (storage creation gas) is now tracked separately from execution gas, cached on `TempoPooledTransaction` via `intrinsic_state_gas`, and validated against `gas_limit` for T2+ transactions without counting toward protocol block/execution gas caps.

Add changelog to commit this to your branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-block-building Related to block building A-txpool S-breaking-stf This PR includes a breaking STF change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants