From 3c3ae9b5a402b113b17bc89fa7a244566ad7892c Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Wed, 6 Apr 2022 15:59:29 +0200 Subject: [PATCH 1/7] feat: add tips pallet --- Cargo.lock | 2 + runtimes/common/src/constants.rs | 14 ++- runtimes/peregrine/Cargo.toml | 4 + runtimes/peregrine/src/lib.rs | 42 +++++++ runtimes/peregrine/src/weights/mod.rs | 1 + runtimes/peregrine/src/weights/pallet_tips.rs | 107 ++++++++++++++++++ runtimes/spiritnet/Cargo.toml | 4 + runtimes/spiritnet/src/lib.rs | 42 +++++++ runtimes/spiritnet/src/weights/mod.rs | 1 + runtimes/spiritnet/src/weights/pallet_tips.rs | 107 ++++++++++++++++++ 10 files changed, 323 insertions(+), 1 deletion(-) create mode 100644 runtimes/peregrine/src/weights/pallet_tips.rs create mode 100644 runtimes/spiritnet/src/weights/pallet_tips.rs diff --git a/Cargo.lock b/Cargo.lock index 5e42bcae0b..c8dee72a24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6685,6 +6685,7 @@ dependencies = [ "pallet-session", "pallet-sudo", "pallet-timestamp", + "pallet-tips", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", @@ -10860,6 +10861,7 @@ dependencies = [ "pallet-scheduler", "pallet-session", "pallet-timestamp", + "pallet-tips", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", diff --git a/runtimes/common/src/constants.rs b/runtimes/common/src/constants.rs index aecde66dea..6c2e9f2f5b 100644 --- a/runtimes/common/src/constants.rs +++ b/runtimes/common/src/constants.rs @@ -20,7 +20,7 @@ use frame_support::{ parameter_types, weights::{constants::WEIGHT_PER_SECOND, Weight}, }; -use sp_runtime::{Perbill, Perquintill}; +use sp_runtime::{Perbill, Percent, Perquintill}; use parachain_staking::InflationInfo; @@ -408,6 +408,18 @@ pub mod preimage { } } +pub mod tips { + use super::*; + + parameter_types! { + pub const DataDepositPerByte: Balance = deposit(0, 1); + pub const MaximumReasonLength: u32 = 16384; + pub const TipCountdown: BlockNumber = DAYS; + pub const TipFindersFee: Percent = Percent::from_percent(20); + pub const TipReportDepositBase: Balance = deposit(1, 1); + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 6b15d7797c..81fd4a954e 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -67,6 +67,7 @@ pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-fea pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-sudo = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} +pallet-tips = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} @@ -122,6 +123,7 @@ runtime-benchmarks = [ "pallet-preimage/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-tips/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-web3-names/runtime-benchmarks", @@ -167,6 +169,7 @@ std = [ "pallet-session/std", "pallet-sudo/std", "pallet-timestamp/std", + "pallet-tips/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-treasury/std", @@ -219,6 +222,7 @@ try-runtime = [ "pallet-session/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", + "pallet-tips/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-web3-names/try-runtime", diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index db22575945..2cc292c2f7 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -475,6 +475,43 @@ impl pallet_membership::Config for Runtime { type WeightInfo = weights::pallet_membership::WeightInfo; } +pub struct CouncilProvider; +impl frame_support::traits::SortedMembers for CouncilProvider { + fn contains(who: &AccountId) -> bool { + Council::is_member(who) + } + + fn sorted_members() -> Vec { + Council::members() + } + + #[cfg(feature = "runtime-benchmarks")] + fn add(_: &AccountId) { + unimplemented!() + } +} + +impl frame_support::traits::ContainsLengthBound for CouncilProvider { + fn max_len() -> usize { + constants::governance::CouncilMaxMembers::get() as usize + } + + fn min_len() -> usize { + 0 + } +} + +impl pallet_tips::Config for Runtime { + type MaximumReasonLength = constants::tips::MaximumReasonLength; + type DataDepositPerByte = constants::tips::DataDepositPerByte; + type Tippers = CouncilProvider; + type TipCountdown = constants::tips::TipCountdown; + type TipFindersFee = constants::tips::TipFindersFee; + type TipReportDepositBase = constants::tips::TipReportDepositBase; + type Event = Event; + type WeightInfo = weights::pallet_tips::WeightInfo; +} + impl attestation::Config for Runtime { type EnsureOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; @@ -868,6 +905,9 @@ construct_runtime! { // Preimage registrar Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, + // Tips module. + Tips: pallet_tips::{Pallet, Call, Storage, Event} = 45, + // KILT Pallets. Start indices 60 to leave room KiltLaunch: kilt_launch = 60, Ctype: ctype = 61, @@ -1098,6 +1138,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_preimage, Preimage); list_benchmark!(list, extra, pallet_scheduler, Scheduler); list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_tips, Tips); list_benchmark!(list, extra, pallet_treasury, Treasury); list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); @@ -1166,6 +1207,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_session, SessionBench::); add_benchmark!(params, batches, frame_system, SystemBench::); add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmark!(params, batches, pallet_tips, Tips); add_benchmark!(params, batches, pallet_treasury, Treasury); add_benchmark!(params, batches, pallet_utility, Utility); add_benchmark!(params, batches, pallet_vesting, Vesting); diff --git a/runtimes/peregrine/src/weights/mod.rs b/runtimes/peregrine/src/weights/mod.rs index 112cd38e0f..a135ba0de6 100644 --- a/runtimes/peregrine/src/weights/mod.rs +++ b/runtimes/peregrine/src/weights/mod.rs @@ -34,6 +34,7 @@ pub mod pallet_proxy; pub mod pallet_scheduler; pub mod pallet_session; pub mod pallet_timestamp; +pub mod pallet_tips; pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vesting; diff --git a/runtimes/peregrine/src/weights/pallet_tips.rs b/runtimes/peregrine/src/weights/pallet_tips.rs new file mode 100644 index 0000000000..5e144ca8d3 --- /dev/null +++ b/runtimes/peregrine/src/weights/pallet_tips.rs @@ -0,0 +1,107 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2022 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_tips` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_tips +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/pallet_tips.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(clippy::unnecessary_cast)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_tips`. +pub struct WeightInfo(PhantomData); +impl pallet_tips::WeightInfo for WeightInfo { + // Storage: Tips Reasons (r:1 w:1) + // Storage: Tips Tips (r:1 w:1) + fn report_awesome(r: u32, ) -> Weight { + (23_071_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + fn retract_tip() -> Weight { + (22_077_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: Tips Reasons (r:1 w:1) + // Storage: Tips Tips (r:0 w:1) + fn tip_new(r: u32, t: u32, ) -> Weight { + (15_063_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 3_000 + .saturating_add((88_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: Tips Tips (r:1 w:1) + fn tip(t: u32, ) -> Weight { + (8_709_000 as Weight) + // Standard Error: 1_000 + .saturating_add((315_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + fn close_tip(t: u32, ) -> Weight { + (37_111_000 as Weight) + // Standard Error: 6_000 + .saturating_add((210_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + fn slash_tip(t: u32, ) -> Weight { + (13_293_000 as Weight) + // Standard Error: 22_000 + .saturating_add((24_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index 9b323c75e5..c2752ecfcf 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -66,6 +66,7 @@ pallet-randomness-collective-flip = {git = "https://github.com/paritytech/substr pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} +pallet-tips = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} @@ -123,6 +124,7 @@ runtime-benchmarks = [ "pallet-proxy/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-tips/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-web3-names/runtime-benchmarks", "pallet-utility/runtime-benchmarks", @@ -166,6 +168,7 @@ std = [ "pallet-scheduler/std", "pallet-session/std", "pallet-timestamp/std", + "pallet-tips/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-treasury/std", @@ -219,6 +222,7 @@ try-runtime = [ "pallet-scheduler/try-runtime", "pallet-session/try-runtime", "pallet-timestamp/try-runtime", + "pallet-tips/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-web3-names/try-runtime", diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 38886ab399..c57e53760f 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -480,6 +480,43 @@ impl pallet_membership::Config for Runtime { type WeightInfo = weights::pallet_membership::WeightInfo; } +pub struct CouncilProvider; +impl frame_support::traits::SortedMembers for CouncilProvider { + fn contains(who: &AccountId) -> bool { + Council::is_member(who) + } + + fn sorted_members() -> Vec { + Council::members() + } + + #[cfg(feature = "runtime-benchmarks")] + fn add(_: &AccountId) { + unimplemented!() + } +} + +impl frame_support::traits::ContainsLengthBound for CouncilProvider { + fn max_len() -> usize { + constants::governance::CouncilMaxMembers::get() as usize + } + + fn min_len() -> usize { + 0 + } +} + +impl pallet_tips::Config for Runtime { + type MaximumReasonLength = constants::tips::MaximumReasonLength; + type DataDepositPerByte = constants::tips::DataDepositPerByte; + type Tippers = CouncilProvider; + type TipCountdown = constants::tips::TipCountdown; + type TipFindersFee = constants::tips::TipFindersFee; + type TipReportDepositBase = constants::tips::TipReportDepositBase; + type Event = Event; + type WeightInfo = weights::pallet_tips::WeightInfo; +} + impl attestation::Config for Runtime { type EnsureOrigin = did::EnsureDidOrigin; type OriginSuccess = did::DidRawOrigin; @@ -870,6 +907,9 @@ construct_runtime! { // Preimage registrar Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, + // Tips module. + Tips: pallet_tips::{Pallet, Call, Storage, Event} = 45, + // KILT Pallets. Start indices 60 to leave room KiltLaunch: kilt_launch = 60, Ctype: ctype = 61, @@ -1100,6 +1140,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_preimage, Preimage); list_benchmark!(list, extra, pallet_scheduler, Scheduler); list_benchmark!(list, extra, pallet_timestamp, Timestamp); + list_benchmark!(list, extra, pallet_tips, Tips); list_benchmark!(list, extra, pallet_treasury, Treasury); list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_vesting, Vesting); @@ -1168,6 +1209,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_session, SessionBench::); add_benchmark!(params, batches, frame_system, SystemBench::); add_benchmark!(params, batches, pallet_timestamp, Timestamp); + add_benchmark!(params, batches, pallet_tips, Tips); add_benchmark!(params, batches, pallet_treasury, Treasury); add_benchmark!(params, batches, pallet_utility, Utility); add_benchmark!(params, batches, pallet_vesting, Vesting); diff --git a/runtimes/spiritnet/src/weights/mod.rs b/runtimes/spiritnet/src/weights/mod.rs index 112cd38e0f..a135ba0de6 100644 --- a/runtimes/spiritnet/src/weights/mod.rs +++ b/runtimes/spiritnet/src/weights/mod.rs @@ -34,6 +34,7 @@ pub mod pallet_proxy; pub mod pallet_scheduler; pub mod pallet_session; pub mod pallet_timestamp; +pub mod pallet_tips; pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vesting; diff --git a/runtimes/spiritnet/src/weights/pallet_tips.rs b/runtimes/spiritnet/src/weights/pallet_tips.rs new file mode 100644 index 0000000000..5e144ca8d3 --- /dev/null +++ b/runtimes/spiritnet/src/weights/pallet_tips.rs @@ -0,0 +1,107 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2022 BOTLabs GmbH + +// The KILT Blockchain 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. + +// The KILT Blockchain 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 this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_tips` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_tips +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/pallet_tips.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(clippy::unnecessary_cast)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_tips`. +pub struct WeightInfo(PhantomData); +impl pallet_tips::WeightInfo for WeightInfo { + // Storage: Tips Reasons (r:1 w:1) + // Storage: Tips Tips (r:1 w:1) + fn report_awesome(r: u32, ) -> Weight { + (23_071_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + fn retract_tip() -> Weight { + (22_077_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: Tips Reasons (r:1 w:1) + // Storage: Tips Tips (r:0 w:1) + fn tip_new(r: u32, t: u32, ) -> Weight { + (15_063_000 as Weight) + // Standard Error: 0 + .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 3_000 + .saturating_add((88_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: Tips Tips (r:1 w:1) + fn tip(t: u32, ) -> Weight { + (8_709_000 as Weight) + // Standard Error: 1_000 + .saturating_add((315_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + fn close_tip(t: u32, ) -> Weight { + (37_111_000 as Weight) + // Standard Error: 6_000 + .saturating_add((210_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + fn slash_tip(t: u32, ) -> Weight { + (13_293_000 as Weight) + // Standard Error: 22_000 + .saturating_add((24_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} From 96bb827aef6f6191a0bfa9747ebb02cdc0ed0833 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Thu, 7 Apr 2022 09:20:33 +0200 Subject: [PATCH 2/7] fix: benchmarks --- runtimes/common/src/constants.rs | 1 - runtimes/peregrine/src/lib.rs | 11 ++++++++--- runtimes/spiritnet/src/lib.rs | 11 ++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/runtimes/common/src/constants.rs b/runtimes/common/src/constants.rs index 6c2e9f2f5b..fb449cceec 100644 --- a/runtimes/common/src/constants.rs +++ b/runtimes/common/src/constants.rs @@ -412,7 +412,6 @@ pub mod tips { use super::*; parameter_types! { - pub const DataDepositPerByte: Balance = deposit(0, 1); pub const MaximumReasonLength: u32 = 16384; pub const TipCountdown: BlockNumber = DAYS; pub const TipFindersFee: Percent = Percent::from_percent(20); diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 2cc292c2f7..b4b12f2a75 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -486,8 +486,13 @@ impl frame_support::traits::SortedMembers for CouncilProvider { } #[cfg(feature = "runtime-benchmarks")] - fn add(_: &AccountId) { - unimplemented!() + fn add(who: &AccountId) { + pallet_collective::Members::::mutate(|members| { + match members.binary_search_by(|m| m.cmp(who)) { + Ok(_) => (), + Err(pos) => members.insert(pos, who.clone()), + } + }) } } @@ -503,7 +508,7 @@ impl frame_support::traits::ContainsLengthBound for CouncilProvider { impl pallet_tips::Config for Runtime { type MaximumReasonLength = constants::tips::MaximumReasonLength; - type DataDepositPerByte = constants::tips::DataDepositPerByte; + type DataDepositPerByte = constants::ByteDeposit; type Tippers = CouncilProvider; type TipCountdown = constants::tips::TipCountdown; type TipFindersFee = constants::tips::TipFindersFee; diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index c57e53760f..b124aaa765 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -491,8 +491,13 @@ impl frame_support::traits::SortedMembers for CouncilProvider { } #[cfg(feature = "runtime-benchmarks")] - fn add(_: &AccountId) { - unimplemented!() + fn add(who: &AccountId) { + pallet_collective::Members::::mutate(|members| { + match members.binary_search_by(|m| m.cmp(who)) { + Ok(_) => (), + Err(pos) => members.insert(pos, who.clone()), + } + }) } } @@ -508,7 +513,7 @@ impl frame_support::traits::ContainsLengthBound for CouncilProvider { impl pallet_tips::Config for Runtime { type MaximumReasonLength = constants::tips::MaximumReasonLength; - type DataDepositPerByte = constants::tips::DataDepositPerByte; + type DataDepositPerByte = constants::ByteDeposit; type Tippers = CouncilProvider; type TipCountdown = constants::tips::TipCountdown; type TipFindersFee = constants::tips::TipFindersFee; From 371874809458ee39f9716bc0197df3b989a64409 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Thu, 7 Apr 2022 11:33:26 +0200 Subject: [PATCH 3/7] refactor: move provider to common --- Cargo.lock | 1 + runtimes/common/Cargo.toml | 2 ++ runtimes/common/src/lib.rs | 39 ++++++++++++++++++++++++++++++++++- runtimes/peregrine/src/lib.rs | 33 +---------------------------- runtimes/spiritnet/src/lib.rs | 33 +---------------------------- 5 files changed, 43 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8dee72a24..c32680d18e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8568,6 +8568,7 @@ dependencies = [ "frame-system", "pallet-authorship", "pallet-balances", + "pallet-membership", "pallet-transaction-payment", "parachain-staking", "parity-scale-codec", diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index be65361d4d..953990d58d 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -20,6 +20,7 @@ frame-support = {git = "https://github.com/paritytech/substrate", default-featur frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} +pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.17"} @@ -38,6 +39,7 @@ std = [ "frame-system/std", "pallet-transaction-payment/std", "pallet-balances/std", + "pallet-membership/std", "pallet-authorship/std", "scale-info/std", "serde", diff --git a/runtimes/common/src/lib.rs b/runtimes/common/src/lib.rs index 9ff9a63900..5921476feb 100644 --- a/runtimes/common/src/lib.rs +++ b/runtimes/common/src/lib.rs @@ -28,7 +28,11 @@ pub use sp_consensus_aura::sr25519::AuthorityId; pub use opaque::*; pub use frame_support::weights::constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; -use frame_support::{parameter_types, traits::Currency, weights::DispatchClass}; +use frame_support::{ + parameter_types, + traits::{Contains, ContainsLengthBound, Currency, Get, SortedMembers}, + weights::DispatchClass, +}; use frame_system::limits; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use sp_runtime::{ @@ -36,6 +40,7 @@ use sp_runtime::{ traits::{IdentifyAccount, Verify}, FixedPointNumber, MultiSignature, Perquintill, }; +use sp_std::marker::PhantomData; pub mod authorization; pub mod constants; @@ -153,3 +158,35 @@ pub type FeeSplit = SplitFeesByRatio; /// https://w3f-research.readthedocs.io/en/latest/polkadot/Token%20Economics.html#-2.-slow-adjusting-mechanism pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment; + +pub struct InitialTippers(PhantomData); +impl ContainsLengthBound for InitialTippers +where + R: pallet_membership::Config, +{ + fn max_len() -> usize { + ::MaxMembers::get() as usize + } + + fn min_len() -> usize { + 0 + } +} + +impl SortedMembers for InitialTippers +where + R: pallet_membership::Config + frame_system::Config, + pallet_membership::Pallet: SortedMembers + Contains, +{ + fn sorted_members() -> sp_std::vec::Vec { + pallet_membership::Pallet::::sorted_members() + } + + #[cfg(feature = "runtime-benchmarks")] + fn add(who: &R::AccountId) { + pallet_membership::Members::::mutate(|members| match members.binary_search_by(|m| m.cmp(who)) { + Ok(_) => (), + Err(pos) => members.insert(pos, who.clone()), + }) + } +} diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index b4b12f2a75..b915fc2bf8 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -475,41 +475,10 @@ impl pallet_membership::Config for Runtime { type WeightInfo = weights::pallet_membership::WeightInfo; } -pub struct CouncilProvider; -impl frame_support::traits::SortedMembers for CouncilProvider { - fn contains(who: &AccountId) -> bool { - Council::is_member(who) - } - - fn sorted_members() -> Vec { - Council::members() - } - - #[cfg(feature = "runtime-benchmarks")] - fn add(who: &AccountId) { - pallet_collective::Members::::mutate(|members| { - match members.binary_search_by(|m| m.cmp(who)) { - Ok(_) => (), - Err(pos) => members.insert(pos, who.clone()), - } - }) - } -} - -impl frame_support::traits::ContainsLengthBound for CouncilProvider { - fn max_len() -> usize { - constants::governance::CouncilMaxMembers::get() as usize - } - - fn min_len() -> usize { - 0 - } -} - impl pallet_tips::Config for Runtime { type MaximumReasonLength = constants::tips::MaximumReasonLength; type DataDepositPerByte = constants::ByteDeposit; - type Tippers = CouncilProvider; + type Tippers = runtime_common::InitialTippers; type TipCountdown = constants::tips::TipCountdown; type TipFindersFee = constants::tips::TipFindersFee; type TipReportDepositBase = constants::tips::TipReportDepositBase; diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index b124aaa765..c39e62cd50 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -480,41 +480,10 @@ impl pallet_membership::Config for Runtime { type WeightInfo = weights::pallet_membership::WeightInfo; } -pub struct CouncilProvider; -impl frame_support::traits::SortedMembers for CouncilProvider { - fn contains(who: &AccountId) -> bool { - Council::is_member(who) - } - - fn sorted_members() -> Vec { - Council::members() - } - - #[cfg(feature = "runtime-benchmarks")] - fn add(who: &AccountId) { - pallet_collective::Members::::mutate(|members| { - match members.binary_search_by(|m| m.cmp(who)) { - Ok(_) => (), - Err(pos) => members.insert(pos, who.clone()), - } - }) - } -} - -impl frame_support::traits::ContainsLengthBound for CouncilProvider { - fn max_len() -> usize { - constants::governance::CouncilMaxMembers::get() as usize - } - - fn min_len() -> usize { - 0 - } -} - impl pallet_tips::Config for Runtime { type MaximumReasonLength = constants::tips::MaximumReasonLength; type DataDepositPerByte = constants::ByteDeposit; - type Tippers = CouncilProvider; + type Tippers = runtime_common::InitialTippers; type TipCountdown = constants::tips::TipCountdown; type TipFindersFee = constants::tips::TipFindersFee; type TipReportDepositBase = constants::tips::TipReportDepositBase; From 31eaad3e07e88c12967a808c06f56a8ac9129229 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Thu, 7 Apr 2022 14:17:11 +0200 Subject: [PATCH 4/7] feat: add tips membership pallet --- nodes/parachain/src/chain_spec/peregrine.rs | 1 + nodes/parachain/src/chain_spec/spiritnet.rs | 1 + runtimes/common/src/lib.rs | 18 ++++++------- runtimes/peregrine/src/lib.rs | 28 ++++++++++++++++---- runtimes/spiritnet/src/lib.rs | 29 +++++++++++++++++---- 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/nodes/parachain/src/chain_spec/peregrine.rs b/nodes/parachain/src/chain_spec/peregrine.rs index 78e455f3e3..0c0485ac31 100644 --- a/nodes/parachain/src/chain_spec/peregrine.rs +++ b/nodes/parachain/src/chain_spec/peregrine.rs @@ -207,6 +207,7 @@ fn testnet_genesis( phantom: Default::default(), }, treasury: Default::default(), + tips_membership: Default::default(), technical_membership: Default::default(), democracy: Default::default(), parachain_staking: ParachainStakingConfig { diff --git a/nodes/parachain/src/chain_spec/spiritnet.rs b/nodes/parachain/src/chain_spec/spiritnet.rs index e024250b8e..eb07c4ad06 100644 --- a/nodes/parachain/src/chain_spec/spiritnet.rs +++ b/nodes/parachain/src/chain_spec/spiritnet.rs @@ -337,6 +337,7 @@ fn testnet_genesis( }, treasury: Default::default(), technical_membership: Default::default(), + tips_membership: Default::default(), democracy: Default::default(), } } diff --git a/runtimes/common/src/lib.rs b/runtimes/common/src/lib.rs index 5921476feb..2c0fa5f8bb 100644 --- a/runtimes/common/src/lib.rs +++ b/runtimes/common/src/lib.rs @@ -159,13 +159,13 @@ pub type FeeSplit = SplitFeesByRatio; pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment; -pub struct InitialTippers(PhantomData); -impl ContainsLengthBound for InitialTippers +pub struct Tippers(PhantomData, PhantomData); +impl ContainsLengthBound for Tippers where - R: pallet_membership::Config, + R: pallet_membership::Config, { fn max_len() -> usize { - ::MaxMembers::get() as usize + >::MaxMembers::get() as usize } fn min_len() -> usize { @@ -173,18 +173,18 @@ where } } -impl SortedMembers for InitialTippers +impl SortedMembers for Tippers where - R: pallet_membership::Config + frame_system::Config, - pallet_membership::Pallet: SortedMembers + Contains, + R: pallet_membership::Config + frame_system::Config, + pallet_membership::Pallet: SortedMembers + Contains, { fn sorted_members() -> sp_std::vec::Vec { - pallet_membership::Pallet::::sorted_members() + pallet_membership::Pallet::::sorted_members() } #[cfg(feature = "runtime-benchmarks")] fn add(who: &R::AccountId) { - pallet_membership::Members::::mutate(|members| match members.binary_search_by(|m| m.cmp(who)) { + pallet_membership::Members::::mutate(|members| match members.binary_search_by(|m| m.cmp(who)) { Ok(_) => (), Err(pos) => members.insert(pos, who.clone()), }) diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index b915fc2bf8..5035156beb 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -462,7 +462,8 @@ impl pallet_collective::Config for Runtime { type WeightInfo = weights::pallet_collective::WeightInfo; } -impl pallet_membership::Config for Runtime { +type TechnicalMembershipProvider = pallet_membership::Instance1; +impl pallet_membership::Config for Runtime { type Event = Event; type AddOrigin = MoreThanHalfCouncil; type RemoveOrigin = MoreThanHalfCouncil; @@ -475,10 +476,24 @@ impl pallet_membership::Config for Runtime { type WeightInfo = weights::pallet_membership::WeightInfo; } +type TipsMembershipProvider = pallet_membership::Instance2; +impl pallet_membership::Config for Runtime { + type Event = Event; + type AddOrigin = MoreThanHalfCouncil; + type RemoveOrigin = MoreThanHalfCouncil; + type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = (); + type MembershipChanged = (); + type MaxMembers = constants::governance::TechnicalMaxMembers; + type WeightInfo = weights::pallet_membership::WeightInfo; +} + impl pallet_tips::Config for Runtime { type MaximumReasonLength = constants::tips::MaximumReasonLength; type DataDepositPerByte = constants::ByteDeposit; - type Tippers = runtime_common::InitialTippers; + type Tippers = runtime_common::Tippers; type TipCountdown = constants::tips::TipCountdown; type TipFindersFee = constants::tips::TipFindersFee; type TipReportDepositBase = constants::tips::TipReportDepositBase; @@ -711,6 +726,7 @@ impl InstanceFilter for ProxyType { | Call::System(..) | Call::TechnicalCommittee(..) | Call::TechnicalMembership(..) + | Call::TipsMembership(..) | Call::Timestamp(..) | Call::Treasury(..) | Call::Utility(..) @@ -791,6 +807,7 @@ impl InstanceFilter for ProxyType { | Call::Democracy(..) | Call::TechnicalCommittee(..) | Call::TechnicalMembership(..) + | Call::TipsMembership(..) | Call::Treasury(..) | Call::Utility(..) ), ProxyType::ParachainStaking => { @@ -861,7 +878,7 @@ construct_runtime! { Council: pallet_collective:: = 31, TechnicalCommittee: pallet_collective:: = 32, // placeholder: parachain council election = 33, - TechnicalMembership: pallet_membership = 34, + TechnicalMembership: pallet_membership:: = 34, Treasury: pallet_treasury = 35, // Utility module. @@ -879,8 +896,9 @@ construct_runtime! { // Preimage registrar Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, - // Tips module. - Tips: pallet_tips::{Pallet, Call, Storage, Event} = 45, + // Tips module to reward contributions to the ecosystem with small amount of KILTs. + TipsMembership: pallet_membership:: = 45, + Tips: pallet_tips::{Pallet, Call, Storage, Event} = 46, // KILT Pallets. Start indices 60 to leave room KiltLaunch: kilt_launch = 60, diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index c39e62cd50..a1972f2cea 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -467,7 +467,8 @@ impl pallet_collective::Config for Runtime { type WeightInfo = weights::pallet_collective::WeightInfo; } -impl pallet_membership::Config for Runtime { +type TechnicalMembershipProvider = pallet_membership::Instance1; +impl pallet_membership::Config for Runtime { type Event = Event; type AddOrigin = MoreThanHalfCouncil; type RemoveOrigin = MoreThanHalfCouncil; @@ -480,10 +481,24 @@ impl pallet_membership::Config for Runtime { type WeightInfo = weights::pallet_membership::WeightInfo; } +type TipsMembershipProvider = pallet_membership::Instance2; +impl pallet_membership::Config for Runtime { + type Event = Event; + type AddOrigin = MoreThanHalfCouncil; + type RemoveOrigin = MoreThanHalfCouncil; + type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = (); + type MembershipChanged = (); + type MaxMembers = constants::governance::TechnicalMaxMembers; + type WeightInfo = weights::pallet_membership::WeightInfo; +} + impl pallet_tips::Config for Runtime { type MaximumReasonLength = constants::tips::MaximumReasonLength; type DataDepositPerByte = constants::ByteDeposit; - type Tippers = runtime_common::InitialTippers; + type Tippers = runtime_common::Tippers; type TipCountdown = constants::tips::TipCountdown; type TipFindersFee = constants::tips::TipFindersFee; type TipReportDepositBase = constants::tips::TipReportDepositBase; @@ -715,6 +730,7 @@ impl InstanceFilter for ProxyType { | Call::System(..) | Call::TechnicalCommittee(..) | Call::TechnicalMembership(..) + | Call::TipsMembership(..) | Call::Timestamp(..) | Call::Treasury(..) | Call::Utility(..) @@ -777,6 +793,7 @@ impl InstanceFilter for ProxyType { | Call::System(..) | Call::TechnicalCommittee(..) | Call::TechnicalMembership(..) + | Call::TipsMembership(..) | Call::Timestamp(..) | Call::Treasury(..) | Call::Utility(..) @@ -794,6 +811,7 @@ impl InstanceFilter for ProxyType { | Call::Democracy(..) | Call::TechnicalCommittee(..) | Call::TechnicalMembership(..) + | Call::TipsMembership(..) | Call::Treasury(..) | Call::Utility(..) ), ProxyType::ParachainStaking => { @@ -863,7 +881,7 @@ construct_runtime! { Council: pallet_collective:: = 31, TechnicalCommittee: pallet_collective:: = 32, // placeholder: parachain council election = 33, - TechnicalMembership: pallet_membership = 34, + TechnicalMembership: pallet_membership:: = 34, Treasury: pallet_treasury = 35, // Utility module. @@ -881,8 +899,9 @@ construct_runtime! { // Preimage registrar Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, - // Tips module. - Tips: pallet_tips::{Pallet, Call, Storage, Event} = 45, + // Tips module to reward contributions to the ecosystem with small amount of KILTs. + TipsMembership: pallet_membership:: = 45, + Tips: pallet_tips::{Pallet, Call, Storage, Event} = 46, // KILT Pallets. Start indices 60 to leave room KiltLaunch: kilt_launch = 60, From 5bad5018fbfa0bba2bac40ab7d26dfb430473e77 Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 7 Apr 2022 15:08:36 +0200 Subject: [PATCH 5/7] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=spiritnet-dev --steps=50 --repeat=20 --pallet=pallet-tips --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtimes/spiritnet/src/weights/pallet_tips.rs --template=.maintain/runtime-weight-template.hbs --- runtimes/spiritnet/src/weights/pallet_tips.rs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/runtimes/spiritnet/src/weights/pallet_tips.rs b/runtimes/spiritnet/src/weights/pallet_tips.rs index 5e144ca8d3..14a1d3b8f2 100644 --- a/runtimes/spiritnet/src/weights/pallet_tips.rs +++ b/runtimes/spiritnet/src/weights/pallet_tips.rs @@ -16,25 +16,25 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -//! Autogenerated weights for `pallet_tips` +//! Autogenerated weights for pallet_tips //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-03-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 +//! DATE: 2022-04-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("spiritnet-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// target/release/kilt-parachain // benchmark -// --chain=kusama-dev +// --chain=spiritnet-dev // --steps=50 // --repeat=20 -// --pallet=pallet_tips +// --pallet=pallet-tips // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_tips.rs +// --output=./runtimes/spiritnet/src/weights/pallet_tips.rs +// --template=.maintain/runtime-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,7 +50,7 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:1 w:1) fn report_awesome(r: u32, ) -> Weight { - (23_071_000 as Weight) + (39_849_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) @@ -59,48 +59,48 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn retract_tip() -> Weight { - (22_077_000 as Weight) + (37_338_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: PhragmenElection Members (r:1 w:0) + // Storage: TipsMembership Members (r:1 w:0) // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:0 w:1) fn tip_new(r: u32, t: u32, ) -> Weight { - (15_063_000 as Weight) + (25_363_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 3_000 - .saturating_add((88_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 0 + .saturating_add((109_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: PhragmenElection Members (r:1 w:0) + // Storage: TipsMembership Members (r:1 w:0) // Storage: Tips Tips (r:1 w:1) fn tip(t: u32, ) -> Weight { - (8_709_000 as Weight) - // Standard Error: 1_000 - .saturating_add((315_000 as Weight).saturating_mul(t as Weight)) + (15_884_000 as Weight) + // Standard Error: 0 + .saturating_add((450_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Tips Tips (r:1 w:1) - // Storage: PhragmenElection Members (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: TipsMembership Members (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Tips Reasons (r:0 w:1) fn close_tip(t: u32, ) -> Weight { - (37_111_000 as Weight) - // Standard Error: 6_000 - .saturating_add((210_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + (64_138_000 as Weight) + // Standard Error: 0 + .saturating_add((283_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn slash_tip(t: u32, ) -> Weight { - (13_293_000 as Weight) - // Standard Error: 22_000 - .saturating_add((24_000 as Weight).saturating_mul(t as Weight)) + (22_105_000 as Weight) + // Standard Error: 0 + .saturating_add((6_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } From f519ff10d92b43995ba304563a5b02decea58490 Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 7 Apr 2022 15:45:38 +0200 Subject: [PATCH 6/7] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet-tips --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtimes/peregrine/src/weights/pallet_tips.rs --template=.maintain/runtime-weight-template.hbs --- runtimes/peregrine/src/weights/pallet_tips.rs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/runtimes/peregrine/src/weights/pallet_tips.rs b/runtimes/peregrine/src/weights/pallet_tips.rs index 5e144ca8d3..0eb673cc5b 100644 --- a/runtimes/peregrine/src/weights/pallet_tips.rs +++ b/runtimes/peregrine/src/weights/pallet_tips.rs @@ -16,25 +16,25 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -//! Autogenerated weights for `pallet_tips` +//! Autogenerated weights for pallet_tips //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-03-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 +//! DATE: 2022-04-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// target/release/kilt-parachain // benchmark -// --chain=kusama-dev +// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_tips +// --pallet=pallet-tips // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_tips.rs +// --output=./runtimes/peregrine/src/weights/pallet_tips.rs +// --template=.maintain/runtime-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,7 +50,7 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:1 w:1) fn report_awesome(r: u32, ) -> Weight { - (23_071_000 as Weight) + (40_320_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) @@ -59,48 +59,48 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn retract_tip() -> Weight { - (22_077_000 as Weight) + (36_908_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: PhragmenElection Members (r:1 w:0) + // Storage: TipsMembership Members (r:1 w:0) // Storage: Tips Reasons (r:1 w:1) // Storage: Tips Tips (r:0 w:1) fn tip_new(r: u32, t: u32, ) -> Weight { - (15_063_000 as Weight) + (26_418_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 3_000 - .saturating_add((88_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 0 + .saturating_add((102_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - // Storage: PhragmenElection Members (r:1 w:0) + // Storage: TipsMembership Members (r:1 w:0) // Storage: Tips Tips (r:1 w:1) fn tip(t: u32, ) -> Weight { - (8_709_000 as Weight) - // Standard Error: 1_000 - .saturating_add((315_000 as Weight).saturating_mul(t as Weight)) + (15_519_000 as Weight) + // Standard Error: 0 + .saturating_add((457_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Tips Tips (r:1 w:1) - // Storage: PhragmenElection Members (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: TipsMembership Members (r:1 w:0) + // Storage: System Account (r:2 w:2) // Storage: Tips Reasons (r:0 w:1) fn close_tip(t: u32, ) -> Weight { - (37_111_000 as Weight) - // Standard Error: 6_000 - .saturating_add((210_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + (64_426_000 as Weight) + // Standard Error: 0 + .saturating_add((300_000 as Weight).saturating_mul(t as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn slash_tip(t: u32, ) -> Weight { - (13_293_000 as Weight) - // Standard Error: 22_000 - .saturating_add((24_000 as Weight).saturating_mul(t as Weight)) + (22_294_000 as Weight) + // Standard Error: 0 + .saturating_add((6_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } From 1b469d95681951ab772e747eb216d26d32fe8397 Mon Sep 17 00:00:00 2001 From: William Freudenberger Date: Tue, 19 Apr 2022 10:08:47 +0200 Subject: [PATCH 7/7] =?UTF-8?q?refactor:=20apply=20suggestions=20from?= =?UTF-8?q?=C2=A0@ntn-x2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtimes/common/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtimes/common/src/lib.rs b/runtimes/common/src/lib.rs index 2c0fa5f8bb..c05f191df8 100644 --- a/runtimes/common/src/lib.rs +++ b/runtimes/common/src/lib.rs @@ -38,7 +38,7 @@ use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use sp_runtime::{ generic, traits::{IdentifyAccount, Verify}, - FixedPointNumber, MultiSignature, Perquintill, + FixedPointNumber, MultiSignature, Perquintill, SaturatedConversion, }; use sp_std::marker::PhantomData; @@ -165,7 +165,7 @@ where R: pallet_membership::Config, { fn max_len() -> usize { - >::MaxMembers::get() as usize + >::MaxMembers::get().saturated_into() } fn min_len() -> usize { @@ -175,7 +175,7 @@ where impl SortedMembers for Tippers where - R: pallet_membership::Config + frame_system::Config, + R: pallet_membership::Config, pallet_membership::Pallet: SortedMembers + Contains, { fn sorted_members() -> sp_std::vec::Vec {