Skip to content

Sponsorship v2 - #135

Closed
Temasar1 wants to merge 5 commits into
mainfrom
sponsorship-v2
Closed

Temasar1 wants to merge 5 commits into
mainfrom
sponsorship-v2

Conversation

@Temasar1

@Temasar1 Temasar1 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

feat: SponsorshipV2

Drop-in replacement for Sponsorship with all known bugs fixed.

Bug fixes

  • Lexicographic guard: only selects sponsor UTxOs that sort after the static placeholder, preventing Plutus redeemer index shifts
  • Unit mismatch: utxoAmount consistently converted from ADA → lovelace (× 1,000,000)
  • DB reservation checks both isPending and isSpent (V1 only checked isSpent)
  • Revert on failure: finally block always releases in-process lock and reverts DB pending state

Concurrency

  • Module-level inProcessReserved Set closes same-process race condition between concurrent requests
  • Fisher-Yates shuffle for fair, non-repeating UTxO candidate iteration
  • Static wallet cache (SponsorshipV2.walletHandles) survives SDK re-instantiation between requests
  • Background consolidation guarded by per-wallet in-flight lock (no duplicate fires)

Divergence recovery

  • sweepDivergedState() auto-runs when viable pool is empty — resets UTxOs that are unspent on-chain but wrongly locked in DB (isPending=true or isSpent=true), preventing unnecessary consolidation
  • recoverStaleState(projectWalletId) public method for manual/admin recovery

@Temasar1 Temasar1 closed this Sep 15, 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