mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 13:08:03 +00:00
* update for treasury bounty * update trait * add weightinfo * remove old weight tests * "Update Substrate" * remove unused deps Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+134
-134
File diff suppressed because it is too large
Load Diff
@@ -647,8 +647,14 @@ mod tests {
|
||||
pub const TipCountdown: u64 = 1;
|
||||
pub const TipFindersFee: Percent = Percent::from_percent(20);
|
||||
pub const TipReportDepositBase: u64 = 1;
|
||||
pub const TipReportDepositPerByte: u64 = 1;
|
||||
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
|
||||
pub const DataDepositPerByte: u64 = 1;
|
||||
pub const BountyDepositBase: u64 = 1;
|
||||
pub const BountyDepositPayoutDelay: u64 = 1;
|
||||
pub const BountyUpdatePeriod: u64 = 1;
|
||||
pub const MaximumReasonLength: u32 = 16384;
|
||||
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
|
||||
pub const BountyValueMinimum: u64 = 1;
|
||||
}
|
||||
pub struct Nobody;
|
||||
impl Contains<u64> for Nobody {
|
||||
@@ -666,7 +672,7 @@ mod tests {
|
||||
type ApproveOrigin = frame_system::EnsureRoot<u64>;
|
||||
type RejectOrigin = frame_system::EnsureRoot<u64>;
|
||||
type Event = ();
|
||||
type ProposalRejection = ();
|
||||
type OnSlash = ();
|
||||
type ProposalBond = ProposalBond;
|
||||
type ProposalBondMinimum = ProposalBondMinimum;
|
||||
type SpendPeriod = SpendPeriod;
|
||||
@@ -676,7 +682,13 @@ mod tests {
|
||||
type TipCountdown = TipCountdown;
|
||||
type TipFindersFee = TipFindersFee;
|
||||
type TipReportDepositBase = TipReportDepositBase;
|
||||
type TipReportDepositPerByte = TipReportDepositPerByte;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type BountyDepositBase = BountyDepositBase;
|
||||
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
|
||||
type BountyUpdatePeriod = BountyUpdatePeriod;
|
||||
type MaximumReasonLength = MaximumReasonLength;
|
||||
type BountyCuratorDeposit = BountyCuratorDeposit;
|
||||
type BountyValueMinimum = BountyValueMinimum;
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
@@ -494,7 +494,13 @@ parameter_types! {
|
||||
pub const TipCountdown: BlockNumber = 1 * DAYS;
|
||||
pub const TipFindersFee: Percent = Percent::from_percent(20);
|
||||
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
|
||||
pub const TipReportDepositPerByte: Balance = 1 * CENTS;
|
||||
pub const DataDepositPerByte: Balance = 1 * CENTS;
|
||||
pub const BountyDepositBase: Balance = 1 * DOLLARS;
|
||||
pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
|
||||
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
|
||||
pub const MaximumReasonLength: u32 = 16384;
|
||||
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
|
||||
pub const BountyValueMinimum: Balance = 2 * DOLLARS;
|
||||
}
|
||||
|
||||
type ApproveOrigin = EnsureOneOf<
|
||||
@@ -504,6 +510,7 @@ type ApproveOrigin = EnsureOneOf<
|
||||
>;
|
||||
|
||||
impl pallet_treasury::Trait for Runtime {
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type Currency = Balances;
|
||||
type ApproveOrigin = ApproveOrigin;
|
||||
type RejectOrigin = MoreThanHalfCouncil;
|
||||
@@ -511,16 +518,21 @@ impl pallet_treasury::Trait for Runtime {
|
||||
type TipCountdown = TipCountdown;
|
||||
type TipFindersFee = TipFindersFee;
|
||||
type TipReportDepositBase = TipReportDepositBase;
|
||||
type TipReportDepositPerByte = TipReportDepositPerByte;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type Event = Event;
|
||||
type ProposalRejection = Treasury;
|
||||
type OnSlash = Treasury;
|
||||
type ProposalBond = ProposalBond;
|
||||
type ProposalBondMinimum = ProposalBondMinimum;
|
||||
type SpendPeriod = SpendPeriod;
|
||||
type Burn = Burn;
|
||||
type BountyDepositBase = BountyDepositBase;
|
||||
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
|
||||
type BountyUpdatePeriod = BountyUpdatePeriod;
|
||||
type MaximumReasonLength = MaximumReasonLength;
|
||||
type BountyCuratorDeposit = BountyCuratorDeposit;
|
||||
type BountyValueMinimum = BountyValueMinimum;
|
||||
type BurnDestination = Society;
|
||||
type ModuleId = TreasuryModuleId;
|
||||
type WeightInfo = ();
|
||||
type WeightInfo = weights::pallet_treasury::WeightInfo;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -23,5 +23,6 @@ pub mod pallet_democracy;
|
||||
pub mod pallet_proxy;
|
||||
pub mod pallet_staking;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_treasury;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_vesting;
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc6
|
||||
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
|
||||
|
||||
pub struct WeightInfo;
|
||||
impl pallet_treasury::WeightInfo for WeightInfo {
|
||||
fn propose_spend() -> Weight {
|
||||
(79604000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn reject_proposal() -> Weight {
|
||||
(61001000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn approve_proposal() -> Weight {
|
||||
(17835000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn report_awesome(r: u32, ) -> Weight {
|
||||
(101602000 as Weight)
|
||||
.saturating_add((2000 as Weight).saturating_mul(r as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// WARNING! Some components were not used: ["r"]
|
||||
fn retract_tip() -> Weight {
|
||||
(82970000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn tip_new(r: u32, t: u32, ) -> Weight {
|
||||
(63995000 as Weight)
|
||||
.saturating_add((2000 as Weight).saturating_mul(r as Weight))
|
||||
.saturating_add((153000 as Weight).saturating_mul(t as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn tip(t: u32, ) -> Weight {
|
||||
(46765000 as Weight)
|
||||
.saturating_add((711000 as Weight).saturating_mul(t as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn close_tip(t: u32, ) -> Weight {
|
||||
(160874000 as Weight)
|
||||
.saturating_add((379000 as Weight).saturating_mul(t as Weight))
|
||||
.saturating_add(DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn propose_bounty(d: u32, ) -> Weight {
|
||||
(86198000 as Weight)
|
||||
.saturating_add((1000 as Weight).saturating_mul(d as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn approve_bounty() -> Weight {
|
||||
(23063000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn propose_curator() -> Weight {
|
||||
(18890000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn unassign_curator() -> Weight {
|
||||
(66768000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn accept_curator() -> Weight {
|
||||
(69131000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn award_bounty() -> Weight {
|
||||
(48184000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn claim_bounty() -> Weight {
|
||||
(243104000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(5 as Weight))
|
||||
}
|
||||
fn close_bounty_proposed() -> Weight {
|
||||
(65917000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn close_bounty_active() -> Weight {
|
||||
(157232000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn extend_bounty_expiry() -> Weight {
|
||||
(46216000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn on_initialize_proposals(p: u32, ) -> Weight {
|
||||
(119765000 as Weight)
|
||||
.saturating_add((108368000 as Weight).saturating_mul(p as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight)))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight)))
|
||||
}
|
||||
fn on_initialize_bounties(b: u32, ) -> Weight {
|
||||
(112536000 as Weight)
|
||||
.saturating_add((107132000 as Weight).saturating_mul(b as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight)))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
|
||||
}
|
||||
}
|
||||
@@ -550,7 +550,13 @@ parameter_types! {
|
||||
pub const TipCountdown: BlockNumber = 1 * DAYS;
|
||||
pub const TipFindersFee: Percent = Percent::from_percent(20);
|
||||
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
|
||||
pub const TipReportDepositPerByte: Balance = 1 * CENTS;
|
||||
pub const DataDepositPerByte: Balance = 1 * CENTS;
|
||||
pub const BountyDepositBase: Balance = 1 * DOLLARS;
|
||||
pub const BountyDepositPayoutDelay: BlockNumber = 8 * DAYS;
|
||||
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
|
||||
pub const MaximumReasonLength: u32 = 16384;
|
||||
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
|
||||
pub const BountyValueMinimum: Balance = 10 * DOLLARS;
|
||||
}
|
||||
|
||||
type ApproveOrigin = EnsureOneOf<
|
||||
@@ -568,15 +574,21 @@ impl pallet_treasury::Trait for Runtime {
|
||||
type TipCountdown = TipCountdown;
|
||||
type TipFindersFee = TipFindersFee;
|
||||
type TipReportDepositBase = TipReportDepositBase;
|
||||
type TipReportDepositPerByte = TipReportDepositPerByte;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type Event = Event;
|
||||
type ProposalRejection = Treasury;
|
||||
type OnSlash = Treasury;
|
||||
type ProposalBond = ProposalBond;
|
||||
type ProposalBondMinimum = ProposalBondMinimum;
|
||||
type SpendPeriod = SpendPeriod;
|
||||
type Burn = Burn;
|
||||
type BountyDepositBase = BountyDepositBase;
|
||||
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
|
||||
type BountyUpdatePeriod = BountyUpdatePeriod;
|
||||
type MaximumReasonLength = MaximumReasonLength;
|
||||
type BountyCuratorDeposit = BountyCuratorDeposit;
|
||||
type BountyValueMinimum = BountyValueMinimum;
|
||||
type BurnDestination = ();
|
||||
type WeightInfo = ();
|
||||
type WeightInfo = weights::pallet_treasury::WeightInfo;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -23,5 +23,6 @@ pub mod pallet_democracy;
|
||||
pub mod pallet_proxy;
|
||||
pub mod pallet_staking;
|
||||
pub mod pallet_timestamp;
|
||||
pub mod pallet_treasury;
|
||||
pub mod pallet_utility;
|
||||
pub mod pallet_vesting;
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc6
|
||||
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
|
||||
|
||||
pub struct WeightInfo;
|
||||
impl pallet_treasury::WeightInfo for WeightInfo {
|
||||
fn propose_spend() -> Weight {
|
||||
(79604000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn reject_proposal() -> Weight {
|
||||
(61001000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn approve_proposal() -> Weight {
|
||||
(17835000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn report_awesome(r: u32, ) -> Weight {
|
||||
(101602000 as Weight)
|
||||
.saturating_add((2000 as Weight).saturating_mul(r as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// WARNING! Some components were not used: ["r"]
|
||||
fn retract_tip() -> Weight {
|
||||
(82970000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn tip_new(r: u32, t: u32, ) -> Weight {
|
||||
(63995000 as Weight)
|
||||
.saturating_add((2000 as Weight).saturating_mul(r as Weight))
|
||||
.saturating_add((153000 as Weight).saturating_mul(t as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn tip(t: u32, ) -> Weight {
|
||||
(46765000 as Weight)
|
||||
.saturating_add((711000 as Weight).saturating_mul(t as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn close_tip(t: u32, ) -> Weight {
|
||||
(160874000 as Weight)
|
||||
.saturating_add((379000 as Weight).saturating_mul(t as Weight))
|
||||
.saturating_add(DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn propose_bounty(d: u32, ) -> Weight {
|
||||
(86198000 as Weight)
|
||||
.saturating_add((1000 as Weight).saturating_mul(d as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn approve_bounty() -> Weight {
|
||||
(23063000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn propose_curator() -> Weight {
|
||||
(18890000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn unassign_curator() -> Weight {
|
||||
(66768000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn accept_curator() -> Weight {
|
||||
(69131000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn award_bounty() -> Weight {
|
||||
(48184000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn claim_bounty() -> Weight {
|
||||
(243104000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(5 as Weight))
|
||||
}
|
||||
fn close_bounty_proposed() -> Weight {
|
||||
(65917000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn close_bounty_active() -> Weight {
|
||||
(157232000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn extend_bounty_expiry() -> Weight {
|
||||
(46216000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn on_initialize_proposals(p: u32, ) -> Weight {
|
||||
(119765000 as Weight)
|
||||
.saturating_add((108368000 as Weight).saturating_mul(p as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight)))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight)))
|
||||
}
|
||||
fn on_initialize_bounties(b: u32, ) -> Weight {
|
||||
(112536000 as Weight)
|
||||
.saturating_add((107132000 as Weight).saturating_mul(b as Weight))
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight)))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
|
||||
}
|
||||
}
|
||||
@@ -28,41 +28,16 @@
|
||||
//! $ cargo test -p polkadot-runtime -- --nocapture --test-threads=1
|
||||
//! ```
|
||||
|
||||
use codec::Encode;
|
||||
use frame_support::{
|
||||
traits::ContainsLengthBound,
|
||||
weights::{constants::*, GetDispatchInfo, Weight, DispatchInfo},
|
||||
};
|
||||
use keyring::AccountKeyring;
|
||||
use polkadot_runtime::constants::currency::*;
|
||||
use frame_support::weights::{constants::*, GetDispatchInfo};
|
||||
use polkadot_runtime::{self, Runtime};
|
||||
use primitives::v0::AccountId;
|
||||
use runtime_common::MaximumBlockWeight;
|
||||
|
||||
use pallet_elections_phragmen::Call as PhragmenCall;
|
||||
use pallet_session::Call as SessionCall;
|
||||
use pallet_staking::Call as StakingCall;
|
||||
use frame_system::Call as SystemCall;
|
||||
use pallet_treasury::Call as TreasuryCall;
|
||||
|
||||
type DbWeight = <Runtime as frame_system::Trait>::DbWeight;
|
||||
|
||||
|
||||
fn report_portion(name: &'static str, info: DispatchInfo, len: usize) {
|
||||
let maximum_weight = <Runtime as frame_system::Trait>::MaximumBlockWeight::get();
|
||||
let fee = sp_io::TestExternalities::new(Default::default()).execute_with(|| {
|
||||
<pallet_transaction_payment::Module<Runtime>>::compute_fee(len as u32, &info, 0)
|
||||
});
|
||||
|
||||
let portion = info.weight as f64 / maximum_weight as f64;
|
||||
|
||||
if portion > 0.5 {
|
||||
panic!("Weight of some call seem to have exceeded half of the block. Probably something is wrong.");
|
||||
}
|
||||
|
||||
println!("\nCall {} (with default args) takes {} of the block weight, pays {} in fee.", name, portion, fee);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanity_check_weight_per_time_constants_are_as_expected() {
|
||||
// These values comes from Substrate, we want to make sure that if it
|
||||
@@ -73,70 +48,6 @@ fn sanity_check_weight_per_time_constants_are_as_expected() {
|
||||
assert_eq!(WEIGHT_PER_NANOS, WEIGHT_PER_MICROS / 1000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_staking_bond_is_correct() {
|
||||
let controller: AccountId = AccountKeyring::Alice.into();
|
||||
|
||||
// (144278000 as Weight)
|
||||
// .saturating_add(DbWeight::get().reads(5 as Weight))
|
||||
// .saturating_add(DbWeight::get().writes(4 as Weight))
|
||||
let expected_weight = 144278000 + (DbWeight::get().read * 5) + (DbWeight::get().write * 4);
|
||||
let call = StakingCall::bond::<Runtime>(controller, 1 * DOLLARS, Default::default());
|
||||
let info = call.get_dispatch_info();
|
||||
|
||||
assert_eq!(info.weight, expected_weight);
|
||||
report_portion("staking_bond", info, call.encode().len())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_staking_validate_is_correct() {
|
||||
// (35539000 as Weight)
|
||||
// .saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
// .saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
let expected_weight = 35539000 + (DbWeight::get().read * 2) + (DbWeight::get().write * 2);
|
||||
let call = StakingCall::validate::<Runtime>(Default::default());
|
||||
let info = call.get_dispatch_info();
|
||||
|
||||
assert_eq!(info.weight, expected_weight);
|
||||
report_portion("staking_validate", info, call.encode().len())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_staking_nominate_is_correct() {
|
||||
let targets: Vec<AccountId> = vec![Default::default(), Default::default(), Default::default()];
|
||||
|
||||
// (48596000 as Weight)
|
||||
// .saturating_add((308000 as Weight).saturating_mul(n as Weight))
|
||||
// .saturating_add(DbWeight::get().reads(3 as Weight))
|
||||
// .saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
let db_weight = (DbWeight::get().read * 3) + (DbWeight::get().write * 2);
|
||||
let targets_weight = (308 * WEIGHT_PER_NANOS).saturating_mul(targets.len() as Weight);
|
||||
|
||||
let expected_weight = db_weight.saturating_add(48596000).saturating_add(targets_weight);
|
||||
let call = StakingCall::nominate::<Runtime>(targets);
|
||||
let info = call.get_dispatch_info();
|
||||
|
||||
assert_eq!(info.weight, expected_weight);
|
||||
report_portion("staking_nominate", info, call.encode().len())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_staking_payout_staker_is_correct() {
|
||||
// (0 as Weight)
|
||||
// .saturating_add((117324000 as Weight).saturating_mul(n as Weight))
|
||||
// .saturating_add(DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight)))
|
||||
// .saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight)))
|
||||
let call = StakingCall::payout_stakers::<Runtime>(Default::default(), 0u32);
|
||||
let info = call.get_dispatch_info();
|
||||
|
||||
let n = <Runtime as pallet_staking::Trait>::MaxNominatorRewardedPerValidator::get() as Weight;
|
||||
let mut expected_weight = (117324000 as Weight).saturating_mul(n as Weight);
|
||||
expected_weight += (DbWeight::get().read * 5 * n) + (DbWeight::get().write * 3 * n);
|
||||
|
||||
assert_eq!(info.weight, expected_weight);
|
||||
report_portion("staking_payout_stakers", info, call.encode().len())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_system_set_code_is_correct() {
|
||||
// #[weight = (T::MaximumBlockWeight::get(), DispatchClass::Operational)]
|
||||
@@ -196,34 +107,3 @@ fn weight_of_phragmen_renounce_candidacy_is_correct() {
|
||||
|
||||
assert_eq!(weight, expected_weight);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_treasury_propose_spend_is_correct() {
|
||||
// #[weight = 120_000_000 + T::DbWeight::get().reads_writes(1, 2)]
|
||||
let expected_weight = 120_000_000 + DbWeight::get().read + 2 * DbWeight::get().write;
|
||||
let weight =
|
||||
TreasuryCall::propose_spend::<Runtime>(Default::default(), Default::default()).get_dispatch_info().weight;
|
||||
|
||||
assert_eq!(weight, expected_weight);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_treasury_approve_proposal_is_correct() {
|
||||
// #[weight = (34_000_000 + T::DbWeight::get().reads_writes(2, 1), DispatchClass::Operational)]
|
||||
let expected_weight = 34_000_000 + 2 * DbWeight::get().read + DbWeight::get().write;
|
||||
let weight = TreasuryCall::approve_proposal::<Runtime>(Default::default()).get_dispatch_info().weight;
|
||||
|
||||
assert_eq!(weight, expected_weight);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weight_of_treasury_tip_is_correct() {
|
||||
let max_len: Weight = <Runtime as pallet_treasury::Trait>::Tippers::max_len() as Weight;
|
||||
|
||||
// #[weight = 68_000_000 + 2_000_000 * T::Tippers::max_len() as Weight
|
||||
// + T::DbWeight::get().reads_writes(2, 1)]
|
||||
let expected_weight = 68_000_000 + 2_000_000 * max_len + 2 * DbWeight::get().read + DbWeight::get().write;
|
||||
let weight = TreasuryCall::tip::<Runtime>(Default::default(), Default::default()).get_dispatch_info().weight;
|
||||
|
||||
assert_eq!(weight, expected_weight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user