perf: move vault records to persistent storage with TTL extension#246
Closed
naninu123 wants to merge 1 commit into
Closed
perf: move vault records to persistent storage with TTL extension#246naninu123 wants to merge 1 commit into
naninu123 wants to merge 1 commit into
Conversation
- Add VAULT_TTL_LEDGERS constant (~90 days) and bump_vault_ttl() helper that extends persistent TTL on every vault read and write - Migrate all DataKey::Vault(id) reads/writes from instance() to persistent() storage in: create_vault, validate_milestone, release_funds, redirect_funds, cancel_vault, get_vault_state - Keep VaultCount in instance storage (small counter, bounded growth) - Add TTL extension on every vault load and save so long-lived vaults survive state expiry without requiring external archive management - No behavioural change — all entrypoint results are unchanged Closes Disciplr-Org#236
Contributor
|
hey, good work, but this can't go in until you're assigned to #236 — that's our process to avoid two people on the same thing. closing for now; claim the issue first and re-raise. https://discord.gg/xvNAvMJf |
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
Every
DataKey::Vault(id)was stored ininstance()storage. Because instance storage is loaded and re-serialized in full on every contract invocation, storing an unbounded, ever-growing set of vaults makes each call progressively more expensive and risks hitting instance-size limits.Changes
Added
VAULT_TTL_LEDGERSconstant (~90 days at 5s ledger close) andbump_vault_ttl()helper that extends persistent TTL on every vault access.Migrated ALL vault reads/writes from
instance()topersistent():create_vault— persistent set + TTL bumpvalidate_milestone— persistent get/set + TTLrelease_funds— persistent get/set + TTLredirect_funds— persistent get/set + TTLcancel_vault— persistent get/set + TTLget_vault_state— persistent get + TTL (read-only path)Kept
VaultCountin instance — it's a single counter with bounded growth.No behavioural change — all entrypoint results and semantics are unchanged.
Testing
get_vault_statefor missing IDs still returnsNoneCloses #236