feat: two-phase MultisigManager threshold rotation#643
Open
dot-enny wants to merge 2 commits into
Open
Conversation
|
@dot-enny 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! 🚀 |
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.
Pull Request Description
📋 Basic Information
Type of Change
Please select the type of change this PR introduces:
Related Issues
Closes #632
Priority Level
📝 Detailed Description
What does this PR do?
feat/multisig-threshold-two-phase.set_thresholdwithpropose_threshold(env, admin, new_threshold).confirm_threshold(env)which enforces a 24-hour configured delay (THRESHOLD_ROTATION_DELAY: u64 = 86400).cancel_threshold_proposal(env, admin)to allow cancelling a pending rotation proposal.PendingThresholdUpdatestruct to hold the proposal state in persistent storage.MultisigThresholdProposedEventandMultisigThresholdConfirmedEventstructures.emit_threshold_proposedandemit_threshold_confirmedinsideEventEmitter.MultisigManager::set_thresholdwith a localizedset_threshold_helperwhich executes the two-phase commit seamlessly behind the scenes (proposing, warping time by 24h, confirming).test_threshold_confirm_before_delayto guarantee a threshold confirmation is rejected before the delay.test_threshold_double_proposeto verify that proposing a second time gracefully overrides the first.test_threshold_cancel_proposeto document and assert the correct cancellation path..unwrap()statements were introduced into contract code (admin.rsandevents.rs). Tests utilize them inherently for assertions."feat: two-phase MultisigManager threshold rotation".Why is this change needed?
In the previous implementation of
MultisigManager, the threshold could be rotated instantly in a single transaction. This introduced a significant security risk where a compromised admin key or accidental inputs could instantly change the threshold and lock out other administrators.By enforcing a two-phase commit with a mandatory 24-hour delay, other admins are given a grace period to notice the proposed changes, inspect the proposal, and cancel it if it was malicious or erroneous.
How was this tested?
multi_admin_multisig_tests.rs:test_threshold_confirm_before_delay: Assert that confirmation fails if attempted before the 24-hour delay.test_threshold_double_propose: Assert that a newer proposal correctly overwrites a pending one.test_threshold_cancel_propose: Assert that pending proposals can be cancelled.Alternative Solutions Considered
THRESHOLD_ROTATION_DELAY = 86400seconds) to keep the codebase simple, clean, and highly secure.🏗️ Smart Contract Specific
Contract Changes
Please check all that apply:
Oracle Integration
Market Resolution Logic
Security Considerations
🧪 Testing
Test Coverage
Test Results