Skip to content

feat(contracts): add contract upgradeability plan + versioning tests (#1809) - #1848

Open
nissinanlung wants to merge 1 commit into
Smartdevs17:mainfrom
nissinanlung:fix/issue-1809-contract-upgradeability-plan
Open

nissinanlung wants to merge 1 commit into
Smartdevs17:mainfrom
nissinanlung:fix/issue-1809-contract-upgradeability-plan

Conversation

@nissinanlung

Copy link
Copy Markdown
Contributor

Summary

Closes #1809.

Storage/upgrade risks were unmanaged. This adds the authoritative upgradeability plan (versioning scheme, step-by-step migration flow, rollback/emergency procedures, blue-green cutover) plus real-contract tests for the subscription upgrade hooks.

Changes

  • docs/CONTRACT_UPGRADE_PLAN.md — proxy+storage+implementation architecture; STORAGE_VERSION/ProxyVersion scheme; monotonic upgrade rules; step-by-step in-place upgrade procedure (schedule → timelock → validate → migrate → version bump); rollback & emergency procedures; blue-green cutover for breaking changes; version history table; test coverage mapping.
  • contracts/subscription/tests/upgrade_versioning.rs — 7 tests against the real SubTrackrSubscription + UpgradeableProxy + SubTrackrStorage trio (no mocks):
    • get_version returns current STORAGE_VERSION
    • validate_upgrade accepts prior/current (1, 2), rejects 0 and future (3)
    • migrate is a no-op at current version; rejects unsupported future path
    • migrate_v1_to_v2_rebuilds_user_plan_index_for_active_only — drops UserPlanIndex to simulate a v1 snapshot, runs migrate(1), asserts the index is rebuilt for active subscriptions only (cancelled skipped)
    • proxy version tracks implementation version after initialize
    • Verified passing locally on stable cargo.

Acceptance criteria

  • Versioning — STORAGE_VERSION constant + ProxyVersion proxy storage; monotonic upgrades enforced; per-version migrate arms.
  • Migration steps — in-place schedule→timelock→validate→migrate→bump flow plus blue-green cutover for breaking changes; rollback path.
  • Tested — upgrade_flow.rs (proxy lifecycle) + upgrade_versioning.rs (real-contract versioning, compatibility gates, v1→v2 migration).

Quality Gates

  • Rust tests pass locally (cargo test --test upgrade_versioning, stable)
  • Rust build / clippy (CI)
  • Documentation updated

…martdevs17#1809)

Document the upgradeability scheme (versioning, in-place migration flow,
rollback, blue-green cutover) and add real-contract tests for the
subscription upgrade hooks.

Changes:
- Add docs/CONTRACT_UPGRADE_PLAN.md: proxy+storage+implementation
  architecture, STORAGE_VERSION/ProxyVersion scheme, monotonic upgrade
  rules, step-by-step in-place upgrade procedure, rollback & emergency
  procedures, blue-green cutover for breaking changes, version history,
  and test coverage mapping
- Add contracts/subscription/tests/upgrade_versioning.rs: 7 tests against
  the real SubTrackrSubscription + UpgradeableProxy + SubTrackrStorage trio
  — get_version, validate_upgrade boundary gates (0/1/2/3), migrate
  idempotency, unsupported-path rejection, v1→v2 UserPlanIndex rebuild
  (active only), and proxy-version tracking. Verified passing on stable.

Acceptance criteria:
- [x] Versioning — STORAGE_VERSION constant + ProxyVersion proxy storage;
      monotonic upgrades enforced; per-version migrate arms
- [x] Migration steps — in-place schedule→timelock→validate→migrate→bump
      flow plus blue-green cutover for breaking changes; rollback path
- [x] Tested — upgrade_flow.rs (proxy lifecycle) + upgrade_versioning.rs
      (real-contract versioning, compatibility gates, v1→v2 migration)
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@nissinanlung Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nissinanlung
nissinanlung deployed to security-review October 19, 2026 18:55 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
security-review — b3fc0f16 Deployed Oct 19, 2026 by nissinanlung via Security Dashboard #1401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add contract upgradeability plan

1 participant