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

Issue 7143 | Refactor Treasury Pallet into Bounties, Tips, and Proposals #7536

Merged
97 commits merged into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 91 commits
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
1 change: 1 addition & 0 deletions .maintain/gitlab/check_polkadot_companion_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ cargo install -f --version 0.2.0 diener

# Merge master into our branch before building Polkadot to make sure we don't miss
# any commits that are required by Polkadot.
git fetch --depth 20 origin
git merge origin/master

# Clone the current Polkadot master branch into ./polkadot.
Expand Down
39 changes: 39 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ members = [
"frame/babe",
"frame/balances",
"frame/benchmarking",
"frame/bounties",
"frame/collective",
"frame/contracts",
"frame/contracts/rpc",
Expand Down Expand Up @@ -112,6 +113,7 @@ members = [
"frame/transaction-payment/rpc",
"frame/transaction-payment/rpc/runtime-api",
"frame/treasury",
"frame/tips",
"frame/utility",
"frame/vesting",
"primitives/allocator",
Expand Down
6 changes: 6 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pallet-authority-discovery = { version = "2.0.0", default-features = false, path
pallet-authorship = { version = "2.0.0", default-features = false, path = "../../../frame/authorship" }
pallet-babe = { version = "2.0.0", default-features = false, path = "../../../frame/babe" }
pallet-balances = { version = "2.0.0", default-features = false, path = "../../../frame/balances" }
pallet-bounties = { version = "2.0.0", default-features = false, path = "../../../frame/bounties" }
pallet-collective = { version = "2.0.0", default-features = false, path = "../../../frame/collective" }
pallet-contracts = { version = "2.0.0", default-features = false, path = "../../../frame/contracts" }
pallet-contracts-primitives = { version = "2.0.0", default-features = false, path = "../../../frame/contracts/common/" }
Expand All @@ -74,6 +75,7 @@ pallet-scheduler = { version = "2.0.0", default-features = false, path = "../../
pallet-society = { version = "2.0.0", default-features = false, path = "../../../frame/society" }
pallet-sudo = { version = "2.0.0", default-features = false, path = "../../../frame/sudo" }
pallet-timestamp = { version = "2.0.0", default-features = false, path = "../../../frame/timestamp" }
pallet-tips = { version = "2.0.0", default-features = false, path = "../../../frame/tips" }
pallet-treasury = { version = "2.0.0", default-features = false, path = "../../../frame/treasury" }
pallet-utility = { version = "2.0.0", default-features = false, path = "../../../frame/utility" }
pallet-transaction-payment = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment" }
Expand All @@ -97,6 +99,7 @@ std = [
"sp-consensus-babe/std",
"pallet-babe/std",
"pallet-balances/std",
"pallet-bounties/std",
"sp-block-builder/std",
"codec/std",
"pallet-collective/std",
Expand Down Expand Up @@ -136,6 +139,7 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-timestamp/std",
"pallet-tips/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-treasury/std",
Expand All @@ -154,6 +158,7 @@ runtime-benchmarks = [
"pallet-assets/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-bounties/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-contracts/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
Expand All @@ -169,6 +174,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
28 changes: 22 additions & 6 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,25 +671,37 @@ impl pallet_treasury::Config for Runtime {
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>
>;
type Tippers = Elections;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type DataDepositPerByte = DataDepositPerByte;
type Event = Event;
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
type SpendFunds = Bounties;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
}

impl pallet_bounties::Config for Runtime {
type Event = Event;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type MaximumReasonLength = MaximumReasonLength;
type BurnDestination = ();
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
}

impl pallet_tips::Config for Runtime {
type Event = Event;
type MaximumReasonLength = MaximumReasonLength;
type Tippers = Elections;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -977,6 +989,8 @@ construct_runtime!(
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},
Proxy: pallet_proxy::{Module, Call, Storage, Event<T>},
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>},
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>},
Tips: pallet_tips::{Module, Call, Storage, Event<T>},
Assets: pallet_assets::{Module, Call, Storage, Event<T>},
Mmr: pallet_mmr::{Module, Storage},
}
Expand Down Expand Up @@ -1248,6 +1262,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_babe, Babe);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_bounties, Bounties);
add_benchmark!(params, batches, pallet_collective, Council);
add_benchmark!(params, batches, pallet_contracts, Contracts);
add_benchmark!(params, batches, pallet_democracy, Democracy);
Expand All @@ -1265,6 +1280,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_staking, Staking);
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_tips, Tips);
add_benchmark!(params, batches, pallet_treasury, Treasury);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_vesting, Vesting);
Expand Down
47 changes: 47 additions & 0 deletions frame/bounties/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "pallet-bounties"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
description = "FRAME pallet to manage bounties"
readme = "README.md"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" }
sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" }
frame-support = { version = "2.0.0", default-features = false, path = "../support" }
frame-system = { version = "2.0.0", default-features = false, path = "../system" }
pallet-treasury = { version = "2.0.0", default-features = false, path = "../treasury" }

