Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit c620450

Browse files
kianenigmaBustaNit
andauthored
add fast-unstsake pallet to all runtimes (#6050)
* add fast-unstsake pallet to all runtimes * ".git/.scripts/fmt.sh" 1 * ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_fast_unstake * ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_fast_unstake * fix up all the weight stuff * update substrate * update mistake in kusama * add stub file * Update runtime/polkadot/src/lib.rs Co-authored-by: Nitwit <[email protected]> * Update runtime/westend/src/lib.rs Co-authored-by: Nitwit <[email protected]> * cargo update -p sp-io * add signed extension as well * Revert "add signed extension as well" This reverts commit deb936f. * cargo update -p sp-io * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_fast_unstake * ".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_fast_unstake * update sub * integrate latest substrate changes * ".git/.scripts/fmt.sh" 1 * ".git/.scripts/bench-bot.sh" runtime westend-dev pallet_fast_unstake Co-authored-by: command-bot <> Co-authored-by: Nitwit <[email protected]>
1 parent 1cbab5a commit c620450

File tree

13 files changed

+614
-180
lines changed

13 files changed

+614
-180
lines changed

Cargo.lock

Lines changed: 197 additions & 173 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/kusama/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pallet-collective = { git = "https://github.com/paritytech/substrate", branch =
5050
pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5151
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5252
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
53+
pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5354
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5455
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5556
pallet-gilt = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -143,6 +144,7 @@ std = [
143144
"pallet-collective/std",
144145
"pallet-elections-phragmen/std",
145146
"pallet-election-provider-multi-phase/std",
147+
"pallet-fast-unstake/std",
146148
"pallet-democracy/std",
147149
"pallet-gilt/std",
148150
"pallet-grandpa/std",
@@ -206,6 +208,7 @@ runtime-benchmarks = [
206208
"pallet-elections-phragmen/runtime-benchmarks",
207209
"pallet-election-provider-multi-phase/runtime-benchmarks",
208210
"pallet-election-provider-support-benchmarking/runtime-benchmarks",
211+
"pallet-fast-unstake/runtime-benchmarks",
209212
"pallet-gilt/runtime-benchmarks",
210213
"pallet-grandpa/runtime-benchmarks",
211214
"pallet-identity/runtime-benchmarks",
@@ -251,6 +254,7 @@ try-runtime = [
251254
"pallet-collective/try-runtime",
252255
"pallet-elections-phragmen/try-runtime",
253256
"pallet-election-provider-multi-phase/try-runtime",
257+
"pallet-fast-unstake/try-runtime",
254258
"pallet-democracy/try-runtime",
255259
"pallet-gilt/try-runtime",
256260
"pallet-grandpa/try-runtime",

runtime/kusama/src/lib.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,17 @@ impl pallet_staking::Config for Runtime {
621621
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
622622
}
623623

624+
impl pallet_fast_unstake::Config for Runtime {
625+
type RuntimeEvent = RuntimeEvent;
626+
type DepositCurrency = Balances;
627+
type Deposit = frame_support::traits::ConstU128<{ CENTS * 100 }>;
628+
type ControlOrigin = EitherOfDiverse<
629+
EnsureRoot<AccountId>,
630+
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
631+
>;
632+
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
633+
}
634+
624635
parameter_types! {
625636
pub const ProposalBond: Permill = Permill::from_percent(5);
626637
pub const ProposalBondMinimum: Balance = 2000 * CENTS;
@@ -1045,7 +1056,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
10451056
RuntimeCall::Slots(..) |
10461057
RuntimeCall::Auctions(..) | // Specifically omitting the entire XCM Pallet
10471058
RuntimeCall::VoterList(..) |
1048-
RuntimeCall::NominationPools(..)
1059+
RuntimeCall::NominationPools(..) |
1060+
RuntimeCall::FastUnstake(..)
10491061
),
10501062
ProxyType::Governance =>
10511063
matches!(
@@ -1061,7 +1073,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
10611073
ProxyType::Staking => {
10621074
matches!(
10631075
c,
1064-
RuntimeCall::Staking(..) | RuntimeCall::Session(..) | RuntimeCall::Utility(..)
1076+
RuntimeCall::Staking(..) |
1077+
RuntimeCall::Session(..) | RuntimeCall::Utility(..) |
1078+
RuntimeCall::FastUnstake(..)
10651079
)
10661080
},
10671081
ProxyType::IdentityJudgement => matches!(
@@ -1389,6 +1403,9 @@ construct_runtime! {
13891403
// nomination pools: extension to staking.
13901404
NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event<T>, Config<T>} = 41,
13911405

1406+
// Fast unstake pallet: extension to staking.
1407+
FastUnstake: pallet_fast_unstake = 42,
1408+
13921409
// Parachains pallets. Start indices at 50 to leave room.
13931410
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50,
13941411
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 51,
@@ -1500,6 +1517,7 @@ mod benches {
15001517
[pallet_elections_phragmen, PhragmenElection]
15011518
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
15021519
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
1520+
[pallet_fast_unstake, FastUnstake]
15031521
[pallet_gilt, Gilt]
15041522
[pallet_identity, Identity]
15051523
[pallet_im_online, ImOnline]

runtime/kusama/src/weights/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub mod pallet_collective_technical_committee;
2626
pub mod pallet_democracy;
2727
pub mod pallet_election_provider_multi_phase;
2828
pub mod pallet_elections_phragmen;
29+
pub mod pallet_fast_unstake;
2930
pub mod pallet_gilt;
3031
pub mod pallet_identity;
3132
pub mod pallet_im_online;
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
2+
// This file is part of Polkadot.
3+
4+
// Polkadot is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Polkadot is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16+
//! Autogenerated weights for `pallet_fast_unstake`
17+
//!
18+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
19+
//! DATE: 2022-09-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
20+
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
21+
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024
22+
23+
// Executed Command:
24+
// /home/benchbot/cargo_target_dir/production/polkadot
25+
// benchmark
26+
// pallet
27+
// --steps=50
28+
// --repeat=20
29+
// --extrinsic=*
30+
// --execution=wasm
31+
// --wasm-execution=compiled
32+
// --heap-pages=4096
33+
// --pallet=pallet_fast_unstake
34+
// --chain=kusama-dev
35+
// --header=./file_header.txt
36+
// --output=./runtime/kusama/src/weights/
37+
38+
#![cfg_attr(rustfmt, rustfmt_skip)]
39+
#![allow(unused_parens)]
40+
#![allow(unused_imports)]
41+
42+
use frame_support::{traits::Get, weights::Weight};
43+
use sp_std::marker::PhantomData;
44+
45+
/// Weight functions for `pallet_fast_unstake`.
46+
pub struct WeightInfo<T>(PhantomData<T>);
47+
impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T> {
48+
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
49+
// Storage: Staking ValidatorCount (r:1 w:0)
50+
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
51+
// Storage: FastUnstake Head (r:1 w:1)
52+
// Storage: Staking CurrentEra (r:1 w:0)
53+
// Storage: Staking SlashingSpans (r:1 w:0)
54+
// Storage: Staking Bonded (r:1 w:1)
55+
// Storage: Staking Validators (r:1 w:0)
56+
// Storage: Staking Nominators (r:1 w:0)
57+
// Storage: System Account (r:1 w:1)
58+
// Storage: Balances Locks (r:1 w:1)
59+
// Storage: Staking Ledger (r:0 w:1)
60+
// Storage: Staking Payee (r:0 w:1)
61+
fn on_idle_unstake() -> Weight {
62+
Weight::from_ref_time(64_798_000 as u64)
63+
.saturating_add(T::DbWeight::get().reads(11 as u64))
64+
.saturating_add(T::DbWeight::get().writes(6 as u64))
65+
}
66+
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
67+
// Storage: Staking ValidatorCount (r:1 w:0)
68+
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
69+
// Storage: FastUnstake Head (r:1 w:1)
70+
// Storage: FastUnstake Queue (r:2 w:1)
71+
// Storage: FastUnstake CounterForQueue (r:1 w:1)
72+
// Storage: Staking CurrentEra (r:1 w:0)
73+
// Storage: Staking ErasStakers (r:56 w:0)
74+
/// The range of component `x` is `[28, 3584]`.
75+
fn on_idle_check(x: u32, ) -> Weight {
76+
Weight::from_ref_time(412_389_000 as u64)
77+
// Standard Error: 10_902
78+
.saturating_add(Weight::from_ref_time(10_950_753 as u64).saturating_mul(x as u64))
79+
.saturating_add(T::DbWeight::get().reads(64 as u64))
80+
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64)))
81+
.saturating_add(T::DbWeight::get().writes(3 as u64))
82+
}
83+
// Storage: Staking Ledger (r:1 w:1)
84+
// Storage: FastUnstake Queue (r:1 w:1)
85+
// Storage: FastUnstake Head (r:1 w:0)
86+
// Storage: Staking Validators (r:1 w:0)
87+
// Storage: Staking Nominators (r:1 w:1)
88+
// Storage: Staking CounterForNominators (r:1 w:1)
89+
// Storage: VoterList ListNodes (r:1 w:1)
90+
// Storage: VoterList ListBags (r:1 w:1)
91+
// Storage: VoterList CounterForListNodes (r:1 w:1)
92+
// Storage: Staking CurrentEra (r:1 w:0)
93+
// Storage: Balances Locks (r:1 w:1)
94+
// Storage: FastUnstake CounterForQueue (r:1 w:1)
95+
fn register_fast_unstake() -> Weight {
96+
Weight::from_ref_time(84_738_000 as u64)
97+
.saturating_add(T::DbWeight::get().reads(12 as u64))
98+
.saturating_add(T::DbWeight::get().writes(9 as u64))
99+
}
100+
// Storage: Staking Ledger (r:1 w:0)
101+
// Storage: FastUnstake Queue (r:1 w:1)
102+
// Storage: FastUnstake Head (r:1 w:0)
103+
// Storage: FastUnstake CounterForQueue (r:1 w:1)
104+
fn deregister() -> Weight {
105+
Weight::from_ref_time(23_369_000 as u64)
106+
.saturating_add(T::DbWeight::get().reads(4 as u64))
107+
.saturating_add(T::DbWeight::get().writes(2 as u64))
108+
}
109+
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
110+
fn control() -> Weight {
111+
Weight::from_ref_time(3_991_000 as u64)
112+
.saturating_add(T::DbWeight::get().writes(1 as u64))
113+
}
114+
}

runtime/polkadot/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pallet-collective = { git = "https://github.com/paritytech/substrate", branch =
4747
pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
4848
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
4949
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
50+
pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5051
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5152
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5253
pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -139,6 +140,7 @@ std = [
139140
"pallet-elections-phragmen/std",
140141
"pallet-election-provider-multi-phase/std",
141142
"pallet-democracy/std",
143+
"pallet-fast-unstake/std",
142144
"pallet-grandpa/std",
143145
"pallet-identity/std",
144146
"pallet-im-online/std",
@@ -194,6 +196,7 @@ runtime-benchmarks = [
194196
"pallet-elections-phragmen/runtime-benchmarks",
195197
"pallet-election-provider-multi-phase/runtime-benchmarks",
196198
"pallet-election-provider-support-benchmarking/runtime-benchmarks",
199+
"pallet-fast-unstake/runtime-benchmarks",
197200
"pallet-grandpa/runtime-benchmarks",
198201
"pallet-identity/runtime-benchmarks",
199202
"pallet-im-online/runtime-benchmarks",
@@ -237,6 +240,7 @@ try-runtime = [
237240
"pallet-collective/try-runtime",
238241
"pallet-elections-phragmen/try-runtime",
239242
"pallet-election-provider-multi-phase/try-runtime",
243+
"pallet-fast-unstake/try-runtime",
240244
"pallet-democracy/try-runtime",
241245
"pallet-grandpa/try-runtime",
242246
"pallet-identity/try-runtime",

runtime/polkadot/src/lib.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,17 @@ impl pallet_staking::Config for Runtime {
566566
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
567567
}
568568

569+
impl pallet_fast_unstake::Config for Runtime {
570+
type RuntimeEvent = RuntimeEvent;
571+
type DepositCurrency = Balances;
572+
type Deposit = frame_support::traits::ConstU128<{ UNITS }>;
573+
type ControlOrigin = EitherOfDiverse<
574+
EnsureRoot<AccountId>,
575+
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
576+
>;
577+
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
578+
}
579+
569580
parameter_types! {
570581
// Minimum 4 CENTS/byte
571582
pub const BasicDeposit: Balance = deposit(1, 258);
@@ -1133,7 +1144,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
11331144
RuntimeCall::Slots(..) |
11341145
RuntimeCall::Auctions(..) | // Specifically omitting the entire XCM Pallet
11351146
RuntimeCall::VoterList(..) |
1136-
RuntimeCall::NominationPools(..)
1147+
RuntimeCall::NominationPools(..) |
1148+
RuntimeCall::FastUnstake(..)
11371149
),
11381150
ProxyType::Governance =>
11391151
matches!(
@@ -1149,7 +1161,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
11491161
ProxyType::Staking => {
11501162
matches!(
11511163
c,
1152-
RuntimeCall::Staking(..) | RuntimeCall::Session(..) | RuntimeCall::Utility(..)
1164+
RuntimeCall::Staking(..) |
1165+
RuntimeCall::Session(..) | RuntimeCall::Utility(..) |
1166+
RuntimeCall::FastUnstake(..)
11531167
)
11541168
},
11551169
ProxyType::IdentityJudgement => matches!(
@@ -1467,9 +1481,12 @@ construct_runtime! {
14671481
// Provides a semi-sorted list of nominators for staking.
14681482
VoterList: pallet_bags_list::<Instance1>::{Pallet, Call, Storage, Event<T>} = 37,
14691483

1470-
// nomination pools: extension to staking.
1484+
// Nomination pools: extension to staking.
14711485
NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event<T>, Config<T>} = 39,
14721486

1487+
// Fast unstake pallet: extension to staking.
1488+
FastUnstake: pallet_fast_unstake = 40,
1489+
14731490
// Parachains pallets. Start indices at 50 to leave room.
14741491
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50,
14751492
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 51,
@@ -1582,6 +1599,7 @@ mod benches {
15821599
[pallet_elections_phragmen, PhragmenElection]
15831600
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
15841601
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
1602+
[pallet_fast_unstake, FastUnstake]
15851603
[pallet_identity, Identity]
15861604
[pallet_im_online, ImOnline]
15871605
[pallet_indices, Indices]

runtime/polkadot/src/weights/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub mod pallet_collective_technical_committee;
2626
pub mod pallet_democracy;
2727
pub mod pallet_election_provider_multi_phase;
2828
pub mod pallet_elections_phragmen;
29+
pub mod pallet_fast_unstake;
2930
pub mod pallet_identity;
3031
pub mod pallet_im_online;
3132
pub mod pallet_indices;

0 commit comments

Comments
 (0)