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 #6994

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3cd49b3
new start
ndkazu Dec 24, 2024
0a41d8f
Merge branch 'OPF' of github.com:ndkazu/polkadot-sdk into OPF
ndkazu Dec 24, 2024
859e6b3
New OPF pallet in work...
ndkazu Dec 24, 2024
788b33f
Added main extrinsics
ndkazu Dec 26, 2024
ba95275
Merge branch 'paritytech:master' into OPF
ndkazu Dec 29, 2024
1051e52
Merge branch 'paritytech:master' into OPF
ndkazu Dec 30, 2024
0f6bd3d
extrinsic #0 added
ndkazu Dec 30, 2024
54701b7
Added some helpers and extrinsic_#1
ndkazu Dec 30, 2024
e09ff11
Remove unneedded storage
ndkazu Dec 30, 2024
a52879a
prdoc
ndkazu Dec 30, 2024
e023fef
cargo fmt
ndkazu Dec 30, 2024
c5104d7
Claim_reward conditions
ndkazu Dec 30, 2024
f440a8e
cargo fmt
ndkazu Dec 30, 2024
4b3ea70
Merge branch 'paritytech:master' into OPF
ndkazu Dec 31, 2024
27f9107
Hook on_idle added
ndkazu Dec 31, 2024
57f751d
Adding some errors
ndkazu Jan 1, 2025
b639990
Re-factored the code
ndkazu Jan 1, 2025
757d7a4
Listing/unlisting reserved to Root
ndkazu Jan 1, 2025
bf03902
Add pallet-referenda
ndkazu Jan 2, 2025
64be231
Merge branch 'paritytech:master' into OPF
ndkazu Jan 3, 2025
e50dd8c
Merge branch 'paritytech:master' into OPF
ndkazu Jan 4, 2025
9ad6f98
Applied some corrections
ndkazu Jan 4, 2025
2d39b0c
Custom Origin
ndkazu Jan 4, 2025
21a3169
Batch registration
ndkazu Jan 5, 2025
dddba9f
Merge branch 'master' into OPF
ndkazu Jan 7, 2025
78454bc
Correction
ndkazu Jan 7, 2025
367d7bb
Using pallet democracy instead of pallet referenda
ndkazu Jan 7, 2025
d3b9928
Referendums started on project batch submission
ndkazu Jan 7, 2025
5aa92ec
Merge branch 'master' into OPF
ndkazu Jan 9, 2025
1e317a5
Remove unused variable
ndkazu Jan 9, 2025
fb17973
Merge branch 'master' into OPF
ndkazu Jan 10, 2025
6bc36f0
vote extrinsic
ndkazu Jan 11, 2025
e8a8f90
Vote extrinsic
ndkazu Jan 11, 2025
1b1d4d6
cargo fmt
ndkazu Jan 11, 2025
54eb177
Funds are locked by Democracy Pallet
ndkazu Jan 11, 2025
43147c9
Removed some warnings
ndkazu Jan 11, 2025
65bf165
Voting action tested -> works
ndkazu Jan 13, 2025
7486737
Merge branch 'master' into OPF
ndkazu Jan 13, 2025
cce0304
clippy & format
ndkazu Jan 13, 2025
2c047a4
Vote_removal function added
ndkazu Jan 13, 2025
a799448
Merge branch 'master' into OPF
ndkazu Jan 15, 2025
c2c176b
Merge branch 'master' into OPF
ndkazu Jan 16, 2025
6d6254a
added some tests
ndkazu Jan 16, 2025
31f308e
cargo fmt
ndkazu Jan 16, 2025
87b40ea
Enactment not working
ndkazu Jan 16, 2025
6d14852
Referendum working & tested
ndkazu Jan 17, 2025
b30a0a8
Merge branch 'master' into OPF
ndkazu Jan 17, 2025
941956e
tests clean-up
ndkazu Jan 17, 2025
c2bb7d9
Fixed referendum
ndkazu Jan 18, 2025
b63130d
More testing
ndkazu Jan 18, 2025
b428740
cargo fmt
ndkazu Jan 18, 2025
f8d2dcc
Merge branch 'paritytech:master' into OPF
ndkazu Jan 19, 2025
9344204
Added more tests
ndkazu Jan 19, 2025
11c3264
Documentation
ndkazu Jan 19, 2025
1658e80
Documentation
ndkazu Jan 19, 2025
22e3b2d
Clean-up
ndkazu Jan 19, 2025
14f2a3e
cargo fmt & clippy
ndkazu Jan 19, 2025
55b1a6d
Clippy
ndkazu Jan 19, 2025
25a400d
Funds claim tested
ndkazu Jan 20, 2025
30519a6
Merge branch 'master' into OPF
ndkazu Jan 20, 2025
8d05dc0
tests + documentation
ndkazu Jan 21, 2025
a00888d
Merge branch 'OPF' of github.com:ndkazu/polkadot-sdk into OPF
ndkazu Jan 21, 2025
67f1c19
Vote benchmark
ndkazu Jan 21, 2025
db13ef3
Corrected rewards_calculation
ndkazu Jan 22, 2025
b6add3c
cargo fmt
ndkazu Jan 22, 2025
68e40c1
benchmark voter funds release
ndkazu Jan 23, 2025
c0bea86
need to fix claim benchmark
ndkazu Jan 23, 2025
e9a832d
clean-up
ndkazu Jan 23, 2025
07c3191
Benchmarking
ndkazu Jan 24, 2025
920958c
cargo fmt
ndkazu Jan 24, 2025
eb5b586
Merge branch 'master' into OPF
ndkazu Jan 24, 2025
ec3aa5c
Merge branch 'OPF' of github.com:ndkazu/polkadot-sdk into OPF
ndkazu Jan 24, 2025
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
28 changes: 28 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 @@ -391,6 +391,7 @@ members = [
"substrate/frame/nomination-pools/test-delegate-stake",
"substrate/frame/offences",
"substrate/frame/offences/benchmarking",
"substrate/frame/opf",
"substrate/frame/paged-list",
"substrate/frame/paged-list/fuzzer",
"substrate/frame/parameters",
Expand Down Expand Up @@ -967,6 +968,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
21 changes: 21 additions & 0 deletions prdoc/pr_6994.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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 PF 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.

crates:
- name: pallet-opf
bump: patch
- name: frame-support
bump: none
- name: polkadot-sdk
bump: patch
- name: polkadot
bump: none
54 changes: 54 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,56 @@ impl pallet_offences::Config for Runtime {
type OnOffenceHandler = Staking;
}

parameter_types! {
// Id of the treasury
pub const PotId: PalletId = PalletId(*b"py/potid");
pub const ClaimingPeriod: BlockNumber = 7 * DAYS;
pub const VoteValidityPeriod: BlockNumber = 7 * DAYS;
pub const MaxProjects:u32 = 50;

/// This should be calculated as a percentage of inflation.
pub const TemporaryRewards: Balance = 100000 * DOLLARS;


}
impl pallet_opf::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type NativeBalance = Balances;
type AdminOrigin = EnsureRoot<AccountId>;
/// Pot PalletId
type PotId = PotId;

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

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

/// Time period in which people can vote.
/// After the period has ended, the votes are counted (STOP THE COUNT)
/// and then the funds are distributed into Spends.
type VotingPeriod = VotingPeriod;

/// Time for claiming a Spend.
/// After the period has passed, a spend is thrown away
/// and the funds are available again for distribution in the pot.
type ClaimingPeriod = ClaimingPeriod;

/// Period after which all the votes are resetted.
type VoteValidityPeriod = VoteValidityPeriod;

/// Period after which the proposal is enacted
type EnactmentPeriod = EnactmentPeriod;

type BlockNumberProvider = System;

/// This should be calculated as a percentage of inflation.
type TemporaryRewards = TemporaryRewards;

type WeightInfo = (); //pallet_opf::weights::SubstrateWeight<Runtime>;
}

