feat(auction): bump TTL on hot storage reads - #1243
Open
Kingvic300 wants to merge 1 commit into
Open
Conversation
Add persistent-storage-backed auctions with create_auction/get_auction entrypoints. get_auction is the contract's hot read path, so every call extends the auction record's TTL back to a full lifetime once it drops below the refresh threshold, keeping frequently-read, rarely-written auctions clear of archival eviction. Closes Predictify-org#1115
|
@Kingvic300 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
auctioncontract:create_auction(state-changing, requiresseller.require_auth()) andget_auction(read-only).get_auctionis the contract's hot read path. Every call extends the auction record's persistent TTL back to a full lifetime (AUCTION_TTL_EXTEND_TO) once it has dropped below the refresh threshold (AUCTION_TTL_THRESHOLD), usingextend_ttl()semantics (extend-only, idempotent). This keeps frequently-read, rarely-written auctions from falling to archival eviction / rent pressure.create_auctionwrites the record with a full TTL up front and validatesreserve_price > 0; the auction id counter useschecked_add(overflow-safe, nounwrap()).Why
The
auctioncontract previously only exposed acapabilities()stub with no storage at all, so there was no read path to bump. This change adds the smallest real storage layer needed to give "bump TTL on hot reads" concrete meaning, following the same threshold/bump-amount pattern already used inpredictify-hybrid(e.g.MARKETS_LIFETIME_THRESHOLD/MARKETS_BUMP_AMOUNT) and in theallowlistcontract.Test plan
cargo test -p auction— 10/10 passing, covering: capabilities (existing), auction creation + auth requirement, reserve-price validation (zero/negative), id increment across creations, id-counter overflow, not-found on missing auction, and TTL-bump behavior both below and above the refresh threshold.cargo clippy -p auction --all-targets— clean, no warnings.cargo fmt -p auction -- --check— clean.Closes #1115