fix(leaderboard): manage instance storage TTL lifecycle - #111
Open
MJ-RWA wants to merge 3 commits into
Open
Conversation
Author
|
@Muyideen-js PR ready |
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
Fix the leaderboard's instance-storage TTL lifecycle so cached state such as
MinPointsandMinSlotdoes not silently expire without an appropriate refresh strategy.The leaderboard currently stores core state in Soroban instance storage without explicitly managing its TTL. After prolonged inactivity, this can cause cached values to expire and potentially leave subsequent leaderboard updates operating with missing/default state.
Problem
MinPointsandMinSlotare stored in instance storage, but their TTL lifecycle was not being managed.When the instance-storage TTL expires, the cached minimum can be lost. A subsequent leaderboard update may then observe the missing value as the default
u64::MAXand trigger the minimum-recomputation path unexpectedly.Because this state participates in leaderboard insertion and displacement decisions, TTL expiration can become a latent trigger for incorrect leaderboard behavior.
The same lifecycle concern also applies to other relevant instance-storage entries, so the fix addresses the storage lifecycle consistently rather than adding a narrowly scoped workaround for
MinPointsalone.What Changed
MinPointsandMinSlotare covered by the storage lifecycle strategy.Root Cause
The leaderboard relied on instance-storage values without explicitly managing their TTL lifecycle.
Soroban instance storage is subject to TTL expiration, meaning contract inactivity can cause cached instance state to disappear. The leaderboard's subsequent fallback behavior can then operate on missing cache state and trigger incorrect minimum handling.
The fix addresses the underlying TTL lifecycle rather than treating the resulting
MinPointsvalue as an isolated cache bug.Testing & Verification
The implementation was verified against the repository's applicable quality checks, including:
Acceptance Criteria
MinPointsis protected from unintended TTL expiration.MinSlotis protected from unintended TTL expiration.Scope
This PR is intentionally limited to the leaderboard instance-storage TTL lifecycle issue. It does not attempt to redesign the leaderboard's ranking algorithm or address unrelated leaderboard issues.
Review Notes
The implementation should be reviewed with particular attention to:
Closes: #66