feat: add storage TTL bump to prevent persistent/instance data expiration (Closes #7) - #25
Open
ney9320 wants to merge 1 commit into
Open
feat: add storage TTL bump to prevent persistent/instance data expiration (Closes #7)#25ney9320 wants to merge 1 commit into
ney9320 wants to merge 1 commit into
Conversation
…tion Add bump_instance() to all 5 contracts (treasury, voting, loan, governance, dividend) that extends instance storage TTL at the start of every state-changing function. For treasury and voting contracts which use persistent storage: - Add extend_ttl() after contribution history writes in treasury::contribute() - Add extend_ttl() after vote map writes in voting::create_proposal() and voting::vote() TTL values (documented in-code): - Instance: threshold 30 days, extend to 180 days - Persistent: threshold 30 days, extend to 180 days - Based on approx 5s ledger close time (~17,280 ledgers/day) Closes coopfinance#7
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
Add storage TTL bump calls to all 5 Soroban contracts to prevent persistent and instance storage from expiring on the Stellar network.
Closes #7
Changes
All 5 contracts (treasury, voting, loan, governance, dividend)
LEDGERS_PER_DAY,INSTANCE_TTL_THRESHOLD(30 days),INSTANCE_TTL_EXTEND_TO(180 days)bump_instance()helper that callsenv.storage().instance().extend_ttl()bump_instance()at the start of every state-changing functionTreasury contract (has persistent storage)
extend_ttl()onDataKey::Contributions(member)after each persistent write incontribute()initialize,add_member,contribute,withdrawVoting contract (has persistent storage)
extend_ttl()onDataKey::Votes(proposal_id)after writes increate_proposal()andvote()initialize,create_proposal,vote,finalizeLoan, Governance, Dividend (instance storage only)
TTL Design Decisions
Testing
All 21 existing treasury contract tests pass:
No changes to test behavior — TTL calls are no-ops in the mock test environment (
Env::default()).