Skip to content

Defer transaction resubmission until scanning completes - #392

Draft
p0mvn wants to merge 3 commits into
mainfrom
fix/defer-resubmit-until-scan-complete
Draft

Defer transaction resubmission until scanning completes#392
p0mvn wants to merge 3 commits into
mainfrom
fix/defer-resubmit-until-scan-complete

Conversation

@p0mvn

@p0mvn p0mvn commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Defer startup and catch-up resubmit_pending_transactions until local scan work is drained, so already-mined wallet txs are not rebroadcast while mined_height is still NULL.
  • Harden further by moving the catch-up resubmit pass to after ensure_complete_scan_state, and refusing a tip that advanced on lightwalletd but never landed via update_chain_tip.

Authorship

Original investigation and fix by @ValarDragon in draft #386 (commits authored by Dev Ojha). This PR remakes that work on chainapsis/vizor-wallet and adds a small completion-path hardening follow-up.

Please prefer this PR over #386; the draft can be closed once this lands.

Why

During catch-up (especially with 96-block migration retention batches), Vizor refreshed tip and rebroadcast after each batch before scanning that tip. Resubmit eligibility only checks local mined_height IS NULL, so on-chain txs looked pending and were rebroadcast repeatedly — matching the live pending/Sending-now race analysis.

Tests

  • cd rust && cargo test --lib resubmit_: 16 passed

ValarDragon and others added 3 commits July 29, 2026 17:27
Move post-batch rebroadcast to after ensure_complete_scan_state, and
refuse a tip that advanced on lightwalletd but never landed in the DB.
Builds on ValarDragon's #386 deferral of resubmit while scan ranges remain.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

let fresh_for_gate = u32::try_from(final_tip_height).unwrap_or(u32::MAX);
match authoritative_resubmit_tip(final_tip_height, final_tip_height, fresh_for_gate) {

P2 Badge Re-check the chain tip before final resubmit

When the last post-batch tip refresh fails, or it sees a higher lightwalletd tip but update_chain_tip fails, current_tip_height and the DB remain at the old height and the loop can still complete with no pending ranges for that stale tip. This code then fabricates the “fresh” height from final_tip_height, so authoritative_resubmit_tip cannot reject the stale DB tip and resubmit_pending_transactions can rebroadcast a transaction that was already mined or expired in the unobserved new block. Fetch/update the tip here, or carry forward the unsafe refresh state and skip final resubmit unless the DB tip is authoritative.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@p0mvn
p0mvn marked this pull request as draft July 29, 2026 23:41
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.

2 participants