Skip to content

perf(core): reduce allocations for transaction comparison #31912#2214

Merged
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:reduce-txcomp-allocs
Mar 25, 2026
Merged

perf(core): reduce allocations for transaction comparison #31912#2214
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:reduce-txcomp-allocs

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

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 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 19, 2026 04:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 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: d8374272-48cb-4aaa-ae1c-1c04ad23b8b8

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

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.MaxTxGas and enforce it in txpool validation and state transition pre-checks when IsOsaka is active.
  • Extend txpool pending filters with GasLimitCap and apply it during mining pending selection.
  • Rework Transaction effective gas tip comparison paths to use uint256 internals 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.

@gzliudan gzliudan force-pushed the reduce-txcomp-allocs branch from e9f93ee to 7f39349 Compare March 19, 2026 05:46
@gzliudan gzliudan force-pushed the reduce-txcomp-allocs branch 2 times, most recently from cc8911c to 25a8a3c Compare March 19, 2026 07:22
@gzliudan gzliudan requested a review from Copilot March 19, 2026 07:22
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 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 in core/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.

@gzliudan gzliudan force-pushed the reduce-txcomp-allocs branch from 25a8a3c to 61d8bde Compare March 20, 2026 11:52
@gzliudan gzliudan force-pushed the reduce-txcomp-allocs branch from 61d8bde to 85c666f Compare March 24, 2026 11:20
@gzliudan gzliudan force-pushed the reduce-txcomp-allocs branch from 85c666f to db1297c Compare March 24, 2026 14:29
@AnilChinchawale AnilChinchawale merged commit 86e1c63 into XinFinOrg:dev-upgrade Mar 25, 2026
13 checks passed
@gzliudan gzliudan deleted the reduce-txcomp-allocs branch March 25, 2026 06:11
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