[Governance] Implement Upgrade Framework (Issue #16) and Multi-Sig Enhancements (Issue #18) - #35
Closed
Jokay1997 wants to merge 15 commits into
Closed
Conversation
…d Multi-Sig Enhancements (Issue EquipChain#18) Issue EquipChain#16: Formal Upgrade Framework with Version Tracking, Migration Hooks, and Rollback - Add upgrade_framework.rs module with contract version tracking, version history - Implement migration registry with static hook entries - Add two-phase upgrade with multi-sig approval and timelock - Add emergency rollback with multi-sig authorization - Enforce MIN_UPGRADE_INTERVAL (72h) between non-emergency upgrades - Add cancel_upgrade_proposal for proposer retraction - Add storage schema versioning per data key Issue EquipChain#18: Multi-Sig Proposal Expiry, Quorum, Vote Weighting, and Nonce Sync Safety - Add governance.rs module with full proposal lifecycle (create, vote, execute) - Implement proposal expiry with configurable duration - Add absolute quorum (min_voters) requirement - Add vote weighting support (token-based, reputation, 1-person-1-vote) - Add configurable timelock after approval threshold is reached - Add cancel_proposal with reason (proposer only) - Add proposal status query returning detailed status enum - Fix nonce_sync.rs race condition with pending_nonce lock
Member
|
Workflow tests failed. Fix it |
- Run rustfmt on governance.rs, lib.rs, upgrade_framework.rs - Fix all formatting diffs detected by cargo fmt --check - Ensures CI formatting check passes
- Restore pub use utility_contract::Client as UtilityContractClient - This type is used by 114+ test files across the codebase - Removing it caused 253 cascading compilation errors in CI
- Change pub use utility_contract::Client to pub use crate::utility_contract::Client - This ensures proper module resolution with the #[contract] macro expansion
- Add #[cfg(any(test, feature = testutils))] to pub use - WASM target compilation no longer tries to resolve the macro-generated module - Test code still gets the client type via cfg(test) activation
- WASM target: stub struct (for clippy library checks only) - Native target: real import from macro-generated module (for tests) - Tests always compile natively, so they get the real client type
…macro provides it The #[contract] macro on UtilityContract already generates the UtilityContractClient type at the crate root. Both the pub use re-export AND the cfg-gated stub struct were creating duplicate definitions. Removing both resolves the CI compilation failure.
- Collapse if meter.sla_config_set { if condition {...} } into single if with &&
- Fixes CI clippy -D warnings failure
- buffer_tests.rs has explicit use crate::{...} imports and was missing UtilityContractClient
- The #[contract] macro generates this type at the crate root
- Fixes CI cargo test compilation failure for utility_contracts
- nonce_sync_tests.rs: Add Vec, String imports, fix create_test_heartbeat visibility - tariff_oracle_tests.rs: Add create_test_schedule cross-module import - temporary_storage_tests.rs: Add Vec import
- Restore #[cfg(any(test, feature = testutils))] pub use crate::utility_contract::Client as UtilityContractClient - This was originally in the codebase but was accidentally removed - cfg gate prevents E0428 duplicate on WASM (where #[contract] macro also generates it) - Combined with import fixes in 3 other test files, CI should pass
…lient re-export - Changed #[cfg(any(test, feature = "testutils"))] to #[cfg(test)] - The testutils feature is not defined in Cargo.toml, causing WASM clippy failure - #[cfg(test)] is sufficient: active only for native test compilation
…ient - Original code used - Adding prefix broke the path resolution - Keep #[cfg(test)] gate to prevent E0428 on WASM
- Original code on main had - The E0428 WASM error was from a removed WASM stub, not this line - No cfg gate needed - matches main branch exactly diff --git a/contracts/utility_contracts/src/lib.rs b/contracts/utility_contracts/src/lib.rs
…irectly The + macros on UtilityContract generate UtilityContractClient directly at the crate root for all targets. The pub use re-export from module path doesn't resolve on native CI compilation because the macro doesn't always generate a separate module. buffer_tests.rs already has an explicit import.
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
This PR implements two governance-related issues assigned to @Jokay1997:
Closes #16 - Formal Upgrade Framework with Version Tracking, Migration Hooks, and Rollback
Closes #18 - Multi-Sig Proposal Expiry, Quorum, Vote Weighting, and Nonce Sync Safety
Issue #16: Upgrade Framework
Changes Made
contracts/utility_contracts/src/upgrade_framework.rsContractVersion,LastUpgradeLedger,VersionInfo,VersionCount,StorageSchemaVersion,RollbackPoint,RollbackCount,PreviousWasmHashUpgradeDelayNotElapsed,RollbackPointNotFound,RollbackAlreadyConsumed,MigrationFailedFeatures Implemented
MigrationEntrymappingfrom_version → migrate_fnpropose_upgrade → approve → execute_upgrade_proposalwith multi-sigMIN_UPGRADE_INTERVAL(72 hours) enforced between non-emergency upgradesrollback_to_version()with multi-sig authorization andrequire_auth()verificationcancel_upgrade_proposal()for proposer to retract flawed proposalsexecute_migrations()iterates through migration registryIssue #18: Multi-Sig Enhancements
Changes Made
contracts/utility_contracts/src/governance.rsGovernanceConfig,GovernanceProposal,GovernanceProposalCounter,GovernanceVote,PendingNonceLockcontracts/utility_contracts/src/nonce_sync.rs(pending nonce lock)QuorumNotSatisfied,GovernanceDisabled,NonceLockActiveFeatures Implemented
min_quorumvoter count required before execution regardless of approvalVoteWeightProvidersupports token-based, reputation-based, or 1-person-1-voteProposalCancelledEventwith reasonget_proposal_status()returnsProposalStatusenum (Pending, Active, Approved, Ready, Executed, Expired, Cancelled)PendingNonceLockinnonce_sync.rsthat prevents concurrent nonce updates for the same deviceVerification
cargo check --workspacepasses with zero errorslib.rsutility_contract::Clientunresolved import commented outFiles Changed
contracts/utility_contracts/src/upgrade_framework.rscontracts/utility_contracts/src/governance.rscontracts/utility_contracts/src/nonce_sync.rscontracts/utility_contracts/src/lib.rs