Skip to content

perf: move vault records to persistent storage with TTL extension#246

Closed
naninu123 wants to merge 1 commit into
Disciplr-Org:mainfrom
naninu123:feature/persistent-vault-storage
Closed

perf: move vault records to persistent storage with TTL extension#246
naninu123 wants to merge 1 commit into
Disciplr-Org:mainfrom
naninu123:feature/persistent-vault-storage

Conversation

@naninu123

Copy link
Copy Markdown

Summary

Every DataKey::Vault(id) was stored in instance() 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

  1. Added VAULT_TTL_LEDGERS constant (~90 days at 5s ledger close) and bump_vault_ttl() helper that extends persistent TTL on every vault access.

  2. Migrated ALL vault reads/writes from instance() to persistent():

    • create_vault — persistent set + TTL bump
    • validate_milestone — persistent get/set + TTL
    • release_funds — persistent get/set + TTL
    • redirect_funds — persistent get/set + TTL
    • cancel_vault — persistent get/set + TTL
    • get_vault_state — persistent get + TTL (read-only path)
  3. Kept VaultCount in instance — it's a single counter with bounded growth.

  4. No behavioural change — all entrypoint results and semantics are unchanged.

Testing

  • All existing tests pass (awaiting CI)
  • Vault state survives ledger advancement with TTL extension
  • get_vault_state for missing IDs still returns None

Closes #236

- 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
@1nonlypiece

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce instance-storage growth by moving per-vault records to persistent storage with TTL bumps

2 participants