Skip to content

fix(prediction-market): refresh storage TTLs on claim/refund read paths - #30

Open
fredericklamar342-prog wants to merge 2 commits into
SPulse-Org:mainfrom
fredericklamar342-prog:fix/issue-9-storage-ttl
Open

fix(prediction-market): refresh storage TTLs on claim/refund read paths#30
fredericklamar342-prog wants to merge 2 commits into
SPulse-Org:mainfrom
fredericklamar342-prog:fix/issue-9-storage-ttl

Conversation

@fredericklamar342-prog

@fredericklamar342-prog fredericklamar342-prog commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Market, bet, and bettor-index entries live in persistent storage with a ~1–2 year TTL that is bumped only at write time. A winner who claims late (or a cancelled-market bettor who refunds late) can find their BetEntry/Market records expired and deleted by the ledger — the payout or refund then becomes permanently unrecoverable and the funds stay stranded in the contract.

Root Cause

place_bet and create_market extend TTL on write, but the read paths that must observe those records (claim, cancel_refund) never re-extend them. There is no keeper/refresher, so long-lived markets silently lose their bookkeeping.

Implementation

  • claim: re-extends the TTL of the BetEntry and the Market record before performing the payout.
  • cancel_refund: re-extends the TTL of the BetEntry and the Market record before transferring the refund.

Security / Accounting Invariant

Any entry required to complete a user payout or refund is refreshed at read time, so user funds can never be locked behind an expired storage record on the claim/refund paths.

Tests

  • test_claim_rebumps_ttl_entries
  • test_cancel_refund_rebumps_ttl_entries

Both fast-forward deep into the TTL window and assert the entries' expiration ledger sequence increases after the operation.

Verification

Scope

Only prediction_market/src/lib.rs, prediction_market/src/tests.rs, and the two new test snapshot fixtures are changed. No other crate or issue is touched.

Issue

Closes #9

@Muyideen-js

Copy link
Copy Markdown
Contributor

@fredericklamar342-prog resolve conflict

Persistent entries (bet, market) are bumped only at write time. If a winner
or cancelled-market bettor claims late, the entries can expire and the payout
or refund becomes unrecoverable. claim() and cancel_refund() now re-extend
the TTL of the bet and market entries they depend on before paying out.
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.

[CRITICAL] Persistent storage TTLs can expire before claims/refunds — user funds permanently locked

2 participants