Skip to content

fix(platform-wallet): close asset-lock resume broadcast race#4016

Draft
thepastaclaw wants to merge 1 commit into
dashpay:v4.1-devfrom
thepastaclaw:fix/asset-lock-rejected-resume-race
Draft

fix(platform-wallet): close asset-lock resume broadcast race#4016
thepastaclaw wants to merge 1 commit into
dashpay:v4.1-devfrom
thepastaclaw:fix/asset-lock-rejected-resume-race

Conversation

@thepastaclaw

@thepastaclaw thepastaclaw commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to merged #3985 / tracker thepastaclaw/tracker#1742.

The later automated review on #3985 found a real read-before-broadcast race: resume_asset_lock could snapshot a Built row, then a concurrent create-path Rejected cleanup could delete the row and release the reservation before resume rebroadcasted the same tx.

This PR:

  • Advances Built rows to Broadcast before the resume-side broadcast so cleanup guards preserve the row/reservation while a broadcast may be in flight.
  • Rolls the row back to Built if the resume-side broadcast returns definite Rejected, so future resumes can try again instead of waiting forever on a tx that was not sent.
  • Adds regression coverage for the cleanup/resume race and for the resume-side Rejected rollback.

Validation:

  • cargo test -p platform-wallet --lib asset_lock::
  • cargo clippy -p platform-wallet --lib --tests
  • cargo build -p platform-wallet --tests
  • git show --check HEAD

Note: the race regression test was also verified to fail against the pre-fix implementation.

…t_lock

`resume_asset_lock`'s `Built` arm snapshotted the tracked row under a
read lock, dropped it, then awaited `broadcaster.broadcast(&tx)` before
advancing the status to `Broadcast`. During that window a concurrent
`create_funded_asset_lock_proof` that received `Rejected` from its own
broadcast would see the row still at `Built`, remove it, and release the
funding reservation — while resume was still handing the same
transaction to the network. Advance the row to `Broadcast` under the
write lock BEFORE calling `broadcast`, so `untrack_asset_lock`'s guard
fires (row + reservation preserved) or the advance itself fails and
resume returns before broadcasting.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

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

Run ID: 02f6cd6f-512f-4f4d-9672-69cc8cf19156

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added this to the v4.1.0 milestone Jul 6, 2026
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