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

Companion for #7536 (Pallet Treasury Refactor) #2025

Merged
24 commits merged into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1,944 changes: 1,248 additions & 696 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::Gene
vesting: vec![],
}),
pallet_vesting: Some(polkadot::VestingConfig { vesting: vec![] }),
pallet_treasury: Some(Default::default()),
shawntabrizi marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -589,6 +590,7 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
vesting: vec![],
}),
pallet_vesting: Some(kusama::VestingConfig { vesting: vec![] }),
pallet_treasury: Some(Default::default()),
}
}

Expand Down Expand Up @@ -1014,6 +1016,7 @@ pub fn polkadot_testnet_genesis(
vesting: vec![],
}),
pallet_vesting: Some(polkadot::VestingConfig { vesting: vec![] }),
pallet_treasury: Some(Default::default()),
}
}

Expand Down Expand Up @@ -1106,6 +1109,7 @@ pub fn kusama_testnet_genesis(
vesting: vec![],
}),
pallet_vesting: Some(kusama::VestingConfig { vesting: vec![] }),
pallet_treasury: Some(Default::default()),
}
}

Expand Down
8 changes: 7 additions & 1 deletion runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pallet-authority-discovery = { git = "https://github.com/paritytech/substrate",
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-bounties = { git = "https://github.com/shamb0/substrate.git", branch = "issue-7143-pallet-treasury-refactor", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand All @@ -60,7 +61,8 @@ pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "
frame-system = {git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-tips = { git = "https://github.com/shamb0/substrate.git", branch = "issue-7143-pallet-treasury-refactor", default-features = false }
pallet-treasury = { git = "https://github.com/shamb0/substrate.git", branch = "issue-7143-pallet-treasury-refactor", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

Expand Down Expand Up @@ -107,6 +109,7 @@ std = [
"frame-support/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-bounties/std",
"pallet-transaction-payment/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-collective/std",
Expand All @@ -132,6 +135,7 @@ std = [
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"pallet-timestamp/std",
"pallet-tips/std",
"pallet-treasury/std",
"sp-version/std",
"pallet-utility/std",
Expand All @@ -153,6 +157,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-bounties/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
Expand All @@ -166,6 +171,7 @@ runtime-benchmarks = [
"pallet-society/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-tips/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
Expand Down
41 changes: 33 additions & 8 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,25 +535,40 @@ impl pallet_treasury::Trait for Runtime {
type Currency = Balances;
type ApproveOrigin = ApproveOrigin;
type RejectOrigin = MoreThanHalfCouncil;
type Tippers = ElectionsPhragmen;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type DataDepositPerByte = DataDepositPerByte;
type Event = Event;
type OnSlash = Treasury;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type MaximumReasonLength = MaximumReasonLength;
type BurnDestination = Society;
type SpendFunds = Bounties;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
// type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
shawntabrizi marked this conversation as resolved.
Show resolved Hide resolved
}

impl pallet_bounties::Trait for Runtime {
type Event = Event;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type MaximumReasonLength = MaximumReasonLength;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type BurnDestination = Society;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
// type WeightInfo = weights::pallet_bounties::WeightInfo<Runtime>;

}

impl pallet_tips::Trait for Runtime {
type Event = Event;
type Tippers = ElectionsPhragmen;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
// type WeightInfo = weights::pallet_tips::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -930,7 +945,8 @@ construct_runtime! {
TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>} = 15,
ElectionsPhragmen: pallet_elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>} = 16,
TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>} = 17,
Treasury: pallet_treasury::{Module, Call, Storage, Event<T>} = 18,
// Treasury: pallet_treasury::{Module, Call, Storage, Event<T>} = 18,
gui1117 marked this conversation as resolved.
Show resolved Hide resolved
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>} = 18,

// Claims. Usable initially.
Claims: claims::{Module, Call, Storage, Event<T>, Config<T>, ValidateUnsigned} = 19,
Expand Down Expand Up @@ -958,6 +974,12 @@ construct_runtime! {

// Multisig module. Late addition.
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>} = 31,

// Bounties module.
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>} = 35,

// Tips module.
Tips: pallet_tips::{Module, Call, Storage, Event<T>} = 36,
}
}

Expand Down Expand Up @@ -1291,6 +1313,9 @@ sp_api::impl_runtime_apis! {
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_vesting, Vesting);

add_benchmark!(params, batches, pallet_bounties, Bounties);
add_benchmark!(params, batches, pallet_tips, Tips);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/kusama/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ pub mod pallet_timestamp;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
pub mod pallet_bounties;
pub mod pallet_tips;
185 changes: 185 additions & 0 deletions runtime/kusama/src/weights/pallet_bounties.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// This file is part of Substrate.

// 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.

//! Autogenerated weights for pallet_bounties
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
//! DATE: 2020-11-20, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128

// Executed Command:
// target/release/substrate
// benchmark
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_bounties
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./frame/bounties/src/weights.rs
// --template=./.maintain/frame-weight-template.hbs


#![allow(unused_parens)]
#![allow(unused_imports)]

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

/// Weight functions needed for pallet_bounties.
pub trait WeightInfo {
fn propose_bounty(d: u32, ) -> Weight;
fn approve_bounty() -> Weight;
fn propose_curator() -> Weight;
fn unassign_curator() -> Weight;
fn accept_curator() -> Weight;
fn award_bounty() -> Weight;
fn claim_bounty() -> Weight;
fn close_bounty_proposed() -> Weight;
fn close_bounty_active() -> Weight;
fn extend_bounty_expiry() -> Weight;
fn spend_funds(b: u32, ) -> Weight;
}

/// Weights for pallet_bounties using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Trait> WeightInfo for SubstrateWeight<T> {
fn propose_bounty(d: u32, ) -> Weight {
(59_931_000 as Weight)
.saturating_add((1_000 as Weight).saturating_mul(d as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn approve_bounty() -> Weight {
(17_226_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn propose_curator() -> Weight {
(13_314_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn unassign_curator() -> Weight {
(48_677_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn accept_curator() -> Weight {
(48_727_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn award_bounty() -> Weight {
(34_839_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn claim_bounty() -> Weight {
(64_883_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn close_bounty_proposed() -> Weight {
(48_003_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn close_bounty_active() -> Weight {
(62_215_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn extend_bounty_expiry() -> Weight {
(33_748_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn spend_funds(b: u32, ) -> Weight {
(3_688_000 as Weight)
.saturating_add((70_129_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
}
}

// For backwards compatibility and tests
impl WeightInfo for () {
fn propose_bounty(d: u32, ) -> Weight {
(59_931_000 as Weight)
.saturating_add((1_000 as Weight).saturating_mul(d as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
fn approve_bounty() -> Weight {
(17_226_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
fn propose_curator() -> Weight {
(13_314_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn unassign_curator() -> Weight {
(48_677_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
fn accept_curator() -> Weight {
(48_727_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
fn award_bounty() -> Weight {
(34_839_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn claim_bounty() -> Weight {
(64_883_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
fn close_bounty_proposed() -> Weight {
(48_003_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
fn close_bounty_active() -> Weight {
(62_215_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
fn extend_bounty_expiry() -> Weight {
(33_748_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn spend_funds(b: u32, ) -> Weight {
(3_688_000 as Weight)
.saturating_add((70_129_000 as Weight).saturating_mul(b as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(b as Weight)))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
.saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
}
}
Loading