impl pallet_authority_discovery::Config for Runtime {
type MaxAuthorities = MaxAuthorities;
}
Expand Down Expand Up @@ -2718,6 +2768,9 @@ mod runtime {

#[runtime::pallet_index(84)]
pub type AssetsFreezer = pallet_assets_freezer::Pallet<Runtime, Instance1>;

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

impl TryFrom<RuntimeCall> for pallet_revive::Call<Runtime> {
Expand Down Expand Up @@ -2981,6 +3034,7 @@ mod benches {
[pallet_example_mbm, PalletExampleMbms]
[pallet_asset_conversion_ops, AssetConversionMigration]
[pallet_verify_signature, VerifySignature]
[pallet_opf, Opf]
);
}

Expand Down
99 changes: 99 additions & 0 deletions substrate/frame/opf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[package]
authors.workspace = true
description = "Optimist Project Funding - pallet allowing users to nominate projects to be funded, by locking their DOTS."
edition.workspace = true
homepage = "https://substrate.io"
license = "Apache-2.0"
name = "pallet-opf"
readme = "README.md"
repository.workspace = true
version = "0.1.0"

[lints]
workspace = true

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

[dependencies]
codec = { 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 }
log = { workspace = true }
pallet-conviction-voting = { workspace = true, default-features = false }
pallet-democracy = { workspace = true, default-features = true }
pallet-scheduler = { workspace = true, default-features = false }
scale-info = { features = [
"derive",
], workspace = true, default-features = false }
serde = { optional = true, workspace = true, default-features = true }
sp-core = { workspace = true, default-features = false }
sp-io = { workspace = true, default-features = false }
sp-runtime = { workspace = true, default-features = false }
sp-std = { workspace = true, default-features = true }

[dev-dependencies]
pallet-assets = { workspace = true, default-features = true }
pallet-balances = { workspace = true, default-features = true }
pallet-preimage = { workspace = true, default-features = true }
pallet-scheduler = { workspace = true, default-features = true }
pallet-sudo = { workspace = true, default-features = true }
pallet-timestamp = { workspace = true, default-features = true }
pallet-transaction-payment = { workspace = true, default-features = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = true }

[features]
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"scale-info/std",
"serde",
"sp-runtime/runtime-benchmarks",
]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-conviction-voting/std",
"pallet-democracy/std",
"pallet-preimage/std",
"pallet-scheduler/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-assets/try-runtime",
"pallet-balances/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-democracy/try-runtime",
"pallet-preimage/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"sp-runtime/try-runtime",
]
Loading
Loading