feat: shared multisig N-of-M approval trait with stake_vault migration#774
Merged
Merged
Conversation
|
@GazzyLee 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! 🚀 |
6 tasks
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
Adds a shared multi-sig N-of-M approval trait (
shared/src/multisig.rs) and migrates thestake_vaultcontract's privileged admin functions to use it. When aMultisigConfigis set, single-admin gated functions (pause,unpause,set_minimum_stake, etc.) returnRequiresMultisigand must go through a propose → approve → execute flow with N-of-M signer approvals.Changes
New file
contracts/shared/src/multisig.rs— Shared multisig module with:MultisigConfig(signers, threshold, proposal timeout),Proposal,ProposalStatustypesMultisigStorageKey+MultisigError(Soroban#[contracttype])set_config,validate_config,is_signer,propose,approve,get_proposal,has_approved,require_can_execute,mark_executedModified files
contracts/shared/src/lib.rs— Addedpub mod multisig+ re-exportscontracts/stake_vault/src/lib.rsmod actionwith discriminator constants for 6 privileged actionsencode_action,encode_i128_bytes,decode_i128_from_byteshelpersset_multisig_config,propose_action,approve_action,execute_actionpause,unpause,set_minimum_stake,set_minimum_stake_duration,configure_slash_tiers,set_appeal_window— each checks for multisig config and returnsRequiresMultisigwhen configuredStorageKeyandStakeVaultErrorvariants referenced by pre-existing code (unblocks compilation)contracts/stake_vault/src/tests.rs— 9 new multisig integration tests (propose→approve→execute flow, error cases)contracts/stake_vault/src/tests_emergency.rs— Fixed.unwrap()on auto-unwrapped Soroban client methodscontracts/integration_tests/Cargo.toml— Fixed duplicate[dev-dependencies]sectionTest results
cargo checkpasses (test compilation blocked by pre-existingasset_registry.rsissues)Design
pausable.rspatternOptional<MultisigConfig>storage —None= single-admin fallback,Some= multisig requiredBytespayloads with discriminator byte + data; dispatch by first byteExpirable-style exclusive upper-bound timeoutMultisigStorageKeyenum avoids collision with contract-localStorageKeyCloses #749