Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
d3dc12d
wk2046 | D5 | treasury refactor to bounties and tips
shamb0 Nov 12, 2020
70472aa
wk2046 | D5 | treasury refactor to bounties and tips | p2
shamb0 Nov 12, 2020
a861aec
fix test compilation, ignoring events
shawntabrizi Nov 13, 2020
8718f33
initialize treasury in genesis
shawntabrizi Nov 13, 2020
6b4dba5
wk2046 | D7 | treasury refactor | fix bounties test build issues
shamb0 Nov 14, 2020
6c01a91
wk2046 | D7 | treasury refactor | fix bounties test build issues | p2
shamb0 Nov 14, 2020
7bad294
wk2047 | D1 | treasury refactor | tips pallet bringup
shamb0 Nov 15, 2020
86d62ed
wk2047 | D2 | treasury refactor | bounties pallet | unit test bringup
shamb0 Nov 16, 2020
b6ba7f3
wk2047 | D2 | treasury refactor | bounties pallet | unit test bringu…
shamb0 Nov 16, 2020
f117afb
wk2047 | D2 | treasury refactor | pallet-tips| test_last_reward_migra…
shamb0 Nov 16, 2020
3993955
wk2047 | D3 | treasury refactor | pallet-tips| test_last_reward_migra…
shamb0 Nov 17, 2020
9ed2050
wk2047 | D3 | treasury refactor | pallet-bounties | on_initialize() fix
shamb0 Nov 17, 2020
90e2fc3
wk2047 | D3 | treasury refactor | pallet-bounties | on_initialize() f…
shamb0 Nov 17, 2020
508e35e
wk2047 | D4 | treasury refactor | pallet-bounties + pallet-treasury |…
shamb0 Nov 18, 2020
79ddceb
wk2047 | D4 | treasury refactor | pallet-bounties + pallet-treasury |…
shamb0 Nov 18, 2020
49eb073
wk2047 | D4 | treasury refactor | pallet-bounties + pallet-treasury |…
shamb0 Nov 18, 2020
30d2458
wk2047 | D5 | treasury refactor | pallet-bounties + pallet-treasury |…
shamb0 Nov 19, 2020
82d467b
wk2047 | D6 | treasury refactor | review comments fix
shamb0 Nov 20, 2020
3420f4f
some fixes
shawntabrizi Nov 20, 2020
3695aaa
fix bounties instantiable
shawntabrizi Nov 20, 2020
0f014c4
remove instantiable from tips and bounties
shawntabrizi Nov 20, 2020
4581de9
fix compile for benchmarks
shawntabrizi Nov 20, 2020
a15b390
Merge remote-tracking branch 'origin/master' into shawntabrizi-treasu…
Nov 20, 2020
c7ee055
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Nov 20, 2020
da9418e
Update lib.rs
shawntabrizi Nov 20, 2020
40ff8fa
Merge branch 'shawntabrizi-treasury-refactor-weights' of https://gith…
shawntabrizi Nov 20, 2020
dcaddeb
Merge remote-tracking branch 'origin/master' into shawntabrizi-treasu…
Nov 20, 2020
9524f69
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Nov 20, 2020
c0e3f34
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Nov 20, 2020
03e0eee
add back `on_initialize_bounties`
shawntabrizi Nov 20, 2020
b694ef3
patch up bounties benchmarks
shawntabrizi Nov 20, 2020
8c955ac
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Nov 20, 2020
0473842
Remove development TODO from public doc comment (#7500)
c410-f3r Nov 9, 2020
d86a662
refactor subtrait/elevated trait as not needed (#7497)
gui1117 Nov 9, 2020
66d998c
Fix comments of indices pallet events (#7511)
alecalve Nov 10, 2020
e366227
Skip slot lenience on first block in BABE (#7515)
bkchr Nov 11, 2020
d35dee6
slots: incrementally backoff claiming slots if finality lags behind (…
octol Nov 11, 2020
30753b4
Export app-crypto specific keystore functions (#7489)
sorpaas Nov 11, 2020
edf0b8f
Update doc for the --chain flag (#7520)
pepyakin Nov 12, 2020
9af39e4
contracts: Add missing instruction to the `Schedule` (#7527)
athei Nov 12, 2020
9c2f0e7
Don't log with colors when we are writing to a tty (#7525)
bkchr Nov 12, 2020
c9eaf2f
MemoryId -> u32 (#7534)
tomaka Nov 13, 2020
1c12637
Enable local addresses in DHT when chain type == `Local` | `Developme…
bkchr Nov 13, 2020
70ed34c
Update tiny-bip39 to v0.8 (#7539)
Nov 14, 2020
a2ad750
make LocalCallExecutor public (#7528)
insipx Nov 16, 2020
2b81c88
Fix some weirdness in `offchain_worker` (#7541)
bkchr Nov 16, 2020
8a99973
Use inbound peerslot slots when a substream is received, rather than …
tomaka Nov 16, 2020
e3f9ca8
*: Update to libp2p v0.30.0 (#7508)
mxinden Nov 16, 2020
251ac5a
make ClientConfig public (#7544)
insipx Nov 16, 2020
385476c
sc-basic-authorship: remove useless dependencies (#7550)
koushiro Nov 18, 2020
272077c
Add slashing events to elections-phragmen. (#7543)
kianenigma Nov 18, 2020
b552b03
Remove necessity to pass ConsensusEngineId when registering notificat…
tomaka Nov 18, 2020
353fe4e
sc-cli: replace bip39 with tiny-bip39 (#7551)
koushiro Nov 18, 2020
a4ff31e
Add extra docs to on_initialize (#7552)
tomusdrw Nov 18, 2020
c7ba4cf
More Extensible Multiaddress Format (#7380)
shawntabrizi Nov 19, 2020
09759a0
Fix weight template to remove ugliness in rust doc (#7565)
athei Nov 20, 2020
2b5ebd8
Cargo.lock: Run cargo update (#7553)
mxinden Nov 20, 2020
6ca63ba
.github: Add dependabot config and thus enable dependabot (#7509)
mxinden Nov 20, 2020
2be0efb
Thread-local parameter_types for testing. (#7542)
kianenigma Nov 20, 2020
97ad351
Bump wasm-bindgen-test from 0.3.12 to 0.3.17 (#7567)
dependabot[bot] Nov 20, 2020
6fe7112
Merge pull request #1 from paritytech/shawntabrizi-treasury-refactor-…
shamb0 Nov 21, 2020
ffcc899
Merge remote-tracking branch 'upstream/master' into issue-7143-pallet…
shamb0 Nov 21, 2020
2a01b6d
Merge branch 'issue-7143-pallet-treasury-refactor' of github.com:sham…
shamb0 Nov 21, 2020
b81a858
wk2047 | D6 | treasury refactor | review comments fix | p2
shamb0 Nov 21, 2020
18449c1
wk2048 | D1 | treasury refactor | review comments fix | p3
shamb0 Nov 22, 2020
a17a4fe
Merge branch 'master' into pr/7536
shawntabrizi Nov 23, 2020
9578fec
Merge remote-tracking branch 'upstream/master' into issue-7143-pallet…
shamb0 Nov 24, 2020
716c155
Merge branch 'issue-7143-pallet-treasury-refactor' of github.com:sham…
shamb0 Nov 24, 2020
de84b90
Update bin/node/runtime/src/lib.rs
shamb0 Nov 24, 2020
7790282
Update bin/node/runtime/src/lib.rs
shamb0 Nov 24, 2020
f4efda9
wk2048 | D3 | treasury refactor | review comments fix | p4
shamb0 Nov 24, 2020
1bfd2de
wk2048 | D3 | treasury refactor | review comments fix | p5
shamb0 Nov 24, 2020
c11bbb0
wk2048 | D4 | treasury refactor | review comments fix | removal of d…
shamb0 Nov 25, 2020
2c3b1a7
remove broken link
shawntabrizi Nov 25, 2020
c93ad2e
wk2048 | D5 | treasury refactor | review comments fix | bountise doc …
shamb0 Nov 26, 2020
14c30ee
wk2048 | D5 | treasury refactor | review comments fix | p8
shamb0 Nov 26, 2020
7d5bd6e
docs and formatting
shawntabrizi Nov 29, 2020
86e0f29
Update frame/tips/src/benchmarking.rs
wheresaddie Nov 30, 2020
bf95008
formatting nits
shawntabrizi Nov 30, 2020
e9ec8c7
Merge branch 'master' into pr/7536
shawntabrizi Nov 30, 2020
ccc776a
Trait -> Config
shawntabrizi Nov 30, 2020
7be1c09
trait -> config in benchmarks
shawntabrizi Nov 30, 2020
6732d73
clean up weight docs
shawntabrizi Nov 30, 2020
af97502
Trait -> Config in Runtime
shawntabrizi Nov 30, 2020
2484ee0
Merge branch 'master' into pr/7536
shawntabrizi Nov 30, 2020
003af63
Merge branch 'master' into pr/7536
shawntabrizi Dec 1, 2020
e718872
Merge branch 'master' into pr/7536
shawntabrizi Dec 14, 2020
9101ab3
fix test build
shawntabrizi Dec 14, 2020
19f708f
try to fix polkadot build check
shawntabrizi Dec 15, 2020
4ea05e1
fix traits
shawntabrizi Dec 15, 2020
1bc341c
Update lib.rs
shawntabrizi Dec 15, 2020
fe739f2
Apply suggestions from code review
shawntabrizi Dec 15, 2020
c324cda
Apply suggestions from code review
shawntabrizi Dec 15, 2020
41aa951
fix trait location
shawntabrizi Dec 15, 2020
23a903d
nits
shawntabrizi Dec 15, 2020
bc582fd
uncomment on_initialize for bounties benchmarks
shawntabrizi Dec 16, 2020
f1e6d46
update weights
shawntabrizi Dec 16, 2020
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
Prev Previous commit
Next Next commit
wk2047 | D6 | treasury refactor | review comments fix | p2
  • Loading branch information
shamb0 committed Nov 21, 2020
commit b81a858bf923a5a87b9cafd3446ff0c670426e92
2 changes: 1 addition & 1 deletion frame/bounties/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Treasury pallet benchmarking.
//! bounties pallet benchmarking.

#![cfg(feature = "runtime-benchmarks")]

Expand Down
84 changes: 12 additions & 72 deletions frame/bounties/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! # Treasury Module
//!
//! The Treasury module provides a "pot" of funds that can be managed by stakeholders in the
//! system and a structure for making spending proposals from this pot.
//!
//! - [`treasury::Trait`](./trait.Trait.html)
//! - [`Call`](./enum.Call.html)
//!
//! ## Overview
//!
//! The Treasury Module itself provides the pot to store funds, and a means for stakeholders to
//! propose, approve, and deny expenditures. The chain will need to provide a method (e.g.
//! inflation, fees) for collecting funds.
//!
//! By way of example, the Council could vote to fund the Treasury with a portion of the block
//! reward and use the funds to pay developers.
//!
//! ### Tipping
//!
//! A separate subsystem exists to allow for an agile "tipping" process, whereby a reward may be
//! given without first having a pre-determined stakeholder group come to consensus on how much
//! should be paid.
//!
//! A group of `Tippers` is determined through the config `Trait`. After half of these have declared
//! some amount that they believe a particular reported reason deserves, then a countdown period is
//! entered where any remaining members can declare their tip amounts also. After the close of the
//! countdown period, the median of all declared tips is paid to the reported beneficiary, along
//! with any finders fee, in case of a public (and bonded) original report.
//! # Bounties Module ( pallet-bounties )
//!
//! ### Bounty
//!
//! This pallet is build on top of pallet-treasury
//!
//! A Bounty Spending is a reward for a specified body of work - or specified set of objectives - that
//! needs to be executed for a predefined Treasury amount to be paid out. A curator is assigned after
//! the bounty is approved and funded by Council, to be delegated
Expand All @@ -71,16 +46,6 @@
//! respectively.
//! - **Pot:** Unspent funds accumulated by the treasury module.
//!
//! Tipping protocol:
//! - **Tipping:** The process of gathering declarations of amounts to tip and taking the median
//! amount to be transferred from the treasury to a beneficiary account.
//! - **Tip Reason:** The reason for a tip; generally a URL which embodies or explains why a
//! particular individual (identified by an account ID) is worthy of a recognition by the
//! treasury.
//! - **Finder:** The original public reporter of some reason for tipping.
//! - **Finders Fee:** Some proportion of the tip amount that is paid to the reporter of the tip,
//! rather than the main beneficiary.
//!
//! Bounty:
//! - **Bounty spending proposal:** A proposal to reward a predefined body of work upon completion by
//! the Treasury.
Expand All @@ -101,18 +66,6 @@
//!
//! ### Dispatchable Functions
//!
//! General spending/proposal protocol:
//! - `propose_spend` - Make a spending proposal and stake the required deposit.
//! - `reject_proposal` - Reject a proposal, slashing the deposit.
//! - `approve_proposal` - Accept the proposal, returning the deposit.
//!
//! Tipping protocol:
//! - `report_awesome` - Report something worthy of a tip and register for a finders fee.
//! - `retract_tip` - Retract a previous (finders fee registered) report.
//! - `tip_new` - Report an item worthy of a tip and declare a specific amount to tip.
//! - `tip` - Declare or redeclare an amount to tip for a particular reason.
//! - `close_tip` - Close and pay out a tip.
//!
//! Bounty protocol:
//! - `propose_bounty` - Propose a specific treasury amount to be earmarked for a predefined set of
//! tasks and stake the required deposit.
Expand All @@ -125,10 +78,9 @@
//! - `unassign_curator` - Unassign an accepted curator from a specific earmark.
//! - `close_bounty` - Cancel the earmark for a specific treasury amount and close the bounty.
//!
//!
//! ## GenesisConfig
//!
//! The Treasury module depends on the [`GenesisConfig`](./struct.GenesisConfig.html).
//! None

#![cfg_attr(not(feature = "std"), no_std)]

Expand All @@ -143,13 +95,14 @@ use frame_support::{decl_module, decl_storage, decl_event, ensure, decl_error};
use frame_support::traits::{
Currency, Get, Imbalance, OnUnbalanced, ExistenceRequirement::{AllowDeath},
ReservableCurrency};
use sp_runtime::{Permill, ModuleId, RuntimeDebug, DispatchResult, traits::{

use sp_runtime::{Permill, RuntimeDebug, DispatchResult, traits::{
Zero, StaticLookup, AccountIdConversion, Saturating, BadOrigin
}};

use frame_support::dispatch::DispatchResultWithPostInfo;
use frame_support::traits::{EnsureOrigin};

// use frame_support::weights::{Weight, DispatchClass};
use frame_support::weights::{Weight};

use codec::{Encode, Decode};
Expand Down Expand Up @@ -184,10 +137,6 @@ pub trait Trait: frame_system::Trait + pallet_treasury::Trait {
type WeightInfo: WeightInfo;
}

// TODO :: Clean-up :: Can BountyIndex replace ProposalIndex ?
/// An index of a proposal. Just a `u32`.
pub type ProposalIndex = u32;

/// An index of a bounty. Just a `u32`.
pub type BountyIndex = u32;

Expand Down Expand Up @@ -328,9 +277,6 @@ decl_module! {
/// The amount held on deposit per byte within the tip report reason or bounty description.
const DataDepositPerByte: BalanceOf<T> = T::DataDepositPerByte::get();

/// The treasury's module id, used for deriving its sovereign account ID.
const ModuleId: ModuleId = T::ModuleId::get();

/// The amount held on deposit for placing a bounty proposal.
const BountyDepositBase: BalanceOf<T> = T::BountyDepositBase::get();

Expand Down Expand Up @@ -382,7 +328,7 @@ decl_module! {
/// - One DB change.
/// # </weight>
#[weight = <T as Trait>::WeightInfo::approve_bounty()]
fn approve_bounty(origin, #[compact] bounty_id: ProposalIndex) {
fn approve_bounty(origin, #[compact] bounty_id: BountyIndex) {
T::ApproveOrigin::ensure_origin(origin)?;

Bounties::<T>::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult {
Expand All @@ -409,7 +355,7 @@ decl_module! {
#[weight = <T as Trait>::WeightInfo::propose_curator()]
fn propose_curator(
origin,
#[compact] bounty_id: ProposalIndex,
#[compact] bounty_id: BountyIndex,
curator: <T::Lookup as StaticLookup>::Source,
#[compact] fee: BalanceOf<T>,
) {
Expand All @@ -418,12 +364,6 @@ decl_module! {
let curator = T::Lookup::lookup(curator)?;
Bounties::<T>::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult {

// TODO re-visit
// let mut bounty = maybe_bounty.as_mut().ok_or(Error::<T>::InvalidIndex)?;
// match bounty.status {
// BountyStatus::Funded | BountyStatus::CuratorProposed { .. } => {},
// _ => return Err(Error::<T>::UnexpectedStatus.into()),
// };
let mut bounty = maybe_bounty.as_mut().ok_or(Error::<T>::InvalidIndex)?;
match bounty.status {
BountyStatus::Proposed | BountyStatus::Approved | BountyStatus::Funded => {},
Expand Down Expand Up @@ -462,7 +402,7 @@ decl_module! {
#[weight = <T as Trait>::WeightInfo::unassign_curator()]
fn unassign_curator(
origin,
#[compact] bounty_id: ProposalIndex,
#[compact] bounty_id: BountyIndex,
) {
let maybe_sender = ensure_signed(origin.clone())
.map(Some)
Expand Down Expand Up @@ -542,7 +482,7 @@ decl_module! {
/// - One DB change.
/// # </weight>
#[weight = <T as Trait>::WeightInfo::accept_curator()]
fn accept_curator(origin, #[compact] bounty_id: ProposalIndex) {
fn accept_curator(origin, #[compact] bounty_id: BountyIndex) {
let signer = ensure_signed(origin)?;

Bounties::<T>::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult {
Expand Down Expand Up @@ -573,7 +513,7 @@ decl_module! {
/// - `bounty_id`: Bounty ID to award.
/// - `beneficiary`: The beneficiary account whom will receive the payout.
#[weight = <T as Trait>::WeightInfo::award_bounty()]
fn award_bounty(origin, #[compact] bounty_id: ProposalIndex, beneficiary: <T::Lookup as StaticLookup>::Source) {
fn award_bounty(origin, #[compact] bounty_id: BountyIndex, beneficiary: <T::Lookup as StaticLookup>::Source) {
let signer = ensure_signed(origin)?;
let beneficiary = T::Lookup::lookup(beneficiary)?;

Expand Down
25 changes: 12 additions & 13 deletions frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Treasury pallet tests.
//! bounties pallet tests.

#![cfg(test)]

use super::*;
use std::cell::RefCell;

use frame_support::{
assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight,
impl_outer_event, traits::{Contains, ContainsLengthBound, OnInitialize}
impl_outer_event, traits::{OnInitialize}
};

use sp_core::H256;
use sp_runtime::{
Perbill, ModuleId,
Expand All @@ -50,7 +52,6 @@ impl_outer_event! {
}
}


#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
Expand All @@ -70,7 +71,6 @@ impl frame_system::Trait for Test {
type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
// type Event = Event;
type Event = Event;
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
Expand All @@ -93,7 +93,6 @@ parameter_types! {
impl pallet_balances::Trait for Test {
type MaxLocks = ();
type Balance = u64;
// type Event = Event;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
Expand All @@ -119,7 +118,6 @@ impl pallet_treasury::Trait for Test {
type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>;
type DataDepositPerByte = DataDepositPerByte;
// type Event = Event;
type Event = Event;
type OnSlash = ();
type ProposalBond = ProposalBond;
Expand All @@ -139,7 +137,6 @@ parameter_types! {
pub const BountyValueMinimum: u64 = 1;
}
impl Trait for Test {
// type Event = Event;
type Event = Event;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
Expand Down Expand Up @@ -461,8 +458,12 @@ fn close_bounty_works() {
assert_eq!(Balances::free_balance(0), 100 - deposit);

assert_eq!(Bounties::bounties(0), None);
// TODO :: re-visit
// assert!(!Treasury::Proposals::contains_key(0));

// TODO :: re-visit during review
// assert!(!Treasury::Proposals::<Test>::contains_key(0));
// assert!(!pallet_treasury::Module::<Test>::Proposals::<Test>::contains_key(0));
// assert!(!pallet_treasury::Module<Test>::Proposals<Test>::contains_key(0));

assert_eq!(Bounties::bounty_descriptions(0), None);
});
}
Expand Down Expand Up @@ -502,7 +503,6 @@ fn approve_bounty_works() {
assert_eq!(Balances::reserved_balance(0), 0);
assert_eq!(Balances::free_balance(0), 100);

// TODO re-visit
assert_eq!(Bounties::bounties(0).unwrap(), Bounty {
proposer: 0,
fee: 0,
Expand Down Expand Up @@ -668,8 +668,8 @@ fn award_and_claim_bounty_works() {
assert_eq!(last_event(), RawEvent::BountyClaimed(0, 56, 3));

assert_eq!(Balances::free_balance(4), 14); // initial 10 + fee 4
// TODO re-visit
// assert_eq!(Balances::free_balance(3), 56);

assert_eq!(Balances::free_balance(3), 56);
assert_eq!(Balances::free_balance(Bounties::bounty_account_id(0)), 0);

assert_eq!(Bounties::bounties(0), None);
Expand Down Expand Up @@ -767,7 +767,6 @@ fn award_and_cancel() {
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 0, 10));
assert_ok!(Bounties::accept_curator(Origin::signed(0), 0));

// TODO :: re-visit
assert_eq!(Balances::free_balance(0), 95);
assert_eq!(Balances::reserved_balance(0), 5);

Expand Down
Loading