mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 11:51:12 +00:00
Referenda and Conviction Voting pallets (#10195)
* Initial draft of new referendum state machine. * Docs * Fixes * Fixes * Add conviction-voting pallet * Basic build * Building * Some TODOs * Tests building * Add missing file * Basic lifecycle test * Add couple of tests * Another test * More tests * Fixes * Fixes * Formatting * Fixes * Tests * Fixes * Fixes * More tests * Formatting * First few benchmarks * First few benchmarks * Defered queue servicing * More testing * Benchmarks * Fiddly benchmark * Final nudge benchmarks * Formatting * Formatting * Finished up benchmarks * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_referenda --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/referenda/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Events finished * Missing file * No GenesisConfig for Referenda * Formatting * Docs * Docs * Docs * Per-class conviction voting * New test & mock utils * More tests * Tests * Tests finished 🎉 * Benchmarking stuff * Fixes * Test harness * Test harness * Benchmarks for Conviction=Voting * Benchmarking pipeline complete * Docs * Formatting * Remove unneeded warning * Fix UI tests * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_conviction_voting --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/conviction-voting/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Docs * Update frame/conviction-voting/src/vote.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * update sp-runtime version * MEL Fixes for Referenda and Conviction Voting (#10725) * free maxencodedlen * more maxencodedlen * more MEL * more mel * disable storage info * More Referenda Patches (#10760) * basic fixes * fix benchmarking * fix license * prevent panic in curve math * fmt * bump crate versions * Update mock.rs Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -64,6 +64,7 @@ pallet-collective = { version = "4.0.0-dev", default-features = false, path = ".
|
||||
pallet-contracts = { version = "4.0.0-dev", default-features = false, path = "../../../frame/contracts" }
|
||||
pallet-contracts-primitives = { version = "5.0.0", default-features = false, path = "../../../frame/contracts/common/" }
|
||||
pallet-contracts-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" }
|
||||
pallet-conviction-voting = { version = "4.0.0-dev", default-features = false, path = "../../../frame/conviction-voting" }
|
||||
pallet-democracy = { version = "4.0.0-dev", default-features = false, path = "../../../frame/democracy" }
|
||||
pallet-election-provider-multi-phase = { version = "4.0.0-dev", default-features = false, path = "../../../frame/election-provider-multi-phase" }
|
||||
pallet-elections-phragmen = { version = "5.0.0-dev", default-features = false, path = "../../../frame/elections-phragmen" }
|
||||
@@ -82,9 +83,8 @@ pallet-preimage = { version = "4.0.0-dev", default-features = false, path = "../
|
||||
pallet-proxy = { version = "4.0.0-dev", default-features = false, path = "../../../frame/proxy" }
|
||||
pallet-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, path = "../../../frame/randomness-collective-flip" }
|
||||
pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" }
|
||||
pallet-session = { version = "4.0.0-dev", features = [
|
||||
"historical",
|
||||
], path = "../../../frame/session", default-features = false }
|
||||
pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" }
|
||||
pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = "../../../frame/session", default-features = false }
|
||||
pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true }
|
||||
pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" }
|
||||
pallet-staking-reward-curve = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/reward-curve" }
|
||||
@@ -125,6 +125,7 @@ std = [
|
||||
"pallet-contracts/std",
|
||||
"pallet-contracts-primitives/std",
|
||||
"pallet-contracts-rpc-runtime-api/std",
|
||||
"pallet-conviction-voting/std",
|
||||
"pallet-democracy/std",
|
||||
"pallet-elections-phragmen/std",
|
||||
"frame-executive/std",
|
||||
@@ -170,6 +171,7 @@ std = [
|
||||
"pallet-utility/std",
|
||||
"sp-version/std",
|
||||
"pallet-society/std",
|
||||
"pallet-referenda/std",
|
||||
"pallet-recovery/std",
|
||||
"pallet-uniques/std",
|
||||
"pallet-vesting/std",
|
||||
@@ -183,7 +185,6 @@ runtime-benchmarks = [
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-election-provider-multi-phase/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"pallet-assets/runtime-benchmarks",
|
||||
"pallet-babe/runtime-benchmarks",
|
||||
@@ -193,7 +194,9 @@ runtime-benchmarks = [
|
||||
"pallet-child-bounties/runtime-benchmarks",
|
||||
"pallet-collective/runtime-benchmarks",
|
||||
"pallet-contracts/runtime-benchmarks",
|
||||
"pallet-conviction-voting/runtime-benchmarks",
|
||||
"pallet-democracy/runtime-benchmarks",
|
||||
"pallet-election-provider-multi-phase/runtime-benchmarks",
|
||||
"pallet-elections-phragmen/runtime-benchmarks",
|
||||
"pallet-gilt/runtime-benchmarks",
|
||||
"pallet-grandpa/runtime-benchmarks",
|
||||
@@ -204,9 +207,12 @@ runtime-benchmarks = [
|
||||
"pallet-membership/runtime-benchmarks",
|
||||
"pallet-mmr/runtime-benchmarks",
|
||||
"pallet-multisig/runtime-benchmarks",
|
||||
"pallet-offences-benchmarking",
|
||||
"pallet-preimage/runtime-benchmarks",
|
||||
"pallet-proxy/runtime-benchmarks",
|
||||
"pallet-scheduler/runtime-benchmarks",
|
||||
"pallet-referenda/runtime-benchmarks",
|
||||
"pallet-session-benchmarking",
|
||||
"pallet-society/runtime-benchmarks",
|
||||
"pallet-staking/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
@@ -216,8 +222,6 @@ runtime-benchmarks = [
|
||||
"pallet-utility/runtime-benchmarks",
|
||||
"pallet-uniques/runtime-benchmarks",
|
||||
"pallet-vesting/runtime-benchmarks",
|
||||
"pallet-offences-benchmarking",
|
||||
"pallet-session-benchmarking",
|
||||
"frame-system-benchmarking",
|
||||
"hex-literal",
|
||||
]
|
||||
@@ -234,35 +238,37 @@ try-runtime = [
|
||||
"pallet-child-bounties/try-runtime",
|
||||
"pallet-collective/try-runtime",
|
||||
"pallet-contracts/try-runtime",
|
||||
"pallet-conviction-voting/try-runtime",
|
||||
"pallet-democracy/try-runtime",
|
||||
"pallet-election-provider-multi-phase/try-runtime",
|
||||
"pallet-elections-phragmen/try-runtime",
|
||||
"pallet-gilt/try-runtime",
|
||||
"pallet-grandpa/try-runtime",
|
||||
"pallet-identity/try-runtime",
|
||||
"pallet-im-online/try-runtime",
|
||||
"pallet-indices/try-runtime",
|
||||
"pallet-lottery/try-runtime",
|
||||
"pallet-membership/try-runtime",
|
||||
"pallet-mmr/try-runtime",
|
||||
"pallet-multisig/try-runtime",
|
||||
"pallet-identity/try-runtime",
|
||||
"pallet-scheduler/try-runtime",
|
||||
"pallet-offences/try-runtime",
|
||||
"pallet-preimage/try-runtime",
|
||||
"pallet-proxy/try-runtime",
|
||||
"pallet-randomness-collective-flip/try-runtime",
|
||||
"pallet-recovery/try-runtime",
|
||||
"pallet-referenda/try-runtime",
|
||||
"pallet-scheduler/try-runtime",
|
||||
"pallet-session/try-runtime",
|
||||
"pallet-society/try-runtime",
|
||||
"pallet-staking/try-runtime",
|
||||
"pallet-sudo/try-runtime",
|
||||
"pallet-election-provider-multi-phase/try-runtime",
|
||||
"pallet-timestamp/try-runtime",
|
||||
"pallet-tips/try-runtime",
|
||||
"pallet-transaction-payment/try-runtime",
|
||||
"pallet-treasury/try-runtime",
|
||||
"pallet-utility/try-runtime",
|
||||
"pallet-society/try-runtime",
|
||||
"pallet-recovery/try-runtime",
|
||||
"pallet-uniques/try-runtime",
|
||||
"pallet-utility/try-runtime",
|
||||
"pallet-vesting/try-runtime",
|
||||
"pallet-gilt/try-runtime",
|
||||
]
|
||||
# Make contract callable functions marked as __unstable__ available. Do not enable
|
||||
# on live chains as those are subject to change.
|
||||
|
||||
@@ -698,6 +698,83 @@ impl pallet_bags_list::Config for Runtime {
|
||||
type BagThresholds = BagThresholds;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const VoteLockingPeriod: BlockNumber = 30 * DAYS;
|
||||
}
|
||||
|
||||
impl pallet_conviction_voting::Config for Runtime {
|
||||
type WeightInfo = pallet_conviction_voting::weights::SubstrateWeight<Self>;
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type VoteLockingPeriod = VoteLockingPeriod;
|
||||
type MaxVotes = ConstU32<512>;
|
||||
type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
|
||||
type Polls = Referenda;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const AlarmInterval: BlockNumber = 1;
|
||||
pub const SubmissionDeposit: Balance = 100 * DOLLARS;
|
||||
pub const UndecidingTimeout: BlockNumber = 28 * DAYS;
|
||||
}
|
||||
|
||||
pub struct TracksInfo;
|
||||
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
type Id = u8;
|
||||
type Origin = <Origin as frame_support::traits::OriginTrait>::PalletsOrigin;
|
||||
fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo<Balance, BlockNumber>)] {
|
||||
static DATA: [(u8, pallet_referenda::TrackInfo<Balance, BlockNumber>); 1] = [(
|
||||
0u8,
|
||||
pallet_referenda::TrackInfo {
|
||||
name: "root",
|
||||
max_deciding: 1,
|
||||
decision_deposit: 10,
|
||||
prepare_period: 4,
|
||||
decision_period: 4,
|
||||
confirm_period: 2,
|
||||
min_enactment_period: 4,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
begin: Perbill::from_percent(100),
|
||||
delta: Perbill::from_percent(50),
|
||||
},
|
||||
min_turnout: pallet_referenda::Curve::LinearDecreasing {
|
||||
begin: Perbill::from_percent(100),
|
||||
delta: Perbill::from_percent(100),
|
||||
},
|
||||
},
|
||||
)];
|
||||
&DATA[..]
|
||||
}
|
||||
fn track_for(id: &Self::Origin) -> Result<Self::Id, ()> {
|
||||
if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) {
|
||||
match system_origin {
|
||||
frame_system::RawOrigin::Root => Ok(0),
|
||||
_ => Err(()),
|
||||
}
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_referenda::Config for Runtime {
|
||||
type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
|
||||
type Call = Call;
|
||||
type Event = Event;
|
||||
type Scheduler = Scheduler;
|
||||
type Currency = pallet_balances::Pallet<Self>;
|
||||
type CancelOrigin = EnsureRoot<AccountId>;
|
||||
type KillOrigin = EnsureRoot<AccountId>;
|
||||
type Slash = ();
|
||||
type Votes = pallet_conviction_voting::VotesOf<Runtime>;
|
||||
type Tally = pallet_conviction_voting::TallyOf<Runtime>;
|
||||
type SubmissionDeposit = SubmissionDeposit;
|
||||
type MaxQueued = ConstU32<100>;
|
||||
type UndecidingTimeout = UndecidingTimeout;
|
||||
type AlarmInterval = AlarmInterval;
|
||||
type Tracks = TracksInfo;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
|
||||
pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
|
||||
@@ -1336,6 +1413,8 @@ construct_runtime!(
|
||||
TransactionStorage: pallet_transaction_storage,
|
||||
BagsList: pallet_bags_list,
|
||||
ChildBounties: pallet_child_bounties,
|
||||
Referenda: pallet_referenda,
|
||||
ConvictionVoting: pallet_conviction_voting,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1405,6 +1484,7 @@ mod benches {
|
||||
[pallet_bounties, Bounties]
|
||||
[pallet_child_bounties, ChildBounties]
|
||||
[pallet_collective, Council]
|
||||
[pallet_conviction_voting, ConvictionVoting]
|
||||
[pallet_contracts, Contracts]
|
||||
[pallet_democracy, Democracy]
|
||||
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
|
||||
@@ -1421,6 +1501,7 @@ mod benches {
|
||||
[pallet_offences, OffencesBench::<Runtime>]
|
||||
[pallet_preimage, Preimage]
|
||||
[pallet_proxy, Proxy]
|
||||
[pallet_referenda, Referenda]
|
||||
[pallet_scheduler, Scheduler]
|
||||
[pallet_session, SessionBench::<Runtime>]
|
||||
[pallet_staking, Staking]
|
||||
|
||||
Reference in New Issue
Block a user