docs: storage tier matrix - #903
Merged
greatest0fallt1me merged 1 commit intoJul 24, 2026
Merged
Conversation
|
@pheobeayo 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! 🚀 |
Contributor
|
LGTM ✅ appreciate the detailed PR description! |
4 tasks
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.
Pull Request Description
📋 Basic Information
Type of Change
Related Issues
Closes #836
Related to #734 (prior storage-tier audit — see "Notes for Reviewers")
Priority Level
📝 Detailed Description
What does this PR do?
Adds
docs/STORAGE_TIER.md, a reference matrix documenting the storage tierand TTL policy for every data key in
contracts/predictify-hybrid.The document separates two concepts that are easy to conflate:
instance/persistent/temporary) chosen at each call site.by the private
StorageTtlTierenum and resolved throughStorageOptimizer::persistent_ttl_for_tier.It covers: the four TTL tier constants with their ledger counts and durations,
the
StorageConfigfields that override them, themax_ttl()clampingbehaviour, a per-key matrix for both
DataKeyvariants and the non-DataKeycomposite keys, guidance for choosing a tier for new keys, and a "Known
deviations" section recording places where the code diverges from the
documented policy.
This is a documentation-only change. No Rust source files are added or
modified.
Why is this change needed?
Tier assignment is currently made at roughly a dozen individual call sites
rather than by a central
DataKey -> tierfunction. There is no single place acontributor can look to answer "which tier does this key use, and for how
long?" — the answer has to be reassembled by grepping
persistent_ttl_for_tiercall sites. That makes it easy to add a new key withan inappropriate tier, or to change a TTL constant without realising which
keys it affects.
How was this tested?
No automated tests accompany this PR, and none can meaningfully be added — the
change introduces a single markdown file with no executable surface.
Verification performed instead:
directly from
storage.rsrather than inferred.LEDGERS_PER_DAY = 17_280and matches the declared constants:Balance 535,680 (~31 d), Market 6,307,200 (~365 d), Event 1,555,200 (~90 d),
Archive 6,307,200 (~365 d),
PlaceBetsIdem120,960 (~7 d).persistent_ttl_for_tier/set_persistent_with_ttlcall site wastraced to the key it writes, so the matrix maps keys rather than line
numbers.
cargo testcannot currently be run on this branch. See "Test Results"below — this is a pre-existing condition on
main, not a regressionintroduced here.
Alternative Solutions Considered
A larger change was considered and rejected for this PR: making
StorageTtlTierpublic, addingpub fn tier_for(key: &DataKey) -> StorageTtlTier, routingBalanceStorage::update_balancethrough it, andadding a test asserting every
DataKeyvariant maps to a tier. That would makethe matrix enforceable rather than advisory and would satisfy the "tests added"
criterion.
It was rejected here because issue #836 scopes the work to a single new
documentation file and is labelled
documentation. It also depends on firstfixing the
DataKeycompile error (deviation 1 below), which is a separateconcern. Recommended as a follow-up — happy to open it if maintainers agree.
🏗️ Smart Contract Specific
Contract Changes
No contract code is modified by this PR. None of the following apply:
Oracle Integration
Not applicable — no oracle code touched.
Market Resolution Logic
Not applicable — no resolution code touched.
Security Considerations
Not applicable to a documentation-only change. No executable surface is added,
so there is no access control, reentrancy, input validation, or overflow
exposure introduced.
🧪 Testing
Test Coverage
No tests added — see "How was this tested?" for why, and "Notes for Reviewers"
for the follow-up that would make tests possible.
Test Results
cargo testdoes not currently run onmain.DataKeyincontracts/predictify-hybrid/src/storage.rsdeclares the same variant twice:Additionally,
AntiGriefFloor,GlobalConfig, andPlaceBetsIdemareconstructed in
disputes.rs, the governance tests, andbets.rsrespectively,but are absent from the
DataKeyenum.This is a pre-existing condition on
mainand is unrelated to this PR — thebranch inherits it. The 95% coverage requirement in #836 is not satisfiable by
any PR until it is resolved. Flagging it here because it likely blocks other
in-flight work.
Manual Testing Steps
StorageConfigfields, and clamping helpersdirectly from
storage.rsand cross-checked each against the document.matches the declared constants.
persistent_ttl_for_tierandset_persistent_with_ttlcallsite to the key it writes, and confirmed each row of the matrix.
📚 Documentation
Documentation Updates
docs/STORAGE_TIER.md)Breaking Changes
None. No public API, storage layout, or contract behaviour is changed.
Migration Guide: Not applicable.
🔍 Code Quality
Code Review Checklist
guidance directs new keys through the existing tier helpers)
Performance Impact
Security Review
🚀 Deployment & Integration
Deployment Notes
Integration Points
📊 Impact Assessment
User Impact
grep call sites to determine a key's retention. Records four known code
deviations that were previously undocumented.
StorageConfigfields affect which keys, andthat configured TTLs are upper bounds clamped by
max_ttl().Business Impact
document records rather than resolves the deviations it identifies. Because
no test enforces the matrix, it can drift from the code — the follow-up in
"Alternative Solutions Considered" would close that gap.
✅ Final Checklist
Pre-Submission
maindoes not compile(see "Test Results"); unrelated to this change
Review Readiness
📸 Screenshots (if applicable)
Not applicable.
🔗 Additional Resources
contracts/predictify-hybrid/src/storage.rs[Soroban persisting data](https://developers.stellar.org/docs/build/guides/storage)
💬 Notes for Reviewers
Please pay special attention to:
The "Known deviations" section of the new document. It records four
issues found while writing the matrix. These are documented, not fixed, since
this PR is documentation-only:
DataKeydoes not compile (duplicateAdminOverrideNonce; three variantsused elsewhere but never declared).
BalanceStorage::update_balancecallsextend_ttl(&key, 535680, 535680)with hardcoded literals instead of
persistent_ttl_for_tier(Balance). Theliteral happens to equal
BALANCE_TTL_LEDGERS, so behaviour matchestoday — but the write ignores any
StorageConfigoverride and skips themax_ttl()clamp.DataKey -> tiermapping exists, so the matrix can driftsilently.
storage_tier_audit.rsexists but is not declared inlib.rs.Overlap with Add storage-tier classifier audit #734.
storage_tier_audit.rsclaims to answer that issueand exports
get_storage_tier_audit, but as unregistered dead code it nevercompiles and its
#[cfg(test)]tests never execute. Its table also nameseight keys that are not
DataKeyvariants (Admin,PlatformFee,GovernanceMinBps,CumDisputeFee,DisputeMultiSig,OracleConfidence,AdminEmergency,Market) while omitting most that are. Where it disagreeswith this document, this document reflects the code.
Inferred rows in the matrix. Tiers for
AntiGriefFloor,GlobalConfig,PlaceBetsIdem, andAdminOverrideNonceare inferred from call sites, sinceno valid enum declaration currently exists to read. A few
Market-tier rows(
Whitelisted,Blacklisted) are inferred from the surrounding writepattern rather than a direct
persistent_ttl_for_tiercall. These are therows most worth a maintainer's eye.
Questions for reviewers:
storage_tier_audit.rsbe registeredin
lib.rsand reconciled against this matrix? Two disagreeing tier tablesin the repo seems worse than either alone.
DataKeycompile break known and already being addressed in one ofthe open PRs? If not, I'm happy to open a separate PR fixing the duplicate
variant and adding the three missing ones.
tier_for(&DataKey)plus anexhaustive-mapping test, which would make this matrix enforceable rather than
advisory?
Thank you for your contribution to Predictify! 🚀