mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Decouple Staking and Election - Part 2 Unsigned Phase (#7909)
* Base features and traits. * pallet and unsigned phase * Undo bad formattings. * some formatting cleanup. * Small self-cleanup. * Make it all build * self-review * Some doc tests. * Some changes from other PR * Fix session test * Update Cargo.lock * Update frame/election-provider-multi-phase/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Some review comments * Rename + make encode/decode * Do an assert as well, just in case. * Fix build * Update frame/election-provider-multi-phase/src/unsigned.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Las comment * fix staking fuzzer. * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Add one last layer of feasibility check as well. * Last fixes to benchmarks * Some more docs. * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Some nits * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Fix doc * Mkae ci green Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
This commit is contained in:
@@ -413,12 +413,14 @@ impl<T: Config> Module<T> {
|
||||
/// In other word, this is only accurate if no slots are missed. Given missed slots, the slot
|
||||
/// number will grow while the block number will not. Hence, the result can be interpreted as an
|
||||
/// upper bound.
|
||||
// -------------- IMPORTANT NOTE --------------
|
||||
//
|
||||
// ## IMPORTANT NOTE
|
||||
//
|
||||
// This implementation is linked to how [`should_epoch_change`] is working. This might need to
|
||||
// be updated accordingly, if the underlying mechanics of slot and epochs change.
|
||||
//
|
||||
// WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you update
|
||||
// this function, you must also update the corresponding weight.
|
||||
// WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you
|
||||
// update this function, you must also update the corresponding weight.
|
||||
pub fn next_expected_epoch_change(now: T::BlockNumber) -> Option<T::BlockNumber> {
|
||||
let next_slot = Self::current_epoch_start().saturating_add(T::EpochDuration::get());
|
||||
next_slot
|
||||
@@ -754,6 +756,10 @@ impl<T: Config> OnTimestampSet<T::Moment> for Module<T> {
|
||||
}
|
||||
|
||||
impl<T: Config> frame_support::traits::EstimateNextSessionRotation<T::BlockNumber> for Module<T> {
|
||||
fn average_session_length() -> T::BlockNumber {
|
||||
T::EpochDuration::get().saturated_into()
|
||||
}
|
||||
|
||||
fn estimate_next_session_rotation(now: T::BlockNumber) -> Option<T::BlockNumber> {
|
||||
Self::next_expected_epoch_change(now)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ use sp_consensus_babe::{AuthorityId, AuthorityPair, Slot};
|
||||
use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof};
|
||||
use sp_staking::SessionIndex;
|
||||
use pallet_staking::EraIndex;
|
||||
use sp_election_providers::onchain;
|
||||
use pallet_session::historical as pallet_session_historical;
|
||||
|
||||
type DummyValidatorId = u64;
|
||||
@@ -183,6 +184,13 @@ parameter_types! {
|
||||
pub const StakingUnsignedPriority: u64 = u64::max_value() / 2;
|
||||
}
|
||||
|
||||
impl onchain::Config for Test {
|
||||
type AccountId = <Self as frame_system::Config>::AccountId;
|
||||
type BlockNumber = <Self as frame_system::Config>::BlockNumber;
|
||||
type Accuracy = Perbill;
|
||||
type DataProvider = Staking;
|
||||
}
|
||||
|
||||
impl pallet_staking::Config for Test {
|
||||
type RewardRemainder = ();
|
||||
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
|
||||
@@ -205,6 +213,7 @@ impl pallet_staking::Config for Test {
|
||||
type MaxIterations = ();
|
||||
type MinSolutionScoreBump = ();
|
||||
type OffchainSolutionWeightLimit = ();
|
||||
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user