Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c7584c0
Stored call in multisig
gavofyork Jun 10, 2020
0ddd158
Docs.
gavofyork Jun 10, 2020
c30f54f
Benchmarks.
gavofyork Jun 10, 2020
dbac9eb
Fix
gavofyork Jun 10, 2020
3669489
Update frame/multisig/src/lib.rs
gavofyork Jun 10, 2020
9f59d31
patch benchmarks
shawntabrizi Jun 11, 2020
69682e5
Minor grumbles.
gavofyork Jun 11, 2020
e48f3e4
Merge branch 'gav-multisig-stored-call' of github.com:paritytech/subs…
gavofyork Jun 11, 2020
a363d4b
Update as_multi weight
shawntabrizi Jun 11, 2020
1c69bb0
Merge branch 'gav-multisig-stored-call' of https://github.com/parityt…
shawntabrizi Jun 11, 2020
a8343cb
Fixes and refactoring.
gavofyork Jun 11, 2020
fdcab27
Merge branch 'gav-multisig-stored-call' of github.com:paritytech/subs…
gavofyork Jun 11, 2020
bd5f05e
Split out threshold=1 and opaquify Call.
gavofyork Jun 11, 2020
8b9aaae
Compiles, tests pass, weights are broken
shawntabrizi Jun 14, 2020
09da872
Update benchmarks, add working tests
shawntabrizi Jun 14, 2020
2b5c361
Add benchmark to threshold 1, add event too
shawntabrizi Jun 14, 2020
2cf2832
suppress warning for now
shawntabrizi Jun 14, 2020
9a2d25f
@xlc improvment nit
shawntabrizi Jun 14, 2020
db75543
Update weight and tests
shawntabrizi Jun 15, 2020
6275b9c
Test for weight check
shawntabrizi Jun 15, 2020
5c9a7af
Merge branch 'master' into gav-multisig-stored-call
shawntabrizi Jun 15, 2020
81195da
Fix line width
shawntabrizi Jun 15, 2020
7a75cf7
one more line width error
shawntabrizi Jun 15, 2020
9dd0585
Apply suggestions from code review
shawntabrizi Jun 15, 2020
7af9a83
Merge branch 'master' into gav-multisig-stored-call
shawntabrizi Jun 15, 2020
f64e26d
fix merge
shawntabrizi Jun 15, 2020
9becf6e
more @apopiak feedback
shawntabrizi Jun 15, 2020
5bd6514
Multisig handles no preimage
shawntabrizi Jun 16, 2020
5cc17da
Optimize return weight after dispatch
shawntabrizi Jun 16, 2020
a053de8
Merge remote-tracking branch 'origin/master' into gav-multisig-stored…
gavofyork Jun 16, 2020
9e2d5b6
Error on failed deposit.
gavofyork Jun 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more @apopiak feedback
  • Loading branch information
shawntabrizi committed Jun 15, 2020
commit 9becf6e98e4c05a4d59bc11f7d3d207b90fa1ba5
14 changes: 7 additions & 7 deletions frame/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use frame_support::{traits::{Get, ReservableCurrency, Currency},
weights::{Weight, GetDispatchInfo, constants::{WEIGHT_PER_NANOS, WEIGHT_PER_MICROS}},
dispatch::{DispatchResultWithPostInfo, DispatchErrorWithPostInfo, PostDispatchInfo},
};
use frame_system::{self as system, ensure_signed};
use frame_system::{self as system, ensure_signed, RawOrigin};
use sp_runtime::{DispatchError, DispatchResult, traits::Dispatchable};

