Skip to content

feat: complete upgrade safety gate with migration regression tests (#318) - #322

Merged
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
tolulopedd26:feat/upgrade-safety-gate
Jul 21, 2026
Merged

feat: complete upgrade safety gate with migration regression tests (#318) #322
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
tolulopedd26:feat/upgrade-safety-gate

Conversation

@tolulopedd26

Copy link
Copy Markdown
Contributor

Summary

Completes the upgrade safety gate implementation and adds comprehensive migration regression coverage.

Changes

Contract (Issue #318):

  • Added UpgradeGateEnabled storage key — master switch to enable/disable all upgrades
  • Added set_upgrade_gate(caller, enabled) — admin function to toggle the gate
  • Added check_upgrade_safety() — public view returning UpgradeSafetyReport with full safety breakdown
  • Added get_upgrade_status() — public view returning UpgradeState including gate_enabled
  • Integrated gate check into start_upgrade() — blocks when gate is disabled
  • Added UpgradeSafetyReport type with fields: is_safe, gate_enabled, window_active, upgrade_in_progress, version_compatible, invariants_satisfied
  • Updated UpgradeState to include gate_enabled field

Migration Regression Tests (12 new tests):

  • upgrade_safety_gate_blocks_when_gate_disabled — gate blocks upgrades when disabled
  • upgrade_safety_gate_succeeds_when_gate_enabled — upgrades succeed when gate is enabled
  • upgrade_safety_gate_check_upgrade_safety_reports_version — safety report correctness
  • upgrade_safety_gate_check_reports_unsafe_when_disabled — unsafe when gate disabled
  • upgrade_safety_gate_check_reports_unsafe_without_window — unsafe without window
  • upgrade_safety_gate_check_reports_unsafe_when_in_progress — unsafe during upgrade
  • upgrade_safety_gate_check_reports_unsafe_on_invariant_violation — unsafe on bad state
  • upgrade_safety_gate_get_upgrade_status_includes_gate_enabled — status includes gate field
  • upgrade_safety_gate_non_admin_cannot_set_gate — admin-only enforcement
  • upgrade_safety_gate_toggle_preserves_contract_state — regression: gate toggle preserves escrows/fees/privacy
  • upgrade_safety_gate_full_lifecycle — end-to-end gate lifecycle
  • upgrade_safety_gate_migrate_works_independently_of_gate — migrate() unaffected by gate

Documentation:

  • Updated UPGRADE_SAFETY_GATE_IMPLEMENTATION.md
  • Updated UPGRADE_SAFETY_GATE_TEST_GUIDE.md
  • Updated docs/UPGRADE_SAFETY_GATE.md

Test Results

All 329 tests pass (23 upgrade safety gate tests).

cargo test: ok. 329 passed; 0 failed

Closes #318

tolulopedd26 and others added 2 commits July 20, 2026 16:30
…lockDash-Studios#318)

- Add UpgradeGateEnabled master switch to storage with set/get helpers
- Add check_upgrade_safety() view for pre-upgrade validation
- Add get_upgrade_status() returning full UpgradeState including gate_enabled
- Add set_upgrade_gate() admin entrypoint to enable/disable upgrades
- Integrate gate check into start_upgrade() flow
- Add UpgradeSafetyReport type with comprehensive safety breakdown
- Add 8 new migration regression tests covering gate lifecycle,
  safety report correctness, state preservation, and migrate independence
- Update documentation (IMPLEMENTATION, TEST_GUIDE, UPGRADE_SAFETY_GATE)

Closes BlockDash-Studios#318

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a job welldone

@MaryammAli
MaryammAli merged commit 7e9cb63 into BlockDash-Studios:main Jul 21, 2026
2 checks passed
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.

complete upgrade safety gate and add contract migration regression coverage

2 participants