Skip to content

fix(core/txpool): key Osaka gas-cap discard off the reached pool head - #2521

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-osaka-head
Open

fix(core/txpool): key Osaka gas-cap discard off the reached pool head#2521
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-osaka-head

Conversation

@gzliudan

@gzliudan gzliudan commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Proposed changes

When a reorg reset crosses the Osaka fork boundary, the pool discards the transactions whose gas limit exceeds the cap. The check keyed off the heads the reset was asked to move between, which an aborted reset never reaches, so the pool could drop transactions still valid under the head it stays on. A coalesced pending reset is unreliable the other way: the reorg loop replaces only the new head, leaving a stale old head that makes the discard skip although the pool crossed the fork.

Key the discard off the heads the pool actually lands on instead, and run it after the reset so over-cap transactions the reset reinjects are covered too. This deliberately diverges from upstream geth, which keys the discard off the requested heads before the reset.

The Osaka tests need pools whose block gas limit exceeds the transaction gas cap, so setupPoolWithConfig delegates to a chain-injection variant and osakaTestEnv owns its chain, while a stateless chain wrapper aborts state access to simulate a reset that cannot complete. Tests cover the fork crossing, the aborted reset, the coalesced reset with a stale old head, and the announcements for discarded transactions queued through the reorg loop.

Compatibility

No consensus rules, block structure, wire protocol, or JSON-RPC behaviour change; only txpool fork-boundary housekeeping is affected. The divergence from upstream geth is confined to aborted or coalesced resets, where upstream's requested-head check drops transactions still valid under the actual head. A follow-up PR to upstream geth is planned, as the same defect exists there.

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

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

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 Plus

Run ID: afeaa27c-015a-437f-b4c5-21e67576e9b0

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

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes Osaka gas-cap transaction removal after aborted legacy txpool resets by checking the pool’s actual head transition.

Changes:

  • Discards over-cap transactions only after a successful Osaka boundary crossing.
  • Adds configurable test block gas limits.
  • Adds coverage for successful, aborted, recovered resets and announcements.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
core/txpool/legacypool/legacypool.go Keys Osaka cleanup to actual pool heads.
core/txpool/legacypool/legacypool_test.go Adds Osaka reset and announcement tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gzliudan
gzliudan force-pushed the fix-osaka-head branch 3 times, most recently from ead78e7 to e2235e2 Compare August 14, 2026 05:27
@gzliudan gzliudan changed the title fix(core/txpool/legacypool): key Osaka gas cap discard off the actual pool head fix(core/txpool): key Osaka gas-cap discard off the reached pool head Aug 14, 2026
@gzliudan
gzliudan force-pushed the fix-osaka-head branch 14 times, most recently from 79b771a to 7303a56 Compare August 16, 2026 11:20
When a reorg reset crosses the Osaka fork boundary, the pool discards
the transactions whose gas limit exceeds the cap. The check keyed off
the heads the reset was asked to move between, which an aborted reset
never reaches, so the pool could drop transactions still valid under
the head it stays on. A coalesced pending reset is unreliable the
other way: the reorg loop replaces only the new head, leaving a stale
old head that makes the discard skip although the pool crossed the
fork.

Key the discard off the heads the pool actually lands on instead, and
run it after the reset so over-cap transactions the reset reinjects
are covered too. This deliberately diverges from upstream geth, which
keys the discard off the requested heads before the reset.

The Osaka tests need pools whose block gas limit exceeds the
transaction gas cap, so setupPoolWithConfig delegates to a
chain-injection variant and osakaTestEnv owns its chain, while a
stateless chain wrapper aborts state access to simulate a reset that
cannot complete. Tests cover the fork crossing, the aborted reset,
the coalesced reset with a stale old head, and the announcements for
discarded transactions queued through the reorg loop.
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.

4 participants