mod tests;
Expand Down Expand Up @@ -128,8 +128,8 @@ decl_storage! {

decl_error! {
pub enum Error for Module<T: Trait> {
/// Threshold is too low (zero).
ZeroThreshold,
/// Threshold must be 2 or greater.
MinimumThreshold,
/// Call is already approved by this signatory.
AlreadyApproved,
/// Call doesn't need any (more) approvals.
Expand Down Expand Up @@ -282,7 +282,7 @@ decl_module! {
let id = Self::multi_account_id(&signatories, 1);

let call_len = call.using_encoded(|c| c.len());
let result = call.dispatch(frame_system::RawOrigin::Signed(id.clone()).into());
let result = call.dispatch(RawOrigin::Signed(id.clone()).into());

result.map(|post_dispatch_info| post_dispatch_info.actual_weight
.map(|actual_weight| weight_of::as_multi_threshold_1::<T>(
Expand Down Expand Up @@ -469,7 +469,7 @@ decl_module! {
call_hash: [u8; 32],
) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure!(threshold >= 2, Error::<T>::ZeroThreshold);
ensure!(threshold >= 2, Error::<T>::MinimumThreshold);
let max_sigs = T::MaxSignatories::get() as usize;
ensure!(!other_signatories.is_empty(), Error::<T>::TooFewSignatories);
ensure!(other_signatories.len() < max_sigs, Error::<T>::TooManySignatories);
Expand Down Expand Up @@ -510,7 +510,7 @@ impl<T: Trait> Module<T> {
call_or_hash: CallOrHash,
max_weight: Weight,
) -> DispatchResultWithPostInfo {
ensure!(threshold >= 2, Error::<T>::ZeroThreshold);
ensure!(threshold >= 2, Error::<T>::MinimumThreshold);
let max_sigs = T::MaxSignatories::get() as usize;
ensure!(!other_signatories.is_empty(), Error::<T>::TooFewSignatories);
let other_signatories_len = other_signatories.len();
Expand Down Expand Up @@ -551,7 +551,7 @@ impl<T: Trait> Module<T> {
// verify weight
ensure!(call.get_dispatch_info().weight <= max_weight, Error::<T>::WeightTooLow);

let result = call.dispatch(frame_system::RawOrigin::Signed(id.clone()).into());
let result = call.dispatch(RawOrigin::Signed(id.clone()).into());
let _ = T::Currency::unreserve(&m.depositor, m.deposit);
<Multisigs<T>>::remove(&id, call_hash);
Self::clear_call(&call_hash);
Expand Down
16 changes: 10 additions & 6 deletions frame/multisig/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,16 @@ fn multisig_2_of_3_cannot_reissue_same_call() {
}

#[test]
fn zero_threshold_fails() {
fn minimum_threshold_check_works() {
new_test_ext().execute_with(|| {
let call = Call::Balances(BalancesCall::transfer(6, 15)).encode();
assert_noop!(
Multisig::as_multi(Origin::signed(1), 0, vec![2], None, call, false, 0),
Error::<Test>::ZeroThreshold,
Multisig::as_multi(Origin::signed(1), 0, vec![2], None, call.clone(), false, 0),
Error::<Test>::MinimumThreshold,
);
assert_noop!(
Multisig::as_multi(Origin::signed(1), 1, vec![2], None, call.clone(), false, 0),
Error::<Test>::MinimumThreshold,
);
});
}
Expand Down Expand Up @@ -501,11 +505,11 @@ fn multisig_1_of_3_works() {
let hash = blake2_256(&call);
assert_noop!(
Multisig::approve_as_multi(Origin::signed(1), 1, vec![2, 3], None, hash.clone(), 0),
Error::<Test>::ZeroThreshold,
Error::<Test>::MinimumThreshold,
);
assert_noop!(
Multisig::as_multi(Origin::signed(4), 1, vec![2, 3], None, call.clone(), false, 0),
Error::<Test>::ZeroThreshold,
Multisig::as_multi(Origin::signed(1), 1, vec![2, 3], None, call.clone(), false, 0),
Error::<Test>::MinimumThreshold,
);
let boxed_call = Box::new(Call::Balances(BalancesCall::transfer(6, 15)));
assert_ok!(Multisig::as_multi_threshold_1(Origin::signed(1), vec![2, 3], boxed_call));
Expand Down