Skip to content

feat(core,txpool,miner,params): implement eip-7825 tx gas limit cap #31824 #32230#2210

Merged
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:eip7825
Mar 24, 2026
Merged

feat(core,txpool,miner,params): implement eip-7825 tx gas limit cap #31824 #32230#2210
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:eip7825

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

Proposed changes

implement eip-7825 tx gas limit cap

Ref:

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 08:58
@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: e5dbbc0e-b72a-4f7c-aca4-6e8398d6a9f6

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.

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

Implements the EIP-7825 per-transaction gas limit cap (2^24) across core execution and transaction-pool/miner selection, gated on the Osaka fork rules.

Changes:

  • Add params.MaxTxGas constant (16,777,216) as the EIP-7825 cap.
  • Enforce the cap in txpool basic validation and in EVM state-transition pre-checks under Osaka.
  • Extend txpool PendingFilter with GasLimitCap and apply it in mining selection + legacy pool pending retrieval; add reorg-time pruning when crossing into Osaka.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
params/protocol_params.go Adds the MaxTxGas protocol constant for the EIP-7825 cap.
miner/worker.go Applies GasLimitCap when pulling pending txs for block assembly after Osaka.
core/txpool/validation.go Rejects txs exceeding MaxTxGas under Osaka at txpool entry.
core/txpool/subpool.go Extends PendingFilter with GasLimitCap for mining/announcement prefiltering.
core/txpool/legacypool/legacypool.go Filters pending tx lists by GasLimitCap and prunes oversized txs on Osaka transition.
core/state_transition.go Enforces the cap during transaction preCheck under Osaka (consensus processing path).
core/state_processor_test.go Updates tests for gas limit reached cases and adds coverage for ErrGasLimitTooHigh.
core/error.go Introduces ErrGasLimitTooHigh for EIP-7825 violations.

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

@gzliudan gzliudan force-pushed the eip7825 branch 2 times, most recently from ec86bff to ea7a823 Compare March 20, 2026 11:51
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

Implements EIP-7825’s per-transaction gas-limit cap (16,777,216) gated by the Osaka fork, enforcing it across transaction validation, mining selection, and state transition execution.

Changes:

  • Introduces params.MaxTxGas (1<<24) as the EIP-7825 cap.
  • Enforces the cap in txpool basic validation and in StateTransition.preCheck after Osaka.
  • Adds miner-side pending-tx filtering via PendingFilter.GasLimitCap, plus txpool cleanup of pre-Osaka oversized txs on fork transition.

Reviewed changes

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

Show a summary per file
File Description
params/protocol_params.go Adds MaxTxGas constant for EIP-7825.
miner/worker.go Caps mined pending tx selection by gas limit after Osaka.
core/txpool/validation.go Rejects txs exceeding MaxTxGas after Osaka.
core/txpool/subpool.go Extends PendingFilter with GasLimitCap.
core/txpool/legacypool/legacypool.go Applies GasLimitCap during Pending() and drops oversized txs on Osaka transition reorg.
core/state_transition.go Enforces EIP-7825 cap during state transition pre-checks.
core/state_processor_test.go Updates error tests and adds coverage for ErrGasLimitTooHigh.
core/error.go Introduces ErrGasLimitTooHigh.

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

Comment on lines +559 to +571
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 adds GasLimitCap, and LegacyPool.Pending now truncates per-account pending lists when a tx’s gas limit exceeds the cap. There are existing unit tests for MinTip/BaseFee filtering, but none exercising the new GasLimitCap behavior. Adding a targeted test (including the nonce-order truncation case) would help prevent regressions in miner selection logic.

Copilot uses AI. Check for mistakes.
Comment on lines +71 to +73
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 Osaka rule in ValidateTransaction rejects txs with Gas() above params.MaxTxGas, but there’s no direct unit test covering this validation path (either for ValidateTransaction itself or via pool insertion under an Osaka-enabled config). Please add a test that asserts the correct error wrapping/message for a tx with Gas = MaxTxGas+1 once Osaka is active.

Copilot uses AI. Check for mistakes.
@AnilChinchawale AnilChinchawale merged commit b9a255a into XinFinOrg:dev-upgrade Mar 24, 2026
17 checks passed
@gzliudan gzliudan deleted the eip7825 branch March 24, 2026 10:55
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