frame-benchmarking = { version = "2.0.0", default-features = false, path = "../benchmarking", optional = true }

[dev-dependencies]
sp-io ={ version = "2.0.0", path = "../../primitives/io" }
sp-core = { version = "2.0.0", path = "../../primitives/core" }
sp-storage = { version = "2.0.0", path = "../../primitives/storage" }
pallet-balances = { version = "2.0.0", path = "../balances" }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-std/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"pallet-treasury/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
52 changes: 52 additions & 0 deletions frame/bounties/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Bounties Module ( pallet-bounties )

## Bounty

**Note :: This pallet is tightly coupled with 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 with the responsibility of assigning a
payout address once the specified set of objectives is completed.

After the Council has activated a bounty, it delegates the work that requires expertise to a curator
in exchange of a deposit. Once the curator accepts the bounty, they get to close the active bounty.
Closing the active bounty enacts a delayed payout to the payout address, the curator fee and the
return of the curator deposit. The delay allows for intervention through regular democracy. The
Council gets to unassign the curator, resulting in a new curator election. The Council also gets to
cancel the bounty if deemed necessary before assigning a curator or once the bounty is active or
payout is pending, resulting in the slash of the curator's deposit.

### Terminology

- **Bounty spending proposal:** A proposal to reward a predefined body of work upon completion by
the Treasury.
- **Proposer:** An account proposing a bounty spending.
- **Curator:** An account managing the bounty and assigning a payout address receiving the reward
for the completion of work.
- **Deposit:** The amount held on deposit for placing a bounty proposal plus the amount held on
deposit per byte within the bounty description.
- **Curator deposit:** The payment from a candidate willing to curate an approved bounty. The
deposit is returned when/if the bounty is completed.
- **Bounty value:** The total amount that should be paid to the Payout Address if the bounty is
rewarded.
- **Payout address:** The account to which the total or part of the bounty is assigned to.
- **Payout Delay:** The delay period for which a bounty beneficiary needs to wait before claiming.
- **Curator fee:** The reserved upfront payment for a curator for work related to the bounty.

## Interface

### Dispatchable Functions

Bounty protocol:
- `propose_bounty` - Propose a specific treasury amount to be earmarked for a predefined set of
tasks and stake the required deposit.
- `approve_bounty` - Accept a specific treasury amount to be earmarked for a predefined body of
work.
- `propose_curator` - Assign an account to a bounty as candidate curator.
- `accept_curator` - Accept a bounty assignment from the Council, setting a curator deposit.
- `extend_bounty_expiry` - Extend the expiry block number of the bounty and stay active.
- `award_bounty` - Close and pay out the specified amount for the completed work.
- `claim_bounty` - Claim a specific bounty amount from the Payout Address.
- `unassign_curator` - Unassign an accepted curator from a specific earmark.
- `close_bounty` - Cancel the earmark for a specific treasury amount and close the bounty.
Loading