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

Commit ecaf240

Browse files
xlcRRTTIshawntabrizi
authored andcommitted
Bounties (#5715)
* add some compact annotation * implement bounties for treasury * fix test build * remove some duplicated code * fix build * add tests * fix build * fix tests * rename * merge deposit byte fee * add comments * refactor storage * support sub bounty * emit BountyBecameActive when sub bounty is created * able to contribute bounty * allow curator to cancel bounty * remove bounty contribution * implement bounty expiry * Able to extend bounty * fix build and update tests * create sub bounty test * add more tests * add benchmarks for bounties * fix build * line width * fix benchmarking test * update trait * fix typo * Update lib.rs Missing documentation on Bounties added on this change. Please check the definitions of `propose_bounty` and `create_bounty`. * update docs * add MaximumSubBountyDepth * put BountyValueMinimum into storage * rework bount depth * split on_initialize benchmarks * remove components from constant functions * Update weight integration into treasury * Update reject proposal read/writes * fix weight calculation * Ignore weights with 0 factor * Remove 0 multipliers * add some docs * allow unused for generated code * line width * allow RejectOrigin to cancel a pending payout bounty * require BountyValueMinimum > ED * make BountyValueMinimum configurable by chain spec * remove sub-bounty features * update curator * accept curator * unassign and cancel * fix tests * new tests * Update lib.rs - Include on `Assign_curator`, `accept_curator` and `unassign_curator` on Bounties Protocol Section - Include curator fee and curator deposit definitions on Terminology - Update intro. * fix test * update extend_bounty_expiry * fix benchmarking * add new benchmarking code * add docs * fix tests * Update benchmarking.rs * Make BountyValueMinimum a trait config instead of stroage value * fix runtime build * Update weights * Update default_weights.rs * update weights * update * update comments * unreserve curator fee * update tests * update benchmarks * fix curator deposit handling * trigger CI * fix benchmarking * use append instead of mutate push * additional noop tests * improve fee hanlding. update event docs * RejectOrigin to unassign * update bounty cancel logic * use Zero::zero() over 0.into() * fix tests * fix benchmarks * proposed fixes to bounties * fix tests * fix benchmarks * update weightinfo * use closure * fix compile * update weights Co-authored-by: RRTTI <[email protected]> Co-authored-by: Shawn Tabrizi <[email protected]>
1 parent f8ee0e1 commit ecaf240

File tree

8 files changed

+1668
-138
lines changed

8 files changed

+1668
-138
lines changed

bin/node/runtime/src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,14 @@ parameter_types! {
602602
pub const TipCountdown: BlockNumber = 1 * DAYS;
603603
pub const TipFindersFee: Percent = Percent::from_percent(20);
604604
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
605-
pub const TipReportDepositPerByte: Balance = 1 * CENTS;
605+
pub const DataDepositPerByte: Balance = 1 * CENTS;
606+
pub const BountyDepositBase: Balance = 1 * DOLLARS;
607+
pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
606608
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
609+
pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
610+
pub const MaximumReasonLength: u32 = 16384;
611+
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
612+
pub const BountyValueMinimum: Balance = 5 * DOLLARS;
607613
}
608614

609615
impl pallet_treasury::Trait for Runtime {
@@ -623,15 +629,21 @@ impl pallet_treasury::Trait for Runtime {
623629
type TipCountdown = TipCountdown;
624630
type TipFindersFee = TipFindersFee;
625631
type TipReportDepositBase = TipReportDepositBase;
626-
type TipReportDepositPerByte = TipReportDepositPerByte;
632+
type DataDepositPerByte = DataDepositPerByte;
627633
type Event = Event;
628-
type ProposalRejection = ();
634+
type OnSlash = ();
629635
type ProposalBond = ProposalBond;
630636
type ProposalBondMinimum = ProposalBondMinimum;
631637
type SpendPeriod = SpendPeriod;
632638
type Burn = Burn;
639+
type BountyDepositBase = BountyDepositBase;
640+
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
641+
type BountyUpdatePeriod = BountyUpdatePeriod;
642+
type BountyCuratorDeposit = BountyCuratorDeposit;
643+
type BountyValueMinimum = BountyValueMinimum;
644+
type MaximumReasonLength = MaximumReasonLength;
633645
type BurnDestination = ();
634-
type WeightInfo = ();
646+
type WeightInfo = weights::pallet_treasury::WeightInfo;
635647
}
636648

637649
parameter_types! {

bin/node/runtime/src/weights/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1818
pub mod frame_system;
1919
pub mod pallet_balances;
20+
pub mod pallet_treasury;
2021
pub mod pallet_collective;
2122
pub mod pallet_democracy;
2223
pub mod pallet_identity;
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// This file is part of Substrate.
2+
3+
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc6
19+
20+
#![allow(unused_parens)]
21+
#![allow(unused_imports)]
22+
23+
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
24+
25+
pub struct WeightInfo;
26+
impl pallet_treasury::WeightInfo for WeightInfo {
27+
fn propose_spend() -> Weight {
28+
(79604000 as Weight)
29+
.saturating_add(DbWeight::get().reads(1 as Weight))
30+
.saturating_add(DbWeight::get().writes(2 as Weight))
31+
}
32+
fn reject_proposal() -> Weight {
33+
(61001000 as Weight)
34+
.saturating_add(DbWeight::get().reads(2 as Weight))
35+
.saturating_add(DbWeight::get().writes(2 as Weight))
36+
}
37+
fn approve_proposal() -> Weight {
38+
(17835000 as Weight)
39+
.saturating_add(DbWeight::get().reads(2 as Weight))
40+
.saturating_add(DbWeight::get().writes(1 as Weight))
41+
}
42+
fn report_awesome(r: u32, ) -> Weight {
43+
(101602000 as Weight)
44+
.saturating_add((2000 as Weight).saturating_mul(r as Weight))
45+
.saturating_add(DbWeight::get().reads(2 as Weight))
46+
.saturating_add(DbWeight::get().writes(2 as Weight))
47+
}
48+
// WARNING! Some components were not used: ["r"]
49+
fn retract_tip() -> Weight {
50+
(82970000 as Weight)
51+
.saturating_add(DbWeight::get().reads(1 as Weight))
52+
.saturating_add(DbWeight::get().writes(2 as Weight))
53+
}
54+
fn tip_new(r: u32, t: u32, ) -> Weight {
55+
(63995000 as Weight)
56+
.saturating_add((2000 as Weight).saturating_mul(r as Weight))
57+
.saturating_add((153000 as Weight).saturating_mul(t as Weight))
58+
.saturating_add(DbWeight::get().reads(2 as Weight))
59+
.saturating_add(DbWeight::get().writes(2 as Weight))
60+
}
61+
fn tip(t: u32, ) -> Weight {
62+
(46765000 as Weight)
63+
.saturating_add((711000 as Weight).saturating_mul(t as Weight))
64+
.saturating_add(DbWeight::get().reads(2 as Weight))
65+
.saturating_add(DbWeight::get().writes(1 as Weight))
66+
}
67+
fn close_tip(t: u32, ) -> Weight {
68+
(160874000 as Weight)
69+
.saturating_add((379000 as Weight).saturating_mul(t as Weight))
70+
.saturating_add(DbWeight::get().reads(3 as Weight))
71+
.saturating_add(DbWeight::get().writes(3 as Weight))
72+
}
73+
fn propose_bounty(d: u32, ) -> Weight {
74+
(86198000 as Weight)
75+
.saturating_add((1000 as Weight).saturating_mul(d as Weight))
76+
.saturating_add(DbWeight::get().reads(2 as Weight))
77+
.saturating_add(DbWeight::get().writes(4 as Weight))
78+
}
79+
fn approve_bounty() -> Weight {
80+
(23063000 as Weight)
81+
.saturating_add(DbWeight::get().reads(2 as Weight))
82+
.saturating_add(DbWeight::get().writes(2 as Weight))
83+
}
84+
fn propose_curator() -> Weight {
85+
(18890000 as Weight)
86+
.saturating_add(DbWeight::get().reads(1 as Weight))
87+
.saturating_add(DbWeight::get().writes(1 as Weight))
88+
}
89+
fn unassign_curator() -> Weight {
90+
(66768000 as Weight)
91+
.saturating_add(DbWeight::get().reads(2 as Weight))
92+
.saturating_add(DbWeight::get().writes(2 as Weight))
93+
}
94+
fn accept_curator() -> Weight {
95+
(69131000 as Weight)
96+
.saturating_add(DbWeight::get().reads(2 as Weight))
97+
.saturating_add(DbWeight::get().writes(2 as Weight))
98+
}
99+
fn award_bounty() -> Weight {
100+
(48184000 as Weight)
101+
.saturating_add(DbWeight::get().reads(1 as Weight))
102+
.saturating_add(DbWeight::get().writes(1 as Weight))
103+
}
104+
fn claim_bounty() -> Weight {
105+
(243104000 as Weight)
106+
.saturating_add(DbWeight::get().reads(4 as Weight))
107+
.saturating_add(DbWeight::get().writes(5 as Weight))
108+
}
109+
fn close_bounty_proposed() -> Weight {
110+
(65917000 as Weight)
111+
.saturating_add(DbWeight::get().reads(2 as Weight))
112+
.saturating_add(DbWeight::get().writes(3 as Weight))
113+
}
114+
fn close_bounty_active() -> Weight {
115+
(157232000 as Weight)
116+
.saturating_add(DbWeight::get().reads(3 as Weight))
117+
.saturating_add(DbWeight::get().writes(4 as Weight))
118+
}
119+
fn extend_bounty_expiry() -> Weight {
120+
(46216000 as Weight)
121+
.saturating_add(DbWeight::get().reads(1 as Weight))
122+
.saturating_add(DbWeight::get().writes(1 as Weight))
123+
}
124+
fn on_initialize_proposals(p: u32, ) -> Weight {
125+
(119765000 as Weight)
126+
.saturating_add((108368000 as Weight).saturating_mul(p as Weight))
127+
.saturating_add(DbWeight::get().reads(2 as Weight))
128+
.saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight)))
129+
.saturating_add(DbWeight::get().writes(2 as Weight))
130+
.saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight)))
131+
}
132+
fn on_initialize_bounties(b: u32, ) -> Weight {
133+
(112536000 as Weight)
134+
.saturating_add((107132000 as Weight).saturating_mul(b as Weight))
135+
.saturating_add(DbWeight::get().reads(2 as Weight))
136+
.saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight)))
137+
.saturating_add(DbWeight::get().writes(2 as Weight))
138+
.saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
139+
}
140+
}

frame/treasury/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ std = [
4141
runtime-benchmarks = [
4242
"frame-benchmarking",
4343
"frame-support/runtime-benchmarks",
44+
"frame-system/runtime-benchmarks",
4445
]

0 commit comments

Comments
 (0)