📌 Description
Every DataKey::Vault(id) record in src/lib.rs is written to
env.storage().instance(). Because instance storage is loaded and re-serialized
in full on every contract invocation, storing an unbounded, ever-growing set of
vaults there makes each call progressively more expensive and risks hitting
instance-size limits as vault_count grows.
Goal: move per-vault records to persistent storage keyed by id (keeping
only small counters like VaultCount in instance storage), and bump the
entries' TTL on access so active vaults are not archived.
🎯 Requirements and Context
- Must be tested and documented; no behavioural change to entrypoint results.
- Migrate
DataKey::Vault(id) reads/writes from instance() to persistent().
- Add
extend_ttl bumps on read/write so long-lived vaults survive state expiry.
- Keep
VaultCount (and any future admin/pause flags) in instance storage.
- Preserve
get_vault_state / vault_count semantics exactly.
🛠️ Suggested Execution
1. Fork the repo and create a branch
git checkout -b feature/persistent-vault-storage
2. Implement changes
- Contract: update all
DataKey::Vault access in src/lib.rs to persistent
storage with TTL extension; document chosen TTL constants.
- Tests: extend
tests/lifecycle.rs to assert state survives ledger advancement
and that reads/writes still return correct vaults.
- Docs: add
docs/STORAGE_MODEL.md explaining instance vs persistent choices and
the gas/size rationale; cross-link from README.md.
- Add NatSpec-style
/// comments on the storage helpers.
3. Test and commit
- Run
cargo test.
- Cover edge cases: many vaults created, read after large ledger jumps, TTL bump
on each lifecycle transition, get_vault_state for missing id still None.
Example commit message
perf: move vault records to persistent storage with TTL extension
✅ Guidelines
- Minimum 95% test coverage on the migrated storage paths.
- Clear documentation of the storage model and TTL rationale.
- No regressions on existing lifecycle and read semantics.
- Timeframe: 96 hours.
🏷️ Labels
type-performance · area-contracts · type-refactor · MAYBE REWARDED ·
GRANTFOX OSS · OFFICIAL CAMPAIGN
💬 Community & Support
- Join the Disciplr contributor Discord to coordinate, ask questions, and get
unblocked fast: https://discord.gg/xvNAvMJf
- Please introduce yourself before you start so we can avoid duplicate work,
pair you with a reviewer, and merge your PR quickly.
📌 Description
Every
DataKey::Vault(id)record insrc/lib.rsis written toenv.storage().instance(). Because instance storage is loaded and re-serializedin full on every contract invocation, storing an unbounded, ever-growing set of
vaults there makes each call progressively more expensive and risks hitting
instance-size limits as
vault_countgrows.🎯 Requirements and Context
DataKey::Vault(id)reads/writes frominstance()topersistent().extend_ttlbumps on read/write so long-lived vaults survive state expiry.VaultCount(and any future admin/pause flags) in instance storage.get_vault_state/vault_countsemantics exactly.🛠️ Suggested Execution
1. Fork the repo and create a branch
2. Implement changes
DataKey::Vaultaccess insrc/lib.rsto persistentstorage with TTL extension; document chosen TTL constants.
tests/lifecycle.rsto assert state survives ledger advancementand that reads/writes still return correct vaults.
docs/STORAGE_MODEL.mdexplaining instance vs persistent choices andthe gas/size rationale; cross-link from
README.md.///comments on the storage helpers.3. Test and commit
cargo test.on each lifecycle transition,
get_vault_statefor missing id stillNone.Example commit message
✅ Guidelines
🏷️ Labels
type-performance·area-contracts·type-refactor·MAYBE REWARDED·GRANTFOX OSS·OFFICIAL CAMPAIGN💬 Community & Support
unblocked fast: https://discord.gg/xvNAvMJf
pair you with a reviewer, and merge your PR quickly.