mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
Bound uses of Call (#11649)
* Introduce preimages module in traits * Multisize Preimages * Len not actually necessary * Tweaks to the preimage API * Fixes * Get Scheduler building with new API * Scheduler tests pass * Bounded Scheduler 🎉 * Use Agenda holes and introduce IncompleteSince to avoid need to reschedule * Tests pass with new weight system * New benchmarks * Add missing file * Drop preimage when permenantly overeight * Drop preimage when permenantly overeight * Referenda uses latest preimage API * Testing ok * Adding tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add preimage migration Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Docs * Remove dbg * Refactor Democracy * Refactor Democracy * Add final MEL * Remove silly maps * Fixes * Minor refactor * Formatting * Fixes * Fixes * Fixes * Update frame/preimage/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Add migrations to Democracy * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Resolve conflicts Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Resolve conflicts" This reverts commit 734d66d69e54553471ffa54fa52e3e304dc8f106. * Undo wrong resolves... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * WIP Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make compile Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * massage clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy annoyance Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy annoyance Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * add missing file * Test <Preimage as QueryPreimage> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy harassment Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixup tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove old stuff Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test <Scheduler as Anon> trait functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update pallet-ui tests Why is this needed? Should not be the case unless master is broken... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More scheduler trait test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Apply review suggestion Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Beauty fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add Scheduler test migration_v3_to_v4_works Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Merge fixup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Keep referenda benchmarks instantiatable Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new scheduler weight functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new democracy weight functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use weight compare functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update pallet-ui tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More renaming… Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * More renaming… Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add comment Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Implement OnRuntimeUpgrade for scheduler::v3_to_v4 migration Put the migration into a proper `MigrateToV4` struct and implement the OnRuntimeUpgrade hooks for it. Also move the test to use that instead. This should make it easier for adding it to Polkadot. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Handle undecodable Agendas Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove trash Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new OnRuntimeUpgrade functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fix test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix BoundedSlice::truncate_from Co-authored-by: jakoblell Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix pre_upgrade hook return values Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add more error logging Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Find too large preimages in the pre_upgrade hook Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test that too large Calls in agendas are ignored Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use new OnRuntimeUpgrade hooks Why did the CI not catch this?! Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * works fine - just more logs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix staking migration Causing issues on Kusama... Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix UI tests No idea why this is needed. This is actually undoing an earlier change. Maybe the CI has different rustc versions!? Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove multisig's Calls (#12072) * Remove multisig's Calls * Multisig: Fix tests and re-introduce reserve logic (#12241) * Fix tests and re-introduce reserve logic * fix benches * add todo * remove irrelevant bench * [Feature] Add a migration that drains and refunds stored calls (#12313) * [Feature] Add a migration that drains and refunds stored calls * migration fixes * fixes * address review comments * consume the whole block weight * fix assertions * license header * fix interface Co-authored-by: parity-processbot <> Co-authored-by: parity-processbot <> Co-authored-by: Roman Useinov <roman.useinov@gmail.com> * Fix test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix multisig benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/bench-bot.sh" pallet dev pallet_democracy * ".git/.scripts/bench-bot.sh" pallet dev pallet_scheduler * ".git/.scripts/bench-bot.sh" pallet dev pallet_preimage Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: parity-processbot <> Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
This commit is contained in:
@@ -23,35 +23,29 @@ use super::*;
|
||||
fn veto_external_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),));
|
||||
assert!(<NextExternal<Test>>::exists());
|
||||
|
||||
let h = set_balance_proposal_hash_and_note(2);
|
||||
let h = set_balance_proposal(2).hash();
|
||||
assert_ok!(Democracy::veto_external(RuntimeOrigin::signed(3), h));
|
||||
// cancelled.
|
||||
assert!(!<NextExternal<Test>>::exists());
|
||||
// fails - same proposal can't be resubmitted.
|
||||
assert_noop!(
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),),
|
||||
Error::<Test>::ProposalBlacklisted
|
||||
);
|
||||
|
||||
fast_forward_to(1);
|
||||
// fails as we're still in cooloff period.
|
||||
assert_noop!(
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),),
|
||||
Error::<Test>::ProposalBlacklisted
|
||||
);
|
||||
|
||||
fast_forward_to(2);
|
||||
// works; as we're out of the cooloff period.
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),));
|
||||
assert!(<NextExternal<Test>>::exists());
|
||||
|
||||
// 3 can't veto the same thing twice.
|
||||
@@ -68,14 +62,11 @@ fn veto_external_works() {
|
||||
fast_forward_to(3);
|
||||
// same proposal fails as we're still in cooloff
|
||||
assert_noop!(
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2)),
|
||||
Error::<Test>::ProposalBlacklisted
|
||||
);
|
||||
// different proposal works fine.
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(3),
|
||||
));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(3),));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,22 +75,16 @@ fn external_blacklisting_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),));
|
||||
|
||||
let hash = set_balance_proposal_hash(2);
|
||||
let hash = set_balance_proposal(2).hash();
|
||||
assert_ok!(Democracy::blacklist(RuntimeOrigin::root(), hash, None));
|
||||
|
||||
fast_forward_to(2);
|
||||
assert_noop!(Democracy::referendum_status(0), Error::<Test>::ReferendumInvalid);
|
||||
|
||||
assert_noop!(
|
||||
Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2)),
|
||||
Error::<Test>::ProposalBlacklisted,
|
||||
);
|
||||
});
|
||||
@@ -110,15 +95,12 @@ fn external_referendum_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_noop!(
|
||||
Democracy::external_propose(RuntimeOrigin::signed(1), set_balance_proposal_hash(2),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(1), set_balance_proposal(2),),
|
||||
BadOrigin,
|
||||
);
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(2),
|
||||
));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),));
|
||||
assert_noop!(
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal_hash(1),),
|
||||
Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(1),),
|
||||
Error::<Test>::DuplicateProposal
|
||||
);
|
||||
fast_forward_to(2);
|
||||
@@ -126,7 +108,7 @@ fn external_referendum_works() {
|
||||
Democracy::referendum_status(0),
|
||||
Ok(ReferendumStatus {
|
||||
end: 4,
|
||||
proposal_hash: set_balance_proposal_hash(2),
|
||||
proposal: set_balance_proposal(2),
|
||||
threshold: VoteThreshold::SuperMajorityApprove,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
@@ -140,22 +122,19 @@ fn external_majority_referendum_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_noop!(
|
||||
Democracy::external_propose_majority(
|
||||
RuntimeOrigin::signed(1),
|
||||
set_balance_proposal_hash(2)
|
||||
),
|
||||
Democracy::external_propose_majority(RuntimeOrigin::signed(1), set_balance_proposal(2)),
|
||||
BadOrigin,
|
||||
);
|
||||
assert_ok!(Democracy::external_propose_majority(
|
||||
RuntimeOrigin::signed(3),
|
||||
set_balance_proposal_hash_and_note(2)
|
||||
set_balance_proposal(2)
|
||||
));
|
||||
fast_forward_to(2);
|
||||
assert_eq!(
|
||||
Democracy::referendum_status(0),
|
||||
Ok(ReferendumStatus {
|
||||
end: 4,
|
||||
proposal_hash: set_balance_proposal_hash(2),
|
||||
proposal: set_balance_proposal(2),
|
||||
threshold: VoteThreshold::SimpleMajority,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
@@ -169,22 +148,19 @@ fn external_default_referendum_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_noop!(
|
||||
Democracy::external_propose_default(
|
||||
RuntimeOrigin::signed(3),
|
||||
set_balance_proposal_hash(2)
|
||||
),
|
||||
Democracy::external_propose_default(RuntimeOrigin::signed(3), set_balance_proposal(2)),
|
||||
BadOrigin,
|
||||
);
|
||||
assert_ok!(Democracy::external_propose_default(
|
||||
RuntimeOrigin::signed(1),
|
||||
set_balance_proposal_hash_and_note(2)
|
||||
set_balance_proposal(2)
|
||||
));
|
||||
fast_forward_to(2);
|
||||
assert_eq!(
|
||||
Democracy::referendum_status(0),
|
||||
Ok(ReferendumStatus {
|
||||
end: 4,
|
||||
proposal_hash: set_balance_proposal_hash(2),
|
||||
proposal: set_balance_proposal(2),
|
||||
threshold: VoteThreshold::SuperMajorityAgainst,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
@@ -197,11 +173,8 @@ fn external_default_referendum_works() {
|
||||
fn external_and_public_interleaving_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(0);
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(1),
|
||||
));
|
||||
assert_ok!(propose_set_balance_and_note(6, 2, 2));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(1),));
|
||||
assert_ok!(propose_set_balance(6, 2, 2));
|
||||
|
||||
fast_forward_to(2);
|
||||
|
||||
@@ -210,17 +183,14 @@ fn external_and_public_interleaving_works() {
|
||||
Democracy::referendum_status(0),
|
||||
Ok(ReferendumStatus {
|
||||
end: 4,
|
||||
proposal_hash: set_balance_proposal_hash_and_note(1),
|
||||
proposal: set_balance_proposal(1),
|
||||
threshold: VoteThreshold::SuperMajorityApprove,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
})
|
||||
);
|
||||
// replenish external
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(3),
|
||||
));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(3),));
|
||||
|
||||
fast_forward_to(4);
|
||||
|
||||
@@ -229,7 +199,7 @@ fn external_and_public_interleaving_works() {
|
||||
Democracy::referendum_status(1),
|
||||
Ok(ReferendumStatus {
|
||||
end: 6,
|
||||
proposal_hash: set_balance_proposal_hash_and_note(2),
|
||||
proposal: set_balance_proposal(2),
|
||||
threshold: VoteThreshold::SuperMajorityApprove,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
@@ -244,17 +214,14 @@ fn external_and_public_interleaving_works() {
|
||||
Democracy::referendum_status(2),
|
||||
Ok(ReferendumStatus {
|
||||
end: 8,
|
||||
proposal_hash: set_balance_proposal_hash_and_note(3),
|
||||
proposal: set_balance_proposal(3),
|
||||
threshold: VoteThreshold::SuperMajorityApprove,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
})
|
||||
);
|
||||
// replenish external
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(5),
|
||||
));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(5),));
|
||||
|
||||
fast_forward_to(8);
|
||||
|
||||
@@ -263,18 +230,15 @@ fn external_and_public_interleaving_works() {
|
||||
Democracy::referendum_status(3),
|
||||
Ok(ReferendumStatus {
|
||||
end: 10,
|
||||
proposal_hash: set_balance_proposal_hash_and_note(5),
|
||||
proposal: set_balance_proposal(5),
|
||||
threshold: VoteThreshold::SuperMajorityApprove,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
})
|
||||
);
|
||||
// replenish both
|
||||
assert_ok!(Democracy::external_propose(
|
||||
RuntimeOrigin::signed(2),
|
||||
set_balance_proposal_hash_and_note(7),
|
||||
));
|
||||
assert_ok!(propose_set_balance_and_note(6, 4, 2));
|
||||
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(7),));
|
||||
assert_ok!(propose_set_balance(6, 4, 2));
|
||||
|
||||
fast_forward_to(10);
|
||||
|
||||
@@ -283,16 +247,16 @@ fn external_and_public_interleaving_works() {
|
||||
Democracy::referendum_status(4),
|
||||
Ok(ReferendumStatus {
|
||||
end: 12,
|
||||
proposal_hash: set_balance_proposal_hash_and_note(4),
|
||||
proposal: set_balance_proposal(4),
|
||||
threshold: VoteThreshold::SuperMajorityApprove,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
})
|
||||
);
|
||||
// replenish public again
|
||||
assert_ok!(propose_set_balance_and_note(6, 6, 2));
|
||||
assert_ok!(propose_set_balance(6, 6, 2));
|
||||
// cancel external
|
||||
let h = set_balance_proposal_hash_and_note(7);
|
||||
let h = set_balance_proposal(7).hash();
|
||||
assert_ok!(Democracy::veto_external(RuntimeOrigin::signed(3), h));
|
||||
|
||||
fast_forward_to(12);
|
||||
@@ -302,7 +266,7 @@ fn external_and_public_interleaving_works() {
|
||||
Democracy::referendum_status(5),
|
||||
Ok(ReferendumStatus {
|
||||
end: 14,
|
||||
proposal_hash: set_balance_proposal_hash_and_note(6),
|
||||
proposal: set_balance_proposal(6),
|
||||
threshold: VoteThreshold::SuperMajorityApprove,
|
||||
delay: 2,
|
||||
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
|
||||
|
||||
Reference in New Issue
Block a user