Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiry time for MultiSig calls #1281

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
be96656
Expiry time for MultiSig calls
Szegoo Aug 29, 2023
0d8a934
Merge branch 'master' into multisig-expiry
Szegoo Aug 29, 2023
ec70023
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
07dec63
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
9a1a619
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
cf140f0
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
6882821
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
5a99f94
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
8667b20
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
76cf971
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
9ea8802
Update substrate/frame/multisig/src/tests.rs
Szegoo Aug 31, 2023
ceb81f1
Update substrate/frame/multisig/src/tests.rs
Szegoo Aug 31, 2023
c3da879
Update substrate/frame/multisig/src/lib.rs
Szegoo Aug 31, 2023
5151675
update MultisigCancelled event & update complexity
Szegoo Aug 31, 2023
c4350c1
Update substrate/frame/multisig/src/lib.rs
Szegoo Sep 4, 2023
ddf7291
Merge branch 'master' into multisig-expiry
Szegoo Sep 4, 2023
6bc178e
Update substrate/frame/multisig/src/lib.rs
Szegoo Sep 4, 2023
7327b82
update docs & fmt
Szegoo Sep 4, 2023
e124f70
use H256 instead of [u8; 32]
Szegoo Sep 5, 2023
cce5220
more replacement & use if instead of match
Szegoo Sep 5, 2023
72d6ffe
fix?
Szegoo Sep 5, 2023
3ce4657
..
Szegoo Sep 5, 2023
f37ae10
Merge branch 'master' into multisig-expiry
Szegoo Sep 10, 2023
08bdcf0
Update substrate/frame/multisig/src/lib.rs
Szegoo Sep 11, 2023
e44881c
Update substrate/frame/multisig/src/lib.rs
Szegoo Sep 11, 2023
8b66b8c
Update substrate/frame/multisig/src/lib.rs
Szegoo Sep 11, 2023
9dfe2ee
Update substrate/frame/multisig/src/tests.rs
Szegoo Sep 11, 2023
5ca7fc3
Update substrate/frame/multisig/src/tests.rs
Szegoo Sep 11, 2023
2a8e6bd
Merge branch 'master' into multisig-expiry
Szegoo Sep 24, 2023
0471c6e
Merge branch 'paritytech:master' into multisig-expiry
Szegoo Sep 28, 2023
6b49409
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Sep 28, 2023
dfe2e73
use the proper weight function
Szegoo Sep 28, 2023
8d58acf
Merge branch 'master' into multisig-expiry
Szegoo Oct 2, 2023
457d195
Merge branch 'paritytech:master' into multisig-expiry
Szegoo Oct 12, 2023
3e1eec9
add clear_expired_multi function to weight files
Szegoo Oct 16, 2023
3e47150
Merge branch 'master' into multisig-expiry
Szegoo Oct 17, 2023
9782b4f
".git/.scripts/commands/bench/bench.sh" --subcommand=runtime --runtim…
Oct 17, 2023
7b28274
fix warning
Szegoo Oct 17, 2023
a2b7c9c
Merge branch 'master' into multisig-expiry
franciscoaguirre Nov 13, 2023
2970d27
fix
Szegoo Nov 13, 2023
44b3372
warning fix
Szegoo Nov 14, 2023
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
35 changes: 31 additions & 4 deletions substrate/frame/multisig/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use super::*;
use frame_benchmarking::v1::{account, benchmarks};
use frame_system::RawOrigin;
use frame_system::{Pallet as System, RawOrigin};
use sp_runtime::traits::Bounded;

use crate::Pallet as Multisig;
Expand Down Expand Up @@ -152,7 +152,7 @@ benchmarks! {
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
// Create the multi
}: approve_as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call_hash, Weight::zero())
}: approve_as_multi(RawOrigin::Signed(caller), s as u16, signatories, None, call_hash, Weight::zero(), Some(42u32.into()))
verify {
assert!(Multisigs::<T>::contains_key(multi_account_id, call_hash));
}
Expand Down Expand Up @@ -182,7 +182,7 @@ benchmarks! {
// Whitelist caller account from further DB operations.
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller2);
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
}: approve_as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call_hash, Weight::zero())
}: approve_as_multi(RawOrigin::Signed(caller2), s as u16, signatories2, Some(timepoint), call_hash, Weight::zero(), None)
verify {
let multisig = Multisigs::<T>::get(multi_account_id, call_hash).ok_or("multisig not created")?;
assert_eq!(multisig.approvals.len(), 2);
Expand Down Expand Up @@ -210,5 +210,32 @@ benchmarks! {
assert!(!Multisigs::<T>::contains_key(multi_account_id, call_hash));
}

impl_benchmark_test_suite!(Multisig, crate::tests::new_test_ext(), crate::tests::Test);
clear_expired_multi {
// Signatories, need at least 2 people
let s in 2 .. T::MaxSignatories::get();
// Transaction Length, not a component
let z = 10_000;
let (mut signatories, call) = setup_multi::<T>(s, z)?;
let multi_account_id = Multisig::<T>::multi_account_id(&signatories, s.try_into().unwrap());
let caller = signatories.pop().ok_or("signatories should have len 2 or more")?;
let call_hash = call.using_encoded(blake2_256);
let timepoint = Multisig::<T>::timepoint();
// Create the multi
let o = RawOrigin::Signed(caller.clone()).into();
Multisig::<T>::approve_as_multi(o, s as u16, signatories.clone(), None, call_hash, Weight::zero(), Some(3u32.into()))?;
assert!(Multisigs::<T>::contains_key(&multi_account_id, call_hash));
// Multisig expires after block 3 so we proceed to block 4.
System::<T>::set_block_number(4u32.into());
// Whitelist caller account from further DB operations.
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
// For calling clear_expired_multi all the signatories must be specified.
signatories.push(caller.clone());
}: _(RawOrigin::Signed(caller), s as u16, signatories, timepoint, call_hash)
verify {
assert!(!Multisigs::<T>::contains_key(multi_account_id.clone(), call_hash));
assert!(!MultisigExpiries::<T>::contains_key(multi_account_id, call_hash));
}

impl_benchmark_test_suite!(Multisig, crate::tests::ExtBuilder::default().build(), crate::tests::Test);
}
Loading