Skip to content

Add storage-layout snapshot test enforcing stable persistent/instance/temporary key namespaces #1197

@Baskarayelu

Description

@Baskarayelu

Description

A silent rename of a storage key in src/storage.rs would orphan all existing data on a deployed contract. Add a snapshot test that serializes every storage-key constructor (InvoiceStorage::invoices_by_business, BidStorage::bids_by_invoice, etc.) for a fixed canonical input set and asserts the resulting key bytes against a committed snapshot. Any key drift becomes a deliberate, reviewable change.

Requirements and context

  • Secure: snapshot deletions require admin review; renames force a migration plan.
  • Tested: snapshot covers every public key-builder in src/storage.rs.
  • Documented: docs/storage-key-stability.md.
  • Reference: src/storage.rs.

Suggested execution

git checkout -b feature/storage-key-snapshot

  • Add src/test_storage_key_layout.rs enumerating key builders.
  • Persist snapshot under src/test_snapshots/storage_keys.txt.
  • Docs: docs/storage-key-stability.md describing migration policy.
  • Rust doc /// comments on the key builders noting "BREAKING: rename requires migration".
  • Validate that persistent vs instance vs temporary storage classes are tagged.

Test and commit

Run cargo test test_storage_key_layout. Cover edge cases for every storage class. Include security note about data orphaning risk.

Example commit message

test(storage): add storage-key layout snapshot to prevent silent migrations

Guidelines

  • Minimum 95% test coverage
  • Clear documentation in docs/storage-key-stability.md
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    securitySecurity hardening and auditssmart-contractSoroban/Rust smart contract worksorobanStellar Soroban specifictestingTests and coverage

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions