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

Collective: dynamic deposit based on number of proposals #3151

Merged
merged 68 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
cbfd5b3
deposit trait and types, proposal deposit
muharem Jan 30, 2024
bff29ac
upgrade to benchmarks v2
muharem Jan 30, 2024
9bc7f8a
fixes
muharem Jan 30, 2024
09f7b3f
benchmarks
muharem Jan 30, 2024
cc9a9e3
imports
muharem Jan 31, 2024
de84000
tests
muharem Jan 31, 2024
a775365
fix
muharem Jan 31, 2024
311eb49
prdoc
muharem Jan 31, 2024
5100036
fix prdoc title
muharem Jan 31, 2024
b8b927a
fix pallet alliance
muharem Jan 31, 2024
563e7ad
Merge remote-tracking branch 'origin/master' into muharem-collective-…
muharem Jan 31, 2024
bb704fa
docify examples
muharem Jan 31, 2024
feb84e6
fix pallet utility
muharem Jan 31, 2024
f076867
fmt
muharem Jan 31, 2024
f7072fe
geometric and round types
muharem Feb 1, 2024
737b4ce
doc fix
muharem Feb 1, 2024
357af6f
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Feb 6, 2024
0dd1d70
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Feb 6, 2024
cf71614
Merge remote-tracking branch 'origin/master' into muharem-collective-…
muharem Feb 20, 2024
2e13ff1
Merge remote-tracking branch 'origin/master' into muharem-collective-…
muharem Mar 13, 2024
36f1855
remove unused import
muharem Mar 13, 2024
c8dd9c4
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Mar 13, 2024
05633e3
Merge branch 'master' into muharem-collective-deposit
muharem Mar 25, 2024
b213af4
Merge remote-tracking branch 'origin/master' into muharem-collective-…
muharem Jun 26, 2024
94c35f9
use considerations
muharem Jun 27, 2024
29bfd87
improve doc
muharem Jun 27, 2024
61dba53
remove unused imports
muharem Jun 27, 2024
23d6385
fixes
muharem Jun 27, 2024
a687855
fixe benches
muharem Jun 27, 2024
f67e747
fix pr doc
muharem Jun 27, 2024
ccb7035
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Jun 27, 2024
c5eaefd
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jun 27, 2024
1d88228
Merge branch 'master' into muharem-collective-deposit
muharem Jun 27, 2024
615c5ff
Merge remote-tracking branch 'origin/master' into muharem-collective-…
muharem Jul 31, 2024
f505e78
fix import
muharem Jul 31, 2024
de9a123
fixes
muharem Aug 2, 2024
692e62d
Apply suggestions from code review
muharem Aug 2, 2024
5ee2439
fix weights
muharem Aug 2, 2024
fbddc7a
fix weights
muharem Aug 2, 2024
33965f8
collectives westend collective pallet weights
muharem Aug 2, 2024
d3e76cb
Apply suggestions from code review
muharem Aug 2, 2024
87016f3
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Aug 5, 2024
9b6dae2
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Aug 5, 2024
75d6ad9
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Aug 6, 2024
f7a7742
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Aug 6, 2024
ddb8d23
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Aug 6, 2024
0b09a4a
update round type
muharem Aug 7, 2024
5f2fa9f
update prdoc
muharem Aug 7, 2024
4e95fe4
Merge branch 'master' into muharem-collective-deposit
muharem Aug 14, 2024
a0a8f73
Merge remote-tracking branch 'origin/master' into muharem-collective-…
muharem Aug 14, 2024
a0ddd4c
not optional considerations
muharem Aug 15, 2024
16eb8d2
Merge branch 'master' into muharem-collective-deposit
muharem Aug 15, 2024
82e6889
remove debug outputs
muharem Aug 15, 2024
46cb545
Merge remote-tracking branch 'origin/master' into muharem-collective-…
muharem Aug 28, 2024
3f8a76c
maybe consideration
muharem Aug 28, 2024
d92f622
prdoc fix
muharem Aug 28, 2024
0246fa8
fix benches
muharem Aug 28, 2024
9e89a72
update pr doc
muharem Aug 29, 2024
7884b85
improve doc
muharem Aug 29, 2024
bf272d6
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Aug 29, 2024
4f04c4b
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Aug 29, 2024
318958a
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Aug 31, 2024
da151e1
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Aug 31, 2024
e6b5891
Update from mordamax running command 'bench --runtime dev --pallet pa…
actions-user Aug 31, 2024
c47e3b5
Merge branch 'master' into muharem-collective-deposit
muharem Sep 1, 2024
fbb88c9
fix weights
muharem Sep 2, 2024
4520950
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Sep 2, 2024
7582764
Merge branch 'master' into muharem-collective-deposit
muharem Sep 4, 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
2 changes: 2 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
type MaxProposalWeight = MaxProposalWeight;
type DisapproveOrigin = EnsureRoot<Self::AccountId>;
type KillOrigin = EnsureRoot<Self::AccountId>;
type Consideration = ();
}

pub const MAX_FELLOWS: u32 = ALLIANCE_MAX_MEMBERS;
Expand Down

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions prdoc/pr_3151.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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: Dynamic deposit based on number of proposals

doc:
- audience: Runtime User
description: |
Introduce a dynamic proposal deposit mechanism influenced by the total number of active
proposals, with the option to set the deposit to none.

The potential cost (e.g., balance hold) for proposal submission and storage is determined
by the implementation of the `Consideration` trait. The footprint is defined as `proposal_count`,
representing the total number of active proposals in the system, excluding the one currently
being proposed. This cost may vary based on the proposal count. The pallet also offers various
types to define a cost strategy based on the number of proposals.

