feat(core,txpool,miner,params): implement eip-7825 tx gas limit cap #31824 #32230#2210
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.MaxTxGasconstant (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
PendingFilterwithGasLimitCapand 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.
ec86bff to
ea7a823
Compare
There was a problem hiding this comment.
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.preCheckafter 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.
| 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 | ||
| } |
There was a problem hiding this comment.
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.
| if rules.IsOsaka && tx.Gas() > params.MaxTxGas { | ||
| return fmt.Errorf("%w: cap %d, tx %d", core.ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas()) | ||
| } |
There was a problem hiding this comment.
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.
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 applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that