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

Companion PR for Bounties #5715 #1336

Merged
merged 9 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 15 additions & 3 deletions runtime/common/src/crowdfund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,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 BountyDuration: 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 {
Expand All @@ -665,7 +671,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;
Expand All @@ -675,7 +681,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 BountyDuration = BountyDuration;
type MaximumReasonLength = MaximumReasonLength;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type ModuleId = TreasuryModuleId;
type WeightInfo = ();
}
Expand Down
20 changes: 16 additions & 4 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,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 BountyDuration: 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<
Expand All @@ -499,22 +505,28 @@ type ApproveOrigin = EnsureOneOf<
>;

impl pallet_treasury::Trait for Runtime {
type ModuleId = TreasuryModuleId;
type Currency = Balances;
type ApproveOrigin = ApproveOrigin;
type RejectOrigin = MoreThanHalfCouncil;
type Tippers = ElectionsPhragmen;
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 BountyDuration = BountyDuration;
type MaximumReasonLength = MaximumReasonLength;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type BurnDestination = Society;
type ModuleId = TreasuryModuleId;
type WeightInfo = ();
}

Expand Down
18 changes: 15 additions & 3 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,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 BountyDuration: 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<
Expand All @@ -560,13 +566,19 @@ 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 BountyDuration = BountyDuration;
type MaximumReasonLength = MaximumReasonLength;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type BurnDestination = ();
type WeightInfo = ();
}
Expand Down
10 changes: 3 additions & 7 deletions runtime/polkadot/tests/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ fn weight_of_phragmen_renounce_candidacy_is_correct() {

#[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 expected_weight = 43830000 + DbWeight::get().read + 2 * DbWeight::get().write;
let weight =
TreasuryCall::propose_spend::<Runtime>(Default::default(), Default::default()).get_dispatch_info().weight;

Expand All @@ -159,8 +158,7 @@ fn weight_of_treasury_propose_spend_is_correct() {

#[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 expected_weight = 12744000 + 2 * DbWeight::get().read + DbWeight::get().write;
let weight = TreasuryCall::approve_proposal::<Runtime>(Default::default()).get_dispatch_info().weight;

assert_eq!(weight, expected_weight);
Expand All @@ -170,9 +168,7 @@ fn weight_of_treasury_approve_proposal_is_correct() {
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 expected_weight = 26499000 + 675000 * 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);
Expand Down