Two new calls are introduced:
- kill(origin, proposal_hash): the cancellation of a proposal, accompanied by the burning
of the associated cost/consideration ticket.
- release_proposal_cost(origin, proposal_hash): the release of the cost for a non-active proposal.

New config parameters:
muharem marked this conversation as resolved.
Show resolved Hide resolved
- DisapproveOrigin: origin from which a proposal in any status may be disapproved without
associated cost for a proposer;
- KillOrigin: Origin from which any malicious proposal may be killed with associated cost
for a proposer;
- Consideration: mechanism to assess the necessity of some cost for publishing and storing
a proposal. Set to unit type to have not submission cost;

Additionally change:
- benchmarks have been upgraded to benchmarks::v2 for collective pallet;
- `ensure_successful` function added to the `Consideration` under `runtime-benchmarks` feature.

crates:
- name: pallet-collective
bump: major
- name: collectives-westend-runtime
bump: major
- name: kitchensink-runtime
bump: major
- name: pallet-alliance
bump: patch
- name: pallet-balances
bump: patch
- name: pallet-utility
bump: patch
21 changes: 21 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,9 @@ parameter_types! {
pub const CouncilMotionDuration: BlockNumber = 5 * DAYS;
pub const CouncilMaxProposals: u32 = 100;
pub const CouncilMaxMembers: u32 = 100;
pub const ProposalDepositOffset: Balance = ExistentialDeposit::get() + ExistentialDeposit::get();
pub const ProposalHoldReason: RuntimeHoldReason =
RuntimeHoldReason::Council(pallet_collective::HoldReason::ProposalSubmission);
}

type CouncilCollective = pallet_collective::Instance1;
Expand All @@ -1128,6 +1131,18 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type DisapproveOrigin = EnsureRoot<Self::AccountId>;
type KillOrigin = EnsureRoot<Self::AccountId>;
type Consideration = HoldConsideration<
AccountId,
Balances,
ProposalHoldReason,
pallet_collective::deposit::Delayed<
ConstU32<2>,
pallet_collective::deposit::Linear<ConstU32<2>, ProposalDepositOffset>,
>,
u32,
>;
}

parameter_types! {
Expand Down Expand Up @@ -1189,6 +1204,9 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type DisapproveOrigin = EnsureRoot<Self::AccountId>;
type KillOrigin = EnsureRoot<Self::AccountId>;
type Consideration = ();
}

type EnsureRootOrHalfCouncil = EitherOfDiverse<
Expand Down Expand Up @@ -2027,6 +2045,9 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type DisapproveOrigin = EnsureRoot<Self::AccountId>;
type KillOrigin = EnsureRoot<Self::AccountId>;
type Consideration = ();
}

parameter_types! {
Expand Down
3 changes: 3 additions & 0 deletions substrate/frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ impl pallet_collective::Config<AllianceCollective> for Test {
type WeightInfo = ();
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxProposalWeight;
type DisapproveOrigin = EnsureRoot<Self::AccountId>;
type KillOrigin = EnsureRoot<Self::AccountId>;
type Consideration = ();
}

parameter_types! {
Expand Down
13 changes: 6 additions & 7 deletions substrate/frame/balances/src/tests/fungible_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,9 @@ fn freeze_consideration_works() {
let who = 4;
// freeze amount taken somewhere outside of our (Consideration) scope.
let extend_freeze = 15;
let zero_ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap();
assert!(zero_ticket.is_none());

let ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap();
assert!(ticket.is_none());
assert_eq!(Balances::balance_frozen(&TestId::Foo, &who), 0);

let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap();
Expand All @@ -536,7 +537,6 @@ fn freeze_consideration_works() {

let ticket = ticket.update(&who, Footprint::from_parts(0, 0)).unwrap();
assert!(ticket.is_none());
assert_eq!(ticket, zero_ticket);
assert_eq!(Balances::balance_frozen(&TestId::Foo, &who), 0 + extend_freeze);

let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap();
Expand Down Expand Up @@ -565,11 +565,11 @@ fn hold_consideration_works() {
// hold amount taken somewhere outside of our (Consideration) scope.
let extend_hold = 15;

let zero_ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap();
assert!(zero_ticket.is_none());
let ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap();
assert!(ticket.is_none());
assert_eq!(Balances::balance_on_hold(&TestId::Foo, &who), 0);

let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap();
let ticket = ticket.update(&who, Footprint::from_parts(10, 1)).unwrap();
assert_eq!(Balances::balance_on_hold(&TestId::Foo, &who), 10);

let ticket = ticket.update(&who, Footprint::from_parts(4, 1)).unwrap();
Expand All @@ -583,7 +583,6 @@ fn hold_consideration_works() {

let ticket = ticket.update(&who, Footprint::from_parts(0, 0)).unwrap();
assert!(ticket.is_none());
assert_eq!(ticket, zero_ticket);
assert_eq!(Balances::balance_on_hold(&TestId::Foo, &who), 0 + extend_hold);

let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap();
Expand Down
9 changes: 8 additions & 1 deletion substrate/frame/collective/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ targets = ["x86_64-unknown-linux-gnu"]

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

[dev-dependencies]
pallet-balances = { workspace = true, default-features = false }

[features]
default = ["std"]
std = [
Expand All @@ -34,6 +38,7 @@ std = [
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
Expand All @@ -43,10 +48,12 @@ 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",
]
Loading
Loading