Skip to content

fix(internal/ethapi): skip tx gas limit check for calls #32641#2211

Merged
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:ethapi-tx-gaslimit
Mar 24, 2026
Merged

fix(internal/ethapi): skip tx gas limit check for calls #32641#2211
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:ethapi-tx-gaslimit

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

@gzliudan gzliudan commented Mar 18, 2026

Proposed changes

This disables the tx gaslimit cap for eth_call and related RPC operations.

eth_call, estimateGas, simulate and tracer paths construct Message values that do not represent a mempool transaction.

This change consolidates skip semantics by replacing SkipFromEOACheck with SkipTransactionChecks and enabling it for call-style execution paths.

Impact:

  • Avoids applying EIP-7825 tx gas-limit validation to non-transaction call contexts.
  • Preserves transaction-path validation for normal block processing and txpool flows.
  • Keeps behavior aligned across internal/ethapi, tracers, simulated backend, and state tests.

Ref: ethereum#32641

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Copilot AI review requested due to automatic review settings March 18, 2026 10:19
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 18, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 652c8666-6b52-4251-b77a-fd75247290c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI review requested due to automatic review settings March 24, 2026 07:43
@gzliudan gzliudan force-pushed the ethapi-tx-gaslimit branch from fe5a9a3 to f88c613 Compare March 24, 2026 07:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts call-style execution paths (e.g., eth_call, tracing, simulate, estimateGas) to bypass transaction-only validations—specifically the Osaka/EIP-7825 per-tx gas limit cap—by consolidating skip semantics into core.Message.SkipTransactionChecks. It also introduces and enforces a protocol-wide params.MaxTxGas cap for real transactions in state transition and txpool/miner flows.

Changes:

  • Replaces SkipFromEOACheck with SkipTransactionChecks and enables it for call-style Message construction paths.
  • Introduces params.MaxTxGas and enforces it post-Osaka in state transition, txpool validation, and miner pending selection.
  • Updates state processor tests and txpool behavior to reflect the new cap and fork activation behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/state_test_util.go Updates state-test Message construction to the new skip flag field.
params/protocol_params.go Defines MaxTxGas (EIP-7825 cap constant).
miner/worker.go Applies a pending-selection gas cap for mining after Osaka.
internal/ethapi/transaction_args.go Updates ToMessage signature and marks call Messages with SkipTransactionChecks=true.
internal/ethapi/simulate.go Updates simulate call path to new ToMessage signature.
internal/ethapi/api.go Simplifies call apply flow and updates ToMessage usage.
ethclient/simulated/backend.go Marks simulated eth_call messages as non-transaction (SkipTransactionChecks=true).
eth/tracers/api.go Updates trace call path to new ToMessage signature.
core/txpool/validation.go Enforces MaxTxGas in txpool validation after Osaka.
core/txpool/subpool.go Extends PendingFilter with GasLimitCap.
core/txpool/legacypool/legacypool.go Adds GasLimitCap filtering in Pending() and purges oversized-gas txs at Osaka transition.
core/token_validator.go Marks token-validator call messages as non-transaction (SkipTransactionChecks=true).
core/state_transition.go Introduces SkipTransactionChecks and enforces MaxTxGas for real tx messages post-Osaka.
core/state_processor_test.go Adds Osaka to test config and adds coverage for ErrGasLimitTooHigh.
core/error.go Adds ErrGasLimitTooHigh.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +559 to 572
if minTipBig != nil || filter.GasLimitCap != 0 {
for i, tx := range txs {
if !tx.IsSpecialTransaction() && tx.EffectiveGasTipIntCmp(minTipBig, baseFeeBig) < 0 {
txs = txs[:i]
break
if minTipBig != nil {
if !tx.IsSpecialTransaction() && tx.EffectiveGasTipIntCmp(minTipBig, baseFeeBig) < 0 {
txs = txs[:i]
break
}
}
if filter.GasLimitCap != 0 {
if tx.Gas() > filter.GasLimitCap {
txs = txs[:i]
break
}
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

PendingFilter gained GasLimitCap filtering, but there doesn't seem to be a unit test ensuring Pending() truncates per-account tx lists correctly when a tx exceeds the cap (and that later nonces are excluded as expected). Adding a focused test in legacypool_test.go would help prevent regressions in miner selection behavior around Osaka.

Copilot uses AI. Check for mistakes.
Comment on lines +1362 to +1375
if reset.newHead != nil && reset.oldHead != nil {
// Discard the transactions with the gas limit higher than the cap.
if pool.chainconfig.IsOsaka(reset.newHead.Number) && !pool.chainconfig.IsOsaka(reset.oldHead.Number) {
var hashes []common.Hash
pool.all.Range(func(hash common.Hash, tx *types.Transaction) bool {
if tx.Gas() > params.MaxTxGas {
hashes = append(hashes, hash)
}
return true
})
for _, hash := range hashes {
pool.removeTx(hash, true, true)
}
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The fork-transition pruning of txs with gas > params.MaxTxGas is consensus-critical for the Osaka activation path, but it isn't covered by a regression test. Consider adding a test that seeds the pool pre-Osaka with an oversized-gas tx, triggers a reset across the Osaka boundary, and asserts the tx is removed (and priced/pending state remains consistent).

Copilot uses AI. Check for mistakes.
// transaction-specific checks are skipped:
//
// - From is not verified to be an EOA
// - GasLimit is not checked against the protocol defined tx gaslimit
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Minor wording in the new comment: "tx gaslimit" reads like a typo; consider using "tx gas limit" for clarity.

Suggested change
// - GasLimit is not checked against the protocol defined tx gaslimit
// - GasLimit is not checked against the protocol defined tx gas limit

Copilot uses AI. Check for mistakes.
return fmt.Errorf("%w: code size %v, limit %v", core.ErrMaxInitCodeSizeExceeded, len(tx.Data()), params.MaxInitCodeSize)
}
if rules.IsOsaka && tx.Gas() > params.MaxTxGas {
return fmt.Errorf("%w: cap %d, tx %d", core.ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas())
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The new ErrGasLimitTooHigh message format here (": cap %d, tx %d") differs from the same error produced during block execution (state_transition uses "(cap: %d, tx: %d)"). Consider unifying the formatting so users see consistent error strings regardless of whether the tx is rejected by txpool validation vs block processing.

Suggested change
return fmt.Errorf("%w: cap %d, tx %d", core.ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas())
return fmt.Errorf("%w (cap: %d, tx: %d)", core.ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas())

Copilot uses AI. Check for mistakes.
eth_call, estimateGas, simulate and tracer paths construct Message values that do not represent a mempool transaction.

This change consolidates skip semantics by replacing SkipFromEOACheck with SkipTransactionChecks and enabling it for call-style execution paths.

Impact:
- Avoids applying EIP-7825 tx gas-limit validation to non-transaction call contexts.
- Preserves transaction-path validation for normal block processing and txpool flows.
- Keeps behavior aligned across internal/ethapi, tracers, simulated backend, and state tests.
@gzliudan gzliudan force-pushed the ethapi-tx-gaslimit branch from 6ee3878 to 26308c9 Compare March 24, 2026 14:30
@AnilChinchawale AnilChinchawale merged commit c32608a into XinFinOrg:dev-upgrade Mar 24, 2026
13 checks passed
@gzliudan gzliudan deleted the ethapi-tx-gaslimit branch March 24, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants