Skip to content

Move per-investor contribution and yield keys from instance to persistent storage #253

@mikewheeleer

Description

@mikewheeleer

Description

DataKey::InvestorContribution, InvestorEffectiveYield, InvestorClaimNotBefore, and InvestorClaimed are stored in instance storage, so every investor's data shares one entry whose size grows unbounded and whose TTL is coupled to the escrow. The allowlist already uses persistent(). Migrate per-investor keys to persistent storage to bound instance footprint and isolate per-address TTL, per ADR-007.

Requirements and context

  • Scoped to the LiquiFact escrow Soroban contract.
  • Switch the four per-investor keys to env.storage().persistent() consistently across writers (fund_impl, claim_investor_payout) and readers (get_contribution, etc.).
  • Provide a documented migration note (likely redeploy per the migrate panic policy) and bump SCHEMA_VERSION.
  • Invariant: read/write semantics unchanged from a caller's perspective; defaults still apply on absence.
  • Reference docs/escrow-gas-storage-notes.md and ADR-007.
  • Must be secure, tested, and documented.

Suggested execution

  • Fork the repo and create a branch:
    • git checkout -b enhancement/persistent-investor-keys
  • Implement changes:
    • escrow/src/lib.rs
    • Tests: escrow/src/tests/funding.rs
    • Docs: docs/adr/ADR-007-storage-key-evolution.md
    • Include rustdoc/NatSpec-style doc comments on public functions
    • Validate security assumptions (auth, overflow, storage TTL, double-spend)

Test and commit

  • Run tests: cargo test
  • Cover edge cases (zero amounts, overflow, unauthorized callers, double-spend, state-machine misuse)
  • Include test output and security notes in the PR

Example commit message

refactor(escrow): persist per-investor storage keys

Guidelines

  • Minimum 95% test coverage on new/changed code
  • Clear documentation
  • Timeframe: 96 hours from assignment

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions