Skip to content

fix(tx-submitter): recover discarded rollup txs via rebuild instead of self-transfer - #1054

Open
crazywriter1 wants to merge 2 commits into
morph-l2:mainfrom
crazywriter1:fix/rollup-discarded-tx-no-transfer-fallback
Open

fix(tx-submitter): recover discarded rollup txs via rebuild instead of self-transfer#1054
crazywriter1 wants to merge 2 commits into
morph-l2:mainfrom
crazywriter1:fix/rollup-discarded-tx-no-transfer-fallback

Conversation

@crazywriter1

@crazywriter1 crazywriter1 commented Aug 31, 2026

Copy link
Copy Markdown

Summary

When a pending commitBatch, commitState, or finalizeBatch transaction is dropped from the L1 mempool, handleDiscardedTx previously fell back to createReplacementTransferTx: a zero-value self-transfer with empty calldata that reuses the same nonce.
For rollup operations, that permanently abandons the batch/finalize attempt while consuming the nonce. The submitter then moves on as if recovery succeeded, but the batch may never land on L1.
This PR changes discarded-tx recovery for rollup methods to retry via fee-bump resubmit and commit rebuild (tryRecoverDiscardedRollupTxReSubmitTx(false)), which already handles commitBatchcommitState transitions through tryRebuildRollupCommitTx.
Non-rollup pending txs still use the self-transfer fallback to unstick the nonce.

Changes

  • Add constants.IsRollupMethod() for commitBatch, commitState, and finalizeBatch
  • Branch handleDiscardedTx on rollup vs non-rollup recovery paths
  • Add tryRecoverDiscardedRollupTx() helper
  • Add unit tests for IsRollupMethod and rollup discarded-tx recovery (no empty transfer fallback)

Test plan

  • go test ./tx-submitter/constants/... ./tx-submitter/services/... -run 'TestIsRollupMethod|TestHandleDiscardedTx'

Summary by CodeRabbit

  • Bug Fixes
    • Improved recovery for rollup transactions that fail during resubmission.
    • Preserved rollup transaction details and calldata instead of replacing them with empty transfer transactions.
    • Continued using transfer replacements for non-rollup transactions when recovery fails.

@crazywriter1
crazywriter1 requested a review from a team as a code owner August 31, 2026 14:13
@crazywriter1
crazywriter1 requested review from twcctop and removed request for a team August 31, 2026 14:13
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 51e6b381-f737-44cc-8f46-4cf38da7ff9a

📥 Commits

Reviewing files that changed from the base of the PR and between 5edbc69 and b617d08.

📒 Files selected for processing (4)
  • tx-submitter/constants/methods.go
  • tx-submitter/constants/methods_test.go
  • tx-submitter/services/rollup.go
  • tx-submitter/services/rollup_handle_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds rollup method classification and uses rollup-specific recovery when discarded transaction resubmission fails. Non-rollup transactions retain transfer replacement behavior. Tests cover classification and rollup calldata retention.

Changes

Rollup discard recovery

Layer / File(s) Summary
Rollup method classification
tx-submitter/constants/methods.go, tx-submitter/constants/methods_test.go
Adds IsRollupMethod for commitBatch, commitState, and finalizeBatch. Table-driven tests cover rollup and non-rollup methods.
Discarded transaction recovery flow
tx-submitter/services/rollup.go, tx-submitter/services/rollup_handle_test.go
Failed rollup resubmissions call tryRecoverDiscardedRollupTx and ReSubmitTx(false, tx). Non-rollup transactions use transfer replacement. The test verifies that rollup calldata remains tracked after recovery fails.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🔵 Low · up to fc8e7

The PR makes dropped rollup transactions retry their intended L1 operation instead of consuming the nonce with an empty transfer. It is mergeable with owner awareness that interrupted recovery or cleanup failures could leave stale pending transaction records and complicate later recovery.

Sequence Diagram(s)

sequenceDiagram
  participant handleDiscardedTx
  participant IsRollupMethod
  participant tryRecoverDiscardedRollupTx
  participant ReSubmitTx

  handleDiscardedTx->>IsRollupMethod: classify transaction method
  IsRollupMethod-->>handleDiscardedTx: rollup or non-rollup
  handleDiscardedTx->>tryRecoverDiscardedRollupTx: failed rollup resubmission
  tryRecoverDiscardedRollupTx->>ReSubmitTx: ReSubmitTx(false, tx)
  ReSubmitTx-->>tryRecoverDiscardedRollupTx: recovery result
Loading

Suggested reviewers: twcctop, dylancai9, segueii

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: recovering discarded rollup transactions through rebuilding instead of self-transfer replacement.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


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.

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.

1 participant