Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimistic Project Funding #5162

Open
wants to merge 247 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 99 commits
Commits
Show all changes
247 commits
Select commit Hold shift + click to select a range
8537c9e
Started with the pallet structure
ndkazu Jul 23, 2024
dcaa52c
changed Cargo.toml
ndkazu Jul 23, 2024
b781695
Basic pallet structure
ndkazu Jul 27, 2024
527787b
Types, Storages, and naming
ndkazu Jul 27, 2024
f6b8fa8
Basic pallet structure
ndkazu Jul 27, 2024
c1c442d
Update
ndkazu Jul 27, 2024
674c5f1
Helper functions
ndkazu Jul 27, 2024
8f42432
Spnedings creation from projects list
ndkazu Jul 28, 2024
8667321
Spending status change
ndkazu Jul 28, 2024
5fb830e
Funds unlock and transfer
ndkazu Jul 30, 2024
08a56f5
Added an Event
ndkazu Jul 30, 2024
100c26b
Preparation for testing and minor corrections
ndkazu Jul 30, 2024
2be7fb9
Update substrate/frame/distribution/src/lib.rs
ndkazu Jul 30, 2024
76fe14b
Update substrate/frame/distribution/src/lib.rs
ndkazu Jul 30, 2024
5d0f7ba
Update substrate/frame/distribution/src/lib.rs
ndkazu Jul 30, 2024
503f3d3
Update substrate/frame/distribution/src/lib.rs
ndkazu Jul 30, 2024
aaea1fe
Update substrate/frame/distribution/src/types.rs
ndkazu Jul 30, 2024
01c826c
Update umbrella/Cargo.toml
ndkazu Jul 30, 2024
a305d80
Made some corrections
ndkazu Jul 30, 2024
c4e6ae4
First test
ndkazu Jul 30, 2024
9ba1083
Additional event & testing
ndkazu Jul 30, 2024
0268623
Merge branch 'paritytech:master' into Optimist
ndkazu Jul 30, 2024
dab155d
Update branch
ndkazu Jul 30, 2024
990a2f6
Second test: funds locked
ndkazu Jul 30, 2024
119206a
Minor corrections
ndkazu Jul 30, 2024
c9c9c4f
More tests...
ndkazu Jul 30, 2024
d11cbc1
Corrected some terms
ndkazu Jul 31, 2024
fb73b68
Pallet OPF basic structure. No storage yet.
ndkazu Aug 1, 2024
aa7b249
WhiteListed Projects storage
ndkazu Aug 1, 2024
2406b8f
Helper function for voting
ndkazu Aug 1, 2024
26f3958
modified storage
ndkazu Aug 1, 2024
8e10f21
Adding type for freeze
ndkazu Aug 1, 2024
abde432
Voting action + voter funds hold/release
ndkazu Aug 1, 2024
ad4d675
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 1, 2024
114e430
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 2, 2024
245cf90
New constant added
ndkazu Aug 2, 2024
617ee5e
Helper for rewards calculation & distribution
ndkazu Aug 3, 2024
93e3b31
Updated pallet-distribution tests
ndkazu Aug 3, 2024
5fc4beb
In-code documention, extrinsics, and a few corrections
ndkazu Aug 4, 2024
27524ed
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 4, 2024
3ba0121
Documentation for pallet distribution
ndkazu Aug 4, 2024
82bf13d
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Aug 4, 2024
f21ba3c
Documentation edit
ndkazu Aug 4, 2024
8cedc42
Restricted some storages visibility
ndkazu Aug 4, 2024
f95b070
Used checked_add instead of saturating_add
ndkazu Aug 4, 2024
2699fd2
Some corrections
ndkazu Aug 4, 2024
843f558
Logic to be used in pallet-opf hook added
ndkazu Aug 5, 2024
b69cfff
Distribution pallet README
ndkazu Aug 5, 2024
9faf586
README corrections
ndkazu Aug 5, 2024
758e681
README corrections
ndkazu Aug 5, 2024
00fe62b
Remove unfunded projects from whitelist
ndkazu Aug 6, 2024
46ea061
Use on_idle hook in OPF Pallet
ndkazu Aug 6, 2024
876db00
Correction
ndkazu Aug 6, 2024
7445d0f
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 7, 2024
442df1e
Update README.md
ndkazu Aug 7, 2024
238bae5
Update lib.rs
ndkazu Aug 7, 2024
76f31b3
Create README.md
ndkazu Aug 7, 2024
fa8f9c2
User's funds release after rewards calculation
ndkazu Aug 7, 2024
145858c
Benchmarking_begin
ndkazu Aug 8, 2024
1db8e95
Changed Sepnding(s) to Spend(s)
ndkazu Aug 8, 2024
c3ba04e
Changed VotingRoundsNumber to VotingRoundNumber
ndkazu Aug 8, 2024
92eabcd
Correction
ndkazu Aug 8, 2024
6216b5e
Preparing OPF testing
ndkazu Aug 9, 2024
b5c02ab
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 9, 2024
fb76ceb
Stopped using the system block number
ndkazu Aug 10, 2024
945fbb2
corrected block numbers for tests
ndkazu Aug 10, 2024
04c0646
Added events
ndkazu Aug 11, 2024
bdd88c1
First tests and corresponding corrections
ndkazu Aug 11, 2024
6742a58
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 11, 2024
0eb2e5c
Rewards distribution test
ndkazu Aug 11, 2024
d1fac2f
Tests and corrections
ndkazu Aug 11, 2024
7bf608a
Removed dev-mode and some warnings
ndkazu Aug 12, 2024
ba869d6
More OPF testing
ndkazu Aug 12, 2024
bc4c6de
Added benchmarking test suite
ndkazu Aug 12, 2024
32a2296
Extrinsic call not executed in benchmark???
ndkazu Aug 12, 2024
065039e
some corrections
ndkazu Aug 12, 2024
48d5d62
Tests are passing
ndkazu Aug 12, 2024
08c7518
Removed dev mode + clippy & fmt
ndkazu Aug 13, 2024
7b874a1
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 13, 2024
3389e6a
Benchmarking is now working for pallet distribution
ndkazu Aug 13, 2024
0592915
Pallet distribution ready for review
ndkazu Aug 13, 2024
e7956af
Re-wrote distribution benchmark and started opf benchmark
ndkazu Aug 14, 2024
5c25742
Benchmarking done
ndkazu Aug 15, 2024
a8f6d0c
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 15, 2024
ec08801
Fixing CLI errors
ndkazu Aug 15, 2024
d723478
Fixing errors
ndkazu Aug 15, 2024
67ddbb8
Fixing errors
ndkazu Aug 15, 2024
b960b3c
PRdoc
ndkazu Aug 15, 2024
53c31aa
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 15, 2024
ca65abb
Editing the prdoc
ndkazu Aug 15, 2024
b94e3f9
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Aug 15, 2024
6a918ad
Editing the prdoc
ndkazu Aug 15, 2024
8ed0b87
Editing the prdoc
ndkazu Aug 15, 2024
2878e5e
Editing the prdoc
ndkazu Aug 15, 2024
ab2ab73
Editing the prdoc->patch instead of minor
ndkazu Aug 15, 2024
40bdd68
Editing the prdoc
ndkazu Aug 15, 2024
d0dac4b
Editing the prdoc
ndkazu Aug 15, 2024
eb1ba63
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 15, 2024
a3be78b
Update prdoc/pr_5162.prdoc
ndkazu Aug 15, 2024
a5f0018
Fix prdoc
ndkazu Aug 15, 2024
39214cc
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Aug 15, 2024
fd40298
Fix semver
ndkazu Aug 15, 2024
79a29cc
Fix semver
ndkazu Aug 15, 2024
0c24a47
Corrected README
ndkazu Aug 16, 2024
b5c86d6
Use take instead of get & remove
ndkazu Aug 16, 2024
a3a59a2
Some suggested changes implemented.
ndkazu Aug 16, 2024
1a2139c
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 16, 2024
6bab58b
More OPF tests
ndkazu Aug 17, 2024
bf22c86
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 17, 2024
18fce0f
More tests and some in-code comments
ndkazu Aug 19, 2024
9718231
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Aug 19, 2024
1546392
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 19, 2024
8e76dd7
Merge branch 'master' into Optimist
Ank4n Aug 21, 2024
704c2fe
Conviction implemented, and funds unlock extrinsic added. New extrins…
ndkazu Aug 23, 2024
5695675
License added
ndkazu Aug 23, 2024
24cd606
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 23, 2024
7d80bfb
Review related corrections
ndkazu Aug 23, 2024
d9fc656
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Aug 23, 2024
baedd94
fix failing benchmark
ndkazu Aug 23, 2024
0d4a587
cargo fmt
ndkazu Aug 23, 2024
0cd321a
New extrinsic benchmark added
ndkazu Aug 23, 2024
73d0f5f
update
ndkazu Aug 23, 2024
1e38a51
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 24, 2024
4bec5f4
Type miss in ReadMe
ndkazu Aug 24, 2024
e1580cd
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 25, 2024
df41d42
Merge branch 'paritytech:master' into Optimist
ndkazu Aug 26, 2024
304a76d
Corrected Distribution pallet based on reviews
ndkazu Aug 27, 2024
bf8ba94
Error handling correction in Distribution pallet
ndkazu Aug 27, 2024
19dc1d9
added some corrections to the OPF pallet
ndkazu Aug 27, 2024
a2ff644
Removed unbounded map iter
ndkazu Aug 27, 2024
980226e
Further improvements in Distribution pallet
ndkazu Aug 27, 2024
ecbf739
Removing use of iter()
ndkazu Aug 28, 2024
b7ab820
Refactored try_vote function and removed iter()
ndkazu Aug 29, 2024
c29ffe8
cargo fmt
ndkazu Aug 29, 2024
c9dcc86
resolving conflict
ndkazu Aug 30, 2024
492a0d3
Merge branch 'master' into Optimist
ndkazu Aug 30, 2024
87d1c1e
Merge branch 'master' into Optimist
ndkazu Aug 31, 2024
8d4657d
Merge branch 'master' into Optimist
ndkazu Sep 3, 2024
5c5b8ad
opf-test correction
ndkazu Sep 3, 2024
98a0ae4
Merge branch 'paritytech:master' into Optimist
ndkazu Sep 5, 2024
98217d9
Renamed variable & removed some unecessary code
ndkazu Sep 6, 2024
77ae32e
Renamed some variables in pallet-opf
ndkazu Sep 6, 2024
8cb1b18
Updates vote_removal and corresponding tests
ndkazu Sep 6, 2024
ed56b2e
Clearing storages after a voting round ended in pallet-opf
ndkazu Sep 6, 2024
47fe97f
Debugging and additional tests
ndkazu Sep 6, 2024
3e2f2a1
cargo +nightly fmt
ndkazu Sep 6, 2024
8dfbcf3
Merge branch 'master' into Optimist
ndkazu Sep 6, 2024
556551d
Merge branch 'master' into Optimist
ndkazu Sep 7, 2024
effa3d9
Merge branch 'master' into Optimist
ndkazu Sep 8, 2024
2b5e0cd
Comments correction
ndkazu Sep 8, 2024
6942a86
Merge branch 'master' into Optimist
ndkazu Sep 9, 2024
1849512
Merge branch 'master' into Optimist
ndkazu Sep 11, 2024
72a8085
Merge branch 'master' into Optimist
ndkazu Sep 12, 2024
bb82af4
Merge branch 'master' into Optimist
ndkazu Sep 13, 2024
d2804b7
Merge branch 'master' into Optimist
ndkazu Sep 13, 2024
c847381
Reverted unwanted changes from cargo fmt
ndkazu Sep 13, 2024
2c0aa9b
Removed last unwanted format change
ndkazu Sep 13, 2024
511e8bc
Merge branch 'master' into Optimist
ndkazu Sep 13, 2024
bddabc8
Merge branch 'master' into Optimist
ndkazu Sep 14, 2024
5a13c98
Merge branch 'master' into Optimist
ndkazu Sep 16, 2024
e02fe4b
Correct import
ndkazu Sep 17, 2024
576a5b3
Merge branch 'master' into Optimist
ndkazu Sep 18, 2024
5760f9b
Merge branch 'master' into Optimist
ndkazu Sep 18, 2024
6e1c9ab
Merge branch 'master' into Optimist
ndkazu Sep 18, 2024
989be08
Corrected the respectives README's
ndkazu Sep 18, 2024
c62e265
toml format
ndkazu Sep 18, 2024
56e8676
rust-feature-propagation
ndkazu Sep 18, 2024
db2506b
Merge branch 'master' into Optimist
ndkazu Sep 18, 2024
12fbf3c
Rust features propagation
ndkazu Sep 18, 2024
c59b159
Merge branch 'master' into Optimist
ndkazu Sep 18, 2024
7412d46
Rust features propagation
ndkazu Sep 18, 2024
18f92fc
toml format
ndkazu Sep 19, 2024
840d64a
toml format
ndkazu Sep 19, 2024
cac2449
format toml
ndkazu Sep 19, 2024
8f0fd86
format toml
ndkazu Sep 19, 2024
4507209
fix umbrella error
ndkazu Sep 19, 2024
fb51be2
Fix Wasm error
ndkazu Sep 19, 2024
eef451c
Merge branch 'master' into Optimist
ndkazu Sep 19, 2024
f38806c
Merge branch 'master' into Optimist
ndkazu Sep 20, 2024
d21f4d8
Update Cargo.toml
ndkazu Sep 20, 2024
936cfd7
Update Cargo.toml
ndkazu Sep 20, 2024
7728824
Update Cargo.toml
ndkazu Sep 20, 2024
38718e5
Update cargo.toml
ndkazu Sep 20, 2024
99b3be4
Merge branch 'master' into Optimist
ndkazu Sep 20, 2024
f079db6
First round of corrections
ndkazu Sep 20, 2024
b61ddc6
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Sep 20, 2024
a4edbac
Second round of corrections
ndkazu Sep 20, 2024
635526e
Fix umbrella
ndkazu Sep 20, 2024
fa30adb
Revert some modifications
ndkazu Sep 20, 2024
2cf44db
changed max_weight in opf
ndkazu Sep 20, 2024
fa6a553
Fix format
ndkazu Sep 20, 2024
44fa41a
pallet-distribution corrections
ndkazu Sep 22, 2024
1ea2682
Merge branch 'master' into Optimist
ndkazu Sep 22, 2024
c1014fa
Removed unnecessary condition
ndkazu Sep 22, 2024
94496d1
cargo fmt
ndkazu Sep 23, 2024
e11002a
Merge branch 'master' into Optimist
ndkazu Sep 23, 2024
03b59e0
Updated weight.rs files
ndkazu Sep 23, 2024
b26a798
licenses
ndkazu Sep 23, 2024
37d1bca
Merge branch 'master' into Optimist
ndkazu Sep 23, 2024
96d1731
Merge branch 'master' into Optimist
ndkazu Sep 23, 2024
80cc666
Merge branch 'master' into Optimist
ndkazu Sep 25, 2024
10e9df8
Update substrate/frame/opf/src/lib.rs
ndkazu Sep 25, 2024
064b177
Merge branch 'master' into Optimist
ndkazu Sep 25, 2024
8586c18
Merge branch 'master' into Optimist
ndkazu Sep 26, 2024
93a9e9f
Merge branch 'master' into Optimist
ndkazu Sep 26, 2024
3ea2749
Merge branch 'master' into Optimist
ndkazu Sep 28, 2024
2d17a4e
cargo fmt
ndkazu Sep 28, 2024
5be0c9e
Merge branch 'master' into Optimist
ndkazu Sep 28, 2024
5b9f059
Merge branch 'master' into Optimist
ndkazu Sep 29, 2024
8cb632f
Merge branch 'master' into Optimist
ndkazu Oct 1, 2024
2b5d0e2
Merge branch 'master' into Optimist
ndkazu Oct 2, 2024
9b0a5f4
try to Fix failing benchmark test
ndkazu Oct 3, 2024
e201c53
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Oct 3, 2024
228da0a
Use calculated weight instead of max weight in on_idle_function
ndkazu Oct 3, 2024
e8ebcfc
Revert weight changes & limit block consumption to 1/10th
ndkazu Oct 3, 2024
f26d01c
cargo fmt
ndkazu Oct 3, 2024
0aa2708
Merge branch 'master' into Optimist
ndkazu Oct 4, 2024
0dbe4c9
Merge branch 'master' into Optimist
ndkazu Oct 5, 2024
25a3716
Merge branch 'master' into Optimist
ndkazu Oct 6, 2024
7821c10
Merge branch 'master' into Optimist
ndkazu Oct 8, 2024
d8934ad
Merge branch 'master' into Optimist
ndkazu Oct 8, 2024
3816547
Merge branch 'master' into Optimist
ndkazu Oct 9, 2024
8bddb52
Merge branch 'master' into Optimist
ndkazu Oct 10, 2024
48c58ad
Merge branch 'master' into Optimist
ndkazu Oct 13, 2024
65654a5
Merge branch 'master' into Optimist
ndkazu Oct 16, 2024
742544e
Merge branch 'master' into Optimist
ndkazu Oct 18, 2024
63b7eb4
Merge branch 'master' into Optimist
ndkazu Oct 20, 2024
d06fd28
cargo fmt
ndkazu Oct 20, 2024
b2cfb12
License
ndkazu Oct 20, 2024
6babd82
Weights & benchmarking
ndkazu Oct 20, 2024
1572c9a
Merge branch 'master' into Optimist
ndkazu Oct 22, 2024
4b94347
weights
ndkazu Oct 22, 2024
d4f865c
Merge branch 'master' into Optimist
ndkazu Oct 23, 2024
b8f19f2
try to fix feature-propagation error
ndkazu Oct 23, 2024
576c530
Merge branch 'master' into Optimist
ndkazu Oct 24, 2024
aea7890
fix CI errors
ndkazu Oct 24, 2024
0b9977c
Merge branch 'Optimist' of github.com:ndkazu/polkadot-sdk into Optimist
ndkazu Oct 24, 2024
673e991
Merge branch 'master' into Optimist
ndkazu Oct 25, 2024
597d6b5
Update substrate/frame/distribution/src/functions.rs
ndkazu Oct 26, 2024
4d177b3
Preparation for scheduler use instead of on_initialize
ndkazu Oct 27, 2024
78848a1
Added RuntimeCall to distribution Config
ndkazu Oct 29, 2024
76175ab
Replaced on_initialize, need to re-write tests
ndkazu Oct 29, 2024
75dda7b
Some code clean up
ndkazu Oct 29, 2024
7678a81
Merge branch 'master' into Optimist
ndkazu Oct 29, 2024
4f3962a
Fixing tests
ndkazu Oct 31, 2024
5d11ffe
2 more tests to fix
ndkazu Oct 31, 2024
e494e5a
Merge branch 'master' into Optimist
ndkazu Oct 31, 2024
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
47 changes: 47 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ members = [
"substrate/frame/core-fellowship",
"substrate/frame/delegated-staking",
"substrate/frame/democracy",
"substrate/frame/distribution",
ndkazu marked this conversation as resolved.
Show resolved Hide resolved
"substrate/frame/election-provider-multi-phase",
"substrate/frame/election-provider-multi-phase/test-staking-e2e",
"substrate/frame/election-provider-support",
Expand Down Expand Up @@ -903,6 +904,7 @@ pallet-default-config-example = { path = "substrate/frame/examples/default-confi
pallet-delegated-staking = { path = "substrate/frame/delegated-staking", default-features = false }
pallet-democracy = { path = "substrate/frame/democracy", default-features = false }
pallet-dev-mode = { path = "substrate/frame/examples/dev-mode", default-features = false }
pallet-distribution = { path = "substrate/frame/distribution", default-features = false }
pallet-election-provider-multi-phase = { path = "substrate/frame/election-provider-multi-phase", default-features = false }
pallet-election-provider-support-benchmarking = { path = "substrate/frame/election-provider-support/benchmarking", default-features = false }
pallet-elections-phragmen = { path = "substrate/frame/elections-phragmen", default-features = false }
Expand Down Expand Up @@ -940,6 +942,7 @@ pallet-nomination-pools-benchmarking = { path = "substrate/frame/nomination-pool
pallet-nomination-pools-runtime-api = { path = "substrate/frame/nomination-pools/runtime-api", default-features = false }
pallet-offences = { path = "substrate/frame/offences", default-features = false }
pallet-offences-benchmarking = { path = "substrate/frame/offences/benchmarking", default-features = false }
pallet-opf = { path = "substrate/frame/opf", default-features = false }
pallet-paged-list = { path = "substrate/frame/paged-list", default-features = false }
pallet-parachain-template = { path = "templates/parachain/pallets/template", default-features = false }
pallet-parameters = { path = "substrate/frame/parameters", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions docs/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pallet-scheduler = { workspace = true, default-features = true }
pallet-referenda = { workspace = true, default-features = true }
pallet-broker = { workspace = true, default-features = true }
pallet-babe = { workspace = true, default-features = true }
pallet-distribution = { workspace = true, default-features = true }
pallet-opf = { workspace = true, default-features = true }

# Primitives
sp-io = { workspace = true, default-features = true }
Expand Down
18 changes: 18 additions & 0 deletions prdoc/pr_5162.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "Optimistic Project Funding"

doc:
- audience: Runtime Dev
description: |
the combination of the OPF pallet and the DISTRIBUTION pallet handles the Optimistic Project Funding.
It allows users to nominate projects (whitelisted in OpenGov) with their DOT. This mechanism will be funded with a constant stream of DOT taken directly from inflation and distributed to projects based on the proportion of DOT that has nominated them.
The project rewards distribution is handled by the **Distribution Pallet**
The user’s conviction has not been implemented in this first pallet iteration.

crates:
- name: pallet-distribution
bump: patch
- name: pallet-opf
bump: patch
64 changes: 64 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,62 @@ impl pallet_broker::Config for Runtime {
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
}


parameter_types! {
// Id of the treasury
pub const PotId: PalletId = PalletId(*b"py/potid");

// Time needed after approval to unlock the reward claim
pub const Period:BlockNumber = 5*MINUTES;
ndkazu marked this conversation as resolved.
Show resolved Hide resolved
ndkazu marked this conversation as resolved.
Show resolved Hide resolved

// Maximum number of whitelisted projects
pub const MaxProjects:u32 = 50;

pub const EpochDurationBlocks: BlockNumber = EPOCH_DURATION_IN_BLOCKS;

}
impl pallet_distribution::Config for Runtime {
type RuntimeEvent = RuntimeEvent;

ndkazu marked this conversation as resolved.
Show resolved Hide resolved
type NativeBalance = Balances;

/// Pot PalletId
type PotId = PotId;

/// A reason for placing a hold on funds.
type RuntimeHoldReason = RuntimeHoldReason;

/// This the minimum required time period between project whitelisting
ndkazu marked this conversation as resolved.
Show resolved Hide resolved
/// and payment/reward_claim from the treasury.
type BufferPeriod = Period;

/// Maximum number of whitelisted projects
type MaxProjects = MaxProjects;

/// Epoch duration in blocks
type EpochDurationBlocks = EpochDurationBlocks;

type BlockNumberProvider = System;

type WeightInfo = pallet_distribution::weights::SubstrateWeight<Runtime>;
}

parameter_types!{
pub const MaxWhitelistedProjects: u32 = 64;
pub const TemporaryRewards: Balance = 100000 * DOLLARS;
pub const TotalPeriod:BlockNumber = 30 * DAYS;
pub const LockPeriod:BlockNumber = 10 * DAYS;
}
ndkazu marked this conversation as resolved.
Show resolved Hide resolved
impl pallet_opf::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type VoteLockingPeriod = LockPeriod;
type VotingPeriod = TotalPeriod;
type MaxWhitelistedProjects = MaxWhitelistedProjects;
type TemporaryRewards = TemporaryRewards;
type WeightInfo = pallet_opf::weights::SubstrateWeight<Runtime>;
}
ndkazu marked this conversation as resolved.
Show resolved Hide resolved


parameter_types! {
pub const MixnetNumCoverToCurrentBlocks: BlockNumber = 3;
pub const MixnetNumRequestsToCurrentBlocks: BlockNumber = 3;
Expand Down Expand Up @@ -2482,6 +2538,12 @@ mod runtime {

#[runtime::pallet_index(79)]
pub type AssetConversionMigration = pallet_asset_conversion_ops::Pallet<Runtime>;

#[runtime::pallet_index(80)]
pub type Distribution = pallet_distribution::Pallet<Runtime>;

#[runtime::pallet_index(81)]
pub type OptimisticProjectFunding = pallet_opf::Pallet<Runtime>;
}

/// The address format for describing accounts.
Expand Down Expand Up @@ -2645,6 +2707,8 @@ mod benches {
[pallet_safe_mode, SafeMode]
[pallet_example_mbm, PalletExampleMbms]
[pallet_asset_conversion_ops, AssetConversionMigration]
[pallet_distribution, Distribution]
[pallet_opf, OptimisticProjectFunding]
);
}

Expand Down
67 changes: 67 additions & 0 deletions substrate/frame/distribution/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[package]
name = "pallet-distribution"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage = "https://substrate.io"
repository.workspace = true
description = "FRAME pallet to distribute funds to whitelisted projects"
readme = "README.md"

[lints]
workspace = true

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

[dependencies]
codec = { workspace = true, default-features = false }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true , default-features = false }
frame-benchmarking = { optional = true, workspace = true , default-features = false }
frame-support = { workspace = true , default-features = false }
frame-system = { workspace = true , default-features = false }
sp-io = { workspace = true , default-features = false }
sp-runtime = { workspace = true , default-features = false }
sp-core = { workspace = true , default-features = false }

pallet-assets = { workspace = true, default-features = false }
pallet-balances = { workspace = true, default-features = false }
pallet-timestamp = { workspace = true, default-features = false }
pallet-sudo = { workspace = true, default-features = false }
pallet-transaction-payment = { workspace = true, default-features = false }
pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = false }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"log/std",
"scale-info/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-timestamp/std",
"pallet-sudo/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-assets/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
30 changes: 30 additions & 0 deletions substrate/frame/distribution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Distribution Pallet
## Overview

The **Distribution Pallet** handles the distribution of whitelisted projects rewards.

For now only one reward distribution pattern has been implemented, but the pallet could be extended
to offer to the user claiming rewards for a project, a choice between more than one distribution pattern.

The **Distribution Pallet** receives a list of Whitelisted/Nominated Projects with
their respective calculated rewards. For each project, it will create a corresponding
spending that will be stored until the project reward can be claimed. At the moment, the reward claim period start corresponds to: [beginning of an ***Epoch_Block*** + ***BufferPeriod***] (The ***BufferPeriod*** can be configured in the runtime).


### Terminology

- **PotId:** Pot containing the funds used to pay the rewards.
- **BufferPeriod:** minimum required buffer time period between project nomination and reward claim.
## Interface

### Dispatchable Functions

#### Public

These calls can be made from any externally held account capable of creating
a signed extrinsic.

Basic actions:
- `claim_reward_for` - From this extrinsic any user can claim a reward for a nominated/whitelisted project.

License: Apache-2.0
Loading
Loading