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

add fast-unstsake pallet to all runtimes #6050

Merged
merged 25 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
609dea4
add fast-unstsake pallet to all runtimes
kianenigma Sep 25, 2022
86e8447
".git/.scripts/fmt.sh" 1
Sep 25, 2022
5570416
".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_fast_unstake
Sep 25, 2022
6717883
".git/.scripts/bench-bot.sh" runtime westend-dev pallet_fast_unstake
Sep 26, 2022
205b28d
fix up all the weight stuff
kianenigma Sep 26, 2022
8d6509e
update substrate
kianenigma Sep 26, 2022
85d0a35
update mistake in kusama
kianenigma Sep 26, 2022
22cbceb
add stub file
kianenigma Sep 26, 2022
55849d7
Update runtime/polkadot/src/lib.rs
kianenigma Sep 26, 2022
c2a89f8
Update runtime/westend/src/lib.rs
kianenigma Sep 26, 2022
60842bc
Master.into()
kianenigma Sep 26, 2022
663efed
cargo update -p sp-io
kianenigma Sep 26, 2022
e7e552a
Merge branch 'kiz-add-fast-unstake' of github.com:paritytech/polkadot…
kianenigma Sep 26, 2022
deb936f
add signed extension as well
kianenigma Sep 26, 2022
789cc2c
master.into()
kianenigma Sep 27, 2022
95fe711
Revert "add signed extension as well"
kianenigma Sep 27, 2022
3a20b00
Merge branch 'master' of github.com:paritytech/polkadot into kiz-add-…
kianenigma Sep 27, 2022
6c6152e
cargo update -p sp-io
kianenigma Sep 27, 2022
4cda7ec
".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_fast_unstake
Sep 27, 2022
7cd50e3
".git/.scripts/bench-bot.sh" runtime polkadot-dev pallet_fast_unstake
Sep 27, 2022
d5c3a88
update sub
kianenigma Sep 27, 2022
5d938c2
integrate latest substrate changes
kianenigma Sep 27, 2022
6095205
Merge branch 'kiz-add-fast-unstake' of github.com:paritytech/polkadot…
kianenigma Sep 27, 2022
b884ebb
".git/.scripts/fmt.sh" 1
Sep 28, 2022
8a57b1e
".git/.scripts/bench-bot.sh" runtime westend-dev pallet_fast_unstake
Sep 28, 2022
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
371 changes: 199 additions & 172 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions node/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
6 changes: 6 additions & 0 deletions node/client/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl BenchmarkCallSigner<polkadot_runtime::RuntimeCall, sp_core::sr25519::Pair>
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
polkadot_runtime_common::claims::PrevalidateAttests::<runtime::Runtime>::new(),
pallet_fast_unstake::PreventStakingOpsIfUnbonding::<runtime::Runtime>::new(),
);

let payload = runtime::SignedPayload::from_raw(
Expand All @@ -171,6 +172,7 @@ impl BenchmarkCallSigner<polkadot_runtime::RuntimeCall, sp_core::sr25519::Pair>
(),
(),
(),
(),
),
);

Expand Down Expand Up @@ -211,6 +213,7 @@ impl BenchmarkCallSigner<westend_runtime::RuntimeCall, sp_core::sr25519::Pair>
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
pallet_fast_unstake::PreventStakingOpsIfUnbonding::<runtime::Runtime>::new(),
);

let payload = runtime::SignedPayload::from_raw(
Expand All @@ -225,6 +228,7 @@ impl BenchmarkCallSigner<westend_runtime::RuntimeCall, sp_core::sr25519::Pair>
(),
(),
(),
(),
),
);

Expand Down Expand Up @@ -265,6 +269,7 @@ impl BenchmarkCallSigner<kusama_runtime::RuntimeCall, sp_core::sr25519::Pair>
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
pallet_fast_unstake::PreventStakingOpsIfUnbonding::<runtime::Runtime>::new(),
);

