Skip to content

fix(txpool): revalidate fallback fee tokens on reorg - #8855

Open
DaniPopes wants to merge 7 commits into
mainfrom
dani/reorg-fallback-fee-token
Open

DaniPopes wants to merge 7 commits into
mainfrom
dani/reorg-fallback-fee-token

Conversation

@DaniPopes

@DaniPopes DaniPopes commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

On a reorg, maintain_tempo_pool read balances and events only from the new segment, whose baseline is the fork point rather than the orphaned state a cached fee-token choice was computed against. A transaction could keep a token that execution no longer picks, so eviction watched the wrong token. A reorg now also revalidates Fallback-cached transactions whose payer's fallback-token balance slot the orphaned segment wrote, and transactions without an explicit fee token whose payer set a user token in the orphaned segment.

Fixes CYCLOPS-5252.

A reorg diffed fallback-token balances only between the fork point and the new tip, so a transaction whose Fallback choice came from orphaned state kept a token execution no longer picks. Revalidate every Fallback-cached transaction on a reorg.
…chain

Revalidating every fallback transaction on a reorg also removed bystanders that nothing changed. Revalidate those whose fallback-token balance slot the orphaned segment wrote.
@DaniPopes
DaniPopes marked this pull request as ready for review November 3, 2026 22:08
@tempoxyz-bot

tempoxyz-bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

👁️ Cyclops Security Review

✅ Reviewed cbbf553 (latest) · Coverage: partial · no open findings · report
⚠️ Not checked: Reorg fee-token refresh selecting explicit-fee transactions or replacement-chain mined hashes: ruled out without reading the cited code at this commit
⚠️ Not checked: Immediate eth_sendRawTransactionSync error from the new Discarded event: ruled out without reading the cited code at this commit
ℹ️ Not verifiable from the source alone (needs running code or deployed state): The isolated reorg/listener regression test was not executed. Locked offline Cargo dependency resolution failed because the pinned evm2 checkout was not materialized in its cache. To verify it: Provid (2 more in the report)

@claude claude Bot 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.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🟣 crates/transaction-pool/src/maintain.rs — Pre-existing: after a reorg, pooled implicit-fee transactions can keep a Selected user token set only in orphaned blocks, so eviction tracks a token execution no longer uses. TempoPoolUpdates::from_chain(tip) reads UserTokenSet logs from the new segment only. The fallback fix at maintain.rs:575 checks fallback-cached transactions only. Fix: on Reorg, also add the orphaned chain's user_token_changes (e.g. TempoPoolUpdates::from_chain(&old)) to updates. Check 6 in tempo_pool.rs:508 then evicts those payers' implicit-fee transactions.

    Why this was flagged

    The trigger is a payer who calls setUserToken(X) in a block that is later orphaned. A transaction with no explicit fee token is validated against that orphaned state, and resolve_fee_token (crates/evm/src/fee_manager.rs:263-269) caches ResolvedFeeToken::Selected(X). On CanonStateNotification::Reorg, maintain.rs:547 builds updates only from tip, the new segment, which has no UserTokenSet log. So user_token_changes is empty and Check 6 at tempo_pool.rs:508-517 does not evict the transaction. The new fallback-revalidation filter at maintain.rs:564 needs is_fallback_fee_token(), so it skips Selected transactions. On the new chain user_tokens[fee_payer] is zero, so execution infers the token or uses the pathUSD/OUSD fallback, yet pool balance, pause, policy and AMM checks still watch X. The base branch behaves the same way. The PR fixes this orphaned-choice gap only for Fallback-cached transactions, the same defect class its description names.

    Verification: Pre-existing. On a reorg, maintain.rs:547 builds updates only from the new segment: let updates = TempoPoolUpdates::from_chain(tip);. The orphaned chain's UserTokenSet log never reaches user_token_changes, so Check 6 does not fire. The base commit has the same line. Consequence: eviction and balance checks watch token X, which execution no longer charges.

Comment thread crates/node/tests/it/pool.rs Resolved

@claude claude Bot 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.

Code review found no issues

No high-confidence issues detected in this change.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been marked stale due to 7 days of inactivity.

@github-actions github-actions Bot added the stale label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Closed due to inactivity. Reopen if still needed.

@github-actions github-actions Bot closed this Nov 14, 2026
@DaniPopes DaniPopes reopened this Nov 14, 2026

@claude claude Bot 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.

Code review found no issues

No high-confidence issues detected in this change.

…r token an orphaned block set

A user token set only by an orphaned block may have chosen the cached fee token of a transaction without an explicit one, and the new segment emits no event to show it.

@claude claude Bot 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.

Code review found no issues

No high-confidence issues detected in this change.

@github-actions github-actions Bot removed the stale label Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been marked stale due to 7 days of inactivity.

@github-actions github-actions Bot added the stale label Nov 26, 2026

@claude claude Bot 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.

Code review completed

Nothing new to post: everything this review found is already covered by existing comments on this pull request or didn't merit a separate one.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants