Skip to content

fix(vault): prevent collect timing race in pending cosigns#241

Merged
calebjclark merged 1 commit intomainfrom
pr/fix-vault-collect-timing-race
Mar 9, 2026
Merged

fix(vault): prevent collect timing race in pending cosigns#241
calebjclark merged 1 commit intomainfrom
pr/fix-vault-collect-timing-race

Conversation

@blakebyrnes
Copy link
Contributor

Summary

  • prevent collect from using stale pending-cosign subscription updates
  • apply pending-cosign updates atomically as a full snapshot
  • keep collect due-date calculations aligned with the latest pending cosign state

Why

Out-of-order async subscription callbacks could finish late and overwrite newer pending-cosign data, which can leave collect timing stale.

Testing

  • yarn vitest --run src-vue/test/MyVault.integration.test.ts

Make pending cosign updates atomic and discard stale async callback results so older subscription emissions cannot overwrite newer collect state.

This keeps collect deadline and pending cosign state consistent during rapid chain updates.
Copilot AI review requested due to automatic review settings March 8, 2026 23:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a race where out-of-order async pending-cosign subscription updates could overwrite newer state and leave collect timing calculations stale.

Changes:

  • Switch pendingCosignUtxosById to store a full snapshot per UTXO (market value + optional due frame) and apply updates atomically with a sequence guard.
  • Update collect due-date calculation to consider both uncollected revenue frames and the earliest pending cosign due frame.
  • Update UI penalty/sum calculations to use the new marketValue field.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src-vue/screens-operations/vaulting-screen/Dashboard.vue Adjust pending-cosign penalty aggregation to sum marketValue from the new map value type.
src-vue/overlays-operations/VaultCollectOverlay.vue Adjust pending-cosign securitization/penalty sum to use marketValue.
src-vue/lib/MyVault.ts Implement pending-cosign snapshot + out-of-order protection, add due-frame awareness to collect timing, and cache/sort revenue frames for due-date calculation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@calebjclark calebjclark merged commit aee2f70 into main Mar 9, 2026
12 checks passed
@calebjclark calebjclark deleted the pr/fix-vault-collect-timing-race branch March 9, 2026 13:13
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.

3 participants