[Governance] Formal Upgrade Framework with Version Tracking, Migration Hooks, and Rollback (Issue #16) - #36
Open
Jokay1997 wants to merge 6 commits into
Open
Conversation
…tion Hooks, and Rollback Closes EquipChain#16 - Formal Upgrade Framework with Version Tracking, Migration Hooks, and Rollback - Add upgrade_framework.rs module with contract version tracking - Implement version history with VersionInfo storage - Add migration registry with static hook entries for version transitions - Implement two-phase upgrade: propose, approve, execute with timelock - Add emergency rollback with rollback point management - Add storage schema versioning per data key - Enforce MIN_UPGRADE_INTERVAL (72h) between non-emergency upgrades - Add cancel_upgrade_proposal for proposer retraction
- Remove (macro generates type directly) - Fix collapsible where sla_config is not Option - Add missing Vec/String imports to nonce_sync_tests.rs - Add cross-module import to property_tests - Add cross-module import to tariff_property_tests - Add missing Vec import to temporary_storage_tests.rs
Resolve cargo fmt --check failures on both CI jobs: - Collapse env.storage().instance().get(&DataKey::ApprovedTokens) onto one line in require_approved_token() (was split across 3 lines, now fits under 100 chars) - Wrap env.storage().instance() chains in approve_token(), revoke_token() starting at env. rather than env.storage() per rustfmt chain-call rules - Wrap env.storage().instance().set() calls in approve_token() and revoke_token() - Collapse get_token_info() single-expression body onto one line All changes are pure formatting; no logic altered.
…elayNotElapsed, RollbackPointNotFound, RollbackAlreadyConsumed, MigrationFailed) The upgrade_framework.rs module referenced ContractError::MigrationFailed which was declared in the PR description but not added to the ContractError enum. Also adds the other three Issue EquipChain#16 error codes: UpgradeDelayNotElapsed = 119 RollbackPointNotFound = 120 RollbackAlreadyConsumed = 121 MigrationFailed = 122 Fixes cargo clippy --lib failure introduced by this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #16.
Implements a Formal Upgrade Framework for EquipChain smart contracts, providing version tracking, sequential migration hooks, two-phase upgrade approval, storage schema versioning, and emergency rollback. This replaces ad-hoc contract upgrades with a governed, auditable process enforced entirely on-chain.
Files Changed
Implementation Details
upgrade_framework.rs — New Module
Version Tracking
Migration Registry
Two-Phase Upgrade
propose_upgrade → (multi-sig approval) → execute_upgradeUpgrade Delay Enforcement
Emergency Rollback
ollback_to_version(n)\ restores a previous WASM hash from \PreviousWasmHash(u32)\ storage
Storage Schema Versioning
lib.rs — Registry Updates
New \DataKey\ variants:
New \ContractError\ variants:
Testing