fix(prediction-market): refresh storage TTLs on claim/refund read paths - #30
Open
fredericklamar342-prog wants to merge 2 commits into
Open
Conversation
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.
fredericklamar342-prog
force-pushed
the
fix/issue-9-storage-ttl
branch
from
August 17, 2026 00:17
fd56196 to
fcb01e4
Compare
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.
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/Marketrecords 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_betandcreate_marketextend 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 theBetEntryand theMarketrecord before performing the payout.cancel_refund: re-extends the TTL of theBetEntryand theMarketrecord 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_entriestest_cancel_refund_rebumps_ttl_entriesBoth fast-forward deep into the TTL window and assert the entries' expiration ledger sequence increases after the operation.
Verification
cargo test -p prediction_market→ 49 passed, 0 failed (rebase note: branch is based on currentmain, which now includes the merged issue [CRITICAL] Payout rounding leaves dust permanently trapped in the contract — sum of payouts never equals the pool #2 payout changes; the TTL tests pass on top of them)git diff --check→ cleanScope
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