Skip to content

Implement optimistic concurrency / versioned schema migration for escrow & risk pool storage #600

Description

@grantfox-oss

Module: meridian-contracts/contracts/escrow, meridian-contracts/contracts/risk_pool

Problem
Both contracts store state in fixed DataKey shapes with no storage version
field or migration path
. AdvancedEscrow sets DataKey::Version (escrow/src/lib.rs:32)
but never reads/migrates it; RiskPoolContract has no version at all. If we add
fields (e.g. escrow fee_bps, risk-pool locked_capital), old deployments
will deserialize garbage or panic. There is also a stray lib.rs.new file in
the escrow src/ (escrow/src/lib.rs.new) that must be reconciled.

Deliverables

  • Define a StorageVersion and a migrate(env, to_version) entry point on both
    contracts that performs additive, backward-compatible migrations.
  • Reconcile/delete escrow/src/lib.rs.new and document what it was.
  • Write a simulation test that deploys an "old" instance (no new fields),
    migrates, and verifies old data is preserved and new fields default correctly.
  • Document the migration policy in meridian-contracts/contracts/README.md.

Acceptance criteria

  • migrate is callable only by admin and is idempotent.
  • Migration test passes; lib.rs.new removed or merged.
  • No breaking change to existing on-chain reads.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions