perf(core): reduce allocations for transaction comparison #31912#2214
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
This PR aims to reduce allocations in transaction effective-tip comparisons by switching internal comparison logic to uint256, and also introduces enforcement of the EIP-7825 transaction gas limit cap (MaxTxGas) from the Osaka fork across tx validation, mining selection, and state transition checks.
Changes:
- Add
params.MaxTxGasand enforce it in txpool validation and state transition pre-checks whenIsOsakais active. - Extend txpool pending filters with
GasLimitCapand apply it during mining pending selection. - Rework
Transactioneffective gas tip comparison paths to useuint256internals and add a benchmark.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| params/protocol_params.go | Introduces MaxTxGas constant for EIP-7825 cap. |
| miner/worker.go | Applies GasLimitCap to pending tx selection when Osaka is active. |
| ethclient/simulated/backend.go | Switches fee history tip calculation to EffectiveGasTip API. |
| core/types/transaction.go | Refactors effective tip calculation/comparison to use uint256. |
| core/types/transaction_test.go | Adds benchmark for effective-tip comparison. |
| core/txpool/validation.go | Rejects txs exceeding MaxTxGas when Osaka is active. |
| core/txpool/subpool.go | Adds GasLimitCap to PendingFilter. |
| core/txpool/legacypool/list.go | Updates priced heap baseFee type to *uint256.Int and converts in setter. |
| core/txpool/legacypool/legacypool.go | Enforces MinTip via new compare path and filters/removes over-cap txs at Osaka activation. |
| core/state_transition.go | Enforces MaxTxGas during state transition pre-check under Osaka. |
| core/state_processor_test.go | Updates test config/expectations and adds coverage for gas-cap error. |
| core/error.go | Adds ErrGasLimitTooHigh error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e9f93ee to
7f39349
Compare
cc8911c to
25a8a3c
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce allocations in transaction tip comparisons (used in txpool ordering) by switching effective-tip comparison logic to uint256, while also introducing an Osaka-gated EIP-7825 per-transaction gas limit cap (params.MaxTxGas) enforced across tx validation, mining selection, and state transition.
Changes:
- Optimize effective gas tip comparisons by introducing
uint256-based calculation/comparison paths incore/types/transaction.go. - Add Osaka-gated EIP-7825 max per-tx gas cap (
params.MaxTxGas) and enforce it in state transition, txpool validation, and miner pending-tx filtering. - Extend/adjust tests and benchmarks to cover the new comparison semantics, base-fee conversion overflow behavior, and Osaka gas-cap enforcement.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| params/protocol_params.go | Adds MaxTxGas protocol parameter (EIP-7825 cap). |
| miner/worker.go | Applies Osaka-gated PendingFilter.GasLimitCap when fetching pending txs for mining. |
| core/types/transaction.go | Introduces uint256-based effective tip calculation/comparison; adds overflow error. |
| core/types/transaction_test.go | Adds benchmark + tests for EffectiveGasTip*Cmp semantics and internal tip calculation behavior. |
| core/txpool/validation.go | Rejects txs exceeding MaxTxGas when Osaka rules are active. |
| core/txpool/subpool.go | Extends PendingFilter with GasLimitCap. |
| core/txpool/legacypool/list.go | Switches priced-list baseFee storage to *uint256.Int and converts baseFee on update. |
| core/txpool/legacypool/list_test.go | Adds tests for baseFee conversion overflow / nil handling. |
| core/txpool/legacypool/legacypool.go | Applies MinTip filtering using uint256 directly; adds gas-cap filtering and purges over-cap txs on Osaka transition. |
| core/state_transition.go | Enforces Osaka-gated EIP-7825 per-tx gas cap in StateTransition.preCheck. |
| core/state_processor_test.go | Updates fork config + expected errors/hashes; adds ErrGasLimitTooHigh test case. |
| core/error.go | Adds ErrGasLimitTooHigh error constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
25a8a3c to
61d8bde
Compare
61d8bde to
85c666f
Compare
85c666f to
db1297c
Compare
Proposed changes
Ref: ethereum#31912
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