feat(contracts): add storage TTL bump calls to prevent expired persistent & instance entries (closes #7) - #23
Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Conversation
…tent & instance entries (closes coopfinance#7) Soroban charges rent on stored entries and evicts them once their TTL elapses unless explicitly bumped. Treasury contribution history and voting vote maps live in persistent storage; every contract keeps its config/state in instance storage. Without TTL bumps these are silently deleted on an inactive group. - Add a bump_instance() helper to all five contracts, called at the start of every state-changing entrypoint (read-only getters intentionally do not bump, keeping them cheap and write-free). - extend_ttl on persistent storage after every write: treasury.contribute (per-member history) and voting.create_proposal / voting.vote (vote maps). - Document chosen ledger counts: instance ~30d, persistent ~90d, at ~17280 ledgers/day (5s/ledger), threshold one day below target. - dividend: add missing `String` to imports so the crate compiles (it did not build before, which blocked the whole workspace). All existing tests pass (cargo test --workspace: 21 passed, 0 failed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Adds Soroban storage TTL bump calls across all five contracts so contribution history, vote maps and every contract's instance state are not silently evicted by the network. Closes #7.
Why
Persistent and instance storage entries in Soroban carry a time-to-live (TTL) and are deleted once it elapses unless explicitly extended. Today no
extend_ttlcalls exist, so on an inactive group theTreasuryContractcontribution history andVotingContractvote maps — plus every contract's admin/config — can disappear.Changes
bump_instance()helper in all 5 contracts (treasury, voting, loan, governance, dividend), called at the start of every state-changing entrypoint. Read-only getters intentionally do not bump — that keeps them cheap, read-only calls and avoids turning a dashboard read into a state write; any mutating call keeps instance storage alive, so an active group never loses config.extend_ttlon persistent storage after every write:treasury::contribute→ per-memberContributions(member)historyvoting::create_proposalandvoting::vote→ per-proposalVotes(id)map17_280ledgers:INSTANCE_BUMP_LEDGERS)PERSISTENT_BUMP_LEDGERS)dividend: added missingStringto the imports. The crate did not compile before this PR (error[E0425]: cannot find type String), which blockedcargo teston the whole workspace; the fix was required to addbump_instancethere and to satisfy the "all existing tests pass" criterion.Acceptance criteria
extend_ttlcalled after every persistent storage write (treasury.contribute, voting.create_proposal, voting.vote)#[contractimpl]method (getters excluded by design, documented)cargo test --workspace: 21 passed, 0 failed/claim #7