let payload = runtime::SignedPayload::from_raw(
Expand All @@ -279,6 +284,7 @@ impl BenchmarkCallSigner<kusama_runtime::RuntimeCall, sp_core::sr25519::Pair>
(),
(),
(),
(),
),
);

Expand Down
1 change: 1 addition & 0 deletions node/test/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ inherents = { package = "sp-inherents", git = "https://github.com/paritytech/sub
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
4 changes: 4 additions & 0 deletions runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pallet-collective = { git = "https://github.com/paritytech/substrate", branch =
pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-gilt = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -143,6 +144,7 @@ std = [
"pallet-collective/std",
"pallet-elections-phragmen/std",
"pallet-election-provider-multi-phase/std",
"pallet-fast-unstake/std",
"pallet-democracy/std",
"pallet-gilt/std",
"pallet-grandpa/std",
Expand Down Expand Up @@ -206,6 +208,7 @@ runtime-benchmarks = [
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-election-provider-multi-phase/runtime-benchmarks",
"pallet-election-provider-support-benchmarking/runtime-benchmarks",
"pallet-fast-unstake/runtime-benchmarks",
"pallet-gilt/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
Expand Down Expand Up @@ -251,6 +254,7 @@ try-runtime = [
"pallet-collective/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-election-provider-multi-phase/try-runtime",
"pallet-fast-unstake/try-runtime",
"pallet-democracy/try-runtime",
"pallet-gilt/try-runtime",
"pallet-grandpa/try-runtime",
Expand Down
24 changes: 22 additions & 2 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ impl pallet_staking::Config for Runtime {
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
}

impl pallet_fast_unstake::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// slash by KSM/300 per era, if they are proven to be wrong.
type SlashPerEra = frame_support::traits::ConstU128<{ 100 * CENTS }>;
type ControlOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
>;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 2000 * CENTS;
Expand Down Expand Up @@ -798,6 +809,7 @@ where
frame_system::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
pallet_fast_unstake::PreventStakingOpsIfUnbonding::<Runtime>::new(),
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
Expand Down Expand Up @@ -1045,7 +1057,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Slots(..) |
RuntimeCall::Auctions(..) | // Specifically omitting the entire XCM Pallet
RuntimeCall::VoterList(..) |
RuntimeCall::NominationPools(..)
RuntimeCall::NominationPools(..) |
RuntimeCall::FastUnstake(..)
),
ProxyType::Governance =>
matches!(
Expand All @@ -1061,7 +1074,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::Staking => {
matches!(
c,
RuntimeCall::Staking(..) | RuntimeCall::Session(..) | RuntimeCall::Utility(..)
RuntimeCall::Staking(..) |
RuntimeCall::Session(..) | RuntimeCall::Utility(..) |
RuntimeCall::FastUnstake(..)
)
},
ProxyType::IdentityJudgement => matches!(
Expand Down Expand Up @@ -1389,6 +1404,9 @@ construct_runtime! {
// nomination pools: extension to staking.
NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event<T>, Config<T>} = 41,

// Fast unstake pallet: extension to staking.
FastUnstake: pallet_fast_unstake = 42,

// Parachains pallets. Start indices at 50 to leave room.
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50,
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 51,
Expand Down Expand Up @@ -1435,6 +1453,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
pallet_fast_unstake::PreventStakingOpsIfUnbonding<Runtime>,
);

pub struct StakingMigrationV11OldPallet;
Expand Down Expand Up @@ -1501,6 +1520,7 @@ mod benches {
[pallet_elections_phragmen, PhragmenElection]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
[pallet_fast_unstake, FastUnstake]
[pallet_gilt, Gilt]
[pallet_identity, Identity]
[pallet_im_online, ImOnline]
Expand Down
1 change: 1 addition & 0 deletions runtime/kusama/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub mod pallet_collective_technical_committee;
pub mod pallet_democracy;
pub mod pallet_election_provider_multi_phase;
pub mod pallet_elections_phragmen;
pub mod pallet_fast_unstake;
pub mod pallet_gilt;
pub mod pallet_identity;
pub mod pallet_im_online;
Expand Down
122 changes: 122 additions & 0 deletions runtime/kusama/src/weights/pallet_fast_unstake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_fast_unstake`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-09-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024

// Executed Command:
// /home/benchbot/cargo_target_dir/production/polkadot
// benchmark
// pallet
// --steps=50
// --repeat=20
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --pallet=pallet_fast_unstake
// --chain=westend-dev
// --header=./file_header.txt
// --output=./runtime/westend/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weight functions for `pallet_fast_unstake`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T> {
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:2 w:1)
// Storage: Staking Ledger (r:2 w:2)
// Storage: Staking Validators (r:1 w:0)
// Storage: Staking Nominators (r:1 w:0)
// Storage: System Account (r:3 w:2)
// Storage: Balances Locks (r:2 w:2)
// Storage: NominationPools MinJoinBond (r:1 w:0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should see all of this gone now.

// Storage: NominationPools PoolMembers (r:1 w:1)
// Storage: NominationPools BondedPools (r:1 w:1)
// Storage: NominationPools RewardPools (r:1 w:1)
// Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0)
// Storage: NominationPools MaxPoolMembers (r:1 w:0)
// Storage: NominationPools CounterForPoolMembers (r:1 w:1)
// Storage: VoterList ListNodes (r:1 w:0)
// Storage: Staking Payee (r:0 w:1)
fn on_idle_unstake() -> Weight {
Weight::from_ref_time(146_928_000 as u64)
.saturating_add(T::DbWeight::get().reads(25 as u64))
.saturating_add(T::DbWeight::get().writes(13 as u64))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:2 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking ErasStakers (r:4 w:0)
/// The range of component `x` is `[2, 256]`.
fn on_idle_check(x: u32, ) -> Weight {
Weight::from_ref_time(69_485_000 as u64)
// Standard Error: 10_556
.saturating_add(Weight::from_ref_time(13_708_637 as u64).saturating_mul(x as u64))
.saturating_add(T::DbWeight::get().reads(12 as u64))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64)))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
// Storage: Staking Ledger (r:1 w:1)
// Storage: FastUnstake Queue (r:1 w:1)
// Storage: FastUnstake Head (r:1 w:0)
// Storage: Staking Validators (r:1 w:0)
// Storage: Staking Nominators (r:1 w:1)
// Storage: Staking CounterForNominators (r:1 w:1)
// Storage: VoterList ListNodes (r:1 w:1)
// Storage: VoterList ListBags (r:1 w:1)
// Storage: VoterList CounterForListNodes (r:1 w:1)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight {
Weight::from_ref_time(85_439_000 as u64)
.saturating_add(T::DbWeight::get().reads(12 as u64))
.saturating_add(T::DbWeight::get().writes(9 as u64))
}
// Storage: Staking Ledger (r:1 w:0)
// Storage: FastUnstake Queue (r:1 w:1)
// Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight {
Weight::from_ref_time(23_885_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight {
Weight::from_ref_time(4_292_000 as u64)
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
}
4 changes: 4 additions & 0 deletions runtime/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pallet-collective = { git = "https://github.com/paritytech/substrate", branch =
pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -139,6 +140,7 @@ std = [
"pallet-elections-phragmen/std",
"pallet-election-provider-multi-phase/std",
"pallet-democracy/std",
"pallet-fast-unstake/std",
"pallet-grandpa/std",
"pallet-identity/std",
"pallet-im-online/std",
Expand Down Expand Up @@ -194,6 +196,7 @@ runtime-benchmarks = [
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-election-provider-multi-phase/runtime-benchmarks",
"pallet-election-provider-support-benchmarking/runtime-benchmarks",
"pallet-fast-unstake/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
Expand Down Expand Up @@ -237,6 +240,7 @@ try-runtime = [
"pallet-collective/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-election-provider-multi-phase/try-runtime",
"pallet-fast-unstake/try-runtime",
"pallet-democracy/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-identity/try-runtime",
Expand Down
Loading