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 17 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
37 changes: 37 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 @@ -68,6 +68,7 @@ members = [
"frame/babe",
"frame/balances",
"frame/benchmarking",
"frame/bounties",
"frame/collective",
"frame/contracts",
"frame/contracts/rpc",
Expand Down Expand Up @@ -115,6 +116,7 @@ members = [
"frame/transaction-payment/rpc",
"frame/transaction-payment/rpc/runtime-api",
"frame/treasury",
"frame/tips",
"frame/utility",
"frame/vesting",
"primitives/allocator",
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-balances = { version = "2.0.0", default-features = false, path = "../balances" }
shamb0 marked this conversation as resolved.
Show resolved Hide resolved
pallet-treasury = { version = "2.0.0", 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" }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-std/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
118 changes: 118 additions & 0 deletions frame/bounties/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# 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`](https://docs.rs/pallet-treasury/latest/pallet_treasury/trait.Trait.html)
- [`Call`](https://docs.rs/pallet-treasury/latest/pallet_treasury/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
shamb0 marked this conversation as resolved.
Show resolved Hide resolved

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.

### Bounty

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

- **Proposal:** A suggestion to allocate funds from the pot to a beneficiary.
- **Beneficiary:** An account who will receive the funds from a proposal iff
the proposal is approved.
- **Deposit:** Funds that a proposer must lock when making a proposal. The
deposit will be returned or slashed if the proposal is approved or rejected
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.
- **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

General spending/proposal protocol:
- `propose_spend` - Make a spending proposal and stake the required deposit.
- `set_pot` - Set the spendable balance of funds.
- `configure` - Configure the module's proposal requirements.
- `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.
- `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.


## GenesisConfig

The Treasury module depends on the [`GenesisConfig`](https://docs.rs/pallet-treasury/latest/pallet_treasury/struct.GenesisConfig.html).

License: Apache-2.0
Loading