mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +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:
@@ -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