fix(platform-wallet): close asset-lock resume broadcast race#4016
Draft
thepastaclaw wants to merge 1 commit into
Draft
fix(platform-wallet): close asset-lock resume broadcast race#4016thepastaclaw wants to merge 1 commit into
thepastaclaw wants to merge 1 commit into
Conversation
…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>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to merged #3985 / tracker thepastaclaw/tracker#1742.
The later automated review on #3985 found a real read-before-broadcast race:
resume_asset_lockcould 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:
Validation:
cargo test -p platform-wallet --lib asset_lock::cargo clippy -p platform-wallet --lib --testscargo build -p platform-wallet --testsgit show --check HEADNote: the race regression test was also verified to fail against the pre-fix implementation.