Skip to content

Support multiple vaults per contract instance via persistent storage map in accountability_vault #358

@1nonlypiece

Description

@1nonlypiece

Support multiple vaults per contract instance via persistent storage map in accountability_vault

Description

contracts/accountability_vault/src/lib.rs stores a single Vault under DataKey::Vault in instance storage, so one deployed contract supports exactly one vault. Refactor to key vaults by a vault_id in persistent storage so a single deployment can host many vaults, matching the backend model where each PersistedVault has an id (src/types/vaults.ts). Update all functions to take a vault_id argument.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Change DataKey::Vault to DataKey::Vault(BytesN/Symbol id) in contracts/accountability_vault/src/lib.rs
  • Thread a vault_id through create_vault/stake/check_in/slash_on_miss/claim/withdraw
  • Use persistent (not instance) storage with TTL bumps
  • Add multi-vault tests in contracts/accountability_vault/src/test.rs

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feat/multi-vault-storage
  • Implement changes
    • Modify contracts/accountability_vault/src/lib.rs
    • Add tests in contracts/accountability_vault/src/test.rs
    • Document the keying scheme in contracts/README.md
    • Add storage TTL handling
  • Test and commit
    • Run tests, cover edge cases
    • Include test output and notes

Example commit message

feat: support multiple vaults per contract via id keying

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions