Skip to content

fix: replace speculative resolve() with mark_voted() to prevent dupli…#344

Open
enjoyandlove wants to merge 1 commit into
entrius:testfrom
enjoyandlove:fix/duplicate-swap-votes
Open

fix: replace speculative resolve() with mark_voted() to prevent dupli…#344
enjoyandlove wants to merge 1 commit into
entrius:testfrom
enjoyandlove:fix/duplicate-swap-votes

Conversation

@enjoyandlove
Copy link
Copy Markdown

Summary

Closes #343

  • tracker.resolve() was being called speculatively in the forward loop after a confirm or timeout vote succeeded. resolve() removes the swap from voted_ids, destroying the duplicate-vote guard until event_watcher fires.
  • Both call sites (line 408 confirm_miner_fulfillments, line 520 enforce_swap_timeouts) are replaced with tracker.mark_voted(), which records the vote without dropping the guard.
  • event_watcher continues to call tracker.resolve() authoritatively on SwapCompleted/SwapTimedOut chain events — that ownership boundary is now respected.

Why

Between "our vote lands" and "event_watcher observes the finality event" (~12 s per forward step, typically several steps of lag), is_voted() was returning False and a redundant extrinsic was submitted on every step. This burned TAO fees on every affected swap and flooded logs with "already voted" rejections, masking legitimate failures.

Test plan

  • Existing tests/test_swap_tracker.py mark_voted / is_voted / prune_stale_voted_ids round-trip tests pass
  • uv run pytest tests/
  • Verify that after a successful confirm_swap or timeout_swap the swap is not re-submitted on the next forward step before event_watcher fires

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 19, 2026
@enjoyandlove
Copy link
Copy Markdown
Author

Hi, @anderdc
I have just submitted this PR.When you have a moment, could you please review it?
Thank you for your time.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Duplicate swap votes on every confirmed/timed-out swap

1 participant