mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 21:21:11 +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:
@@ -169,11 +169,13 @@ impl<
|
||||
Some(if now > offset {
|
||||
let block_after_last_session = (now.clone() - offset) % period.clone();
|
||||
if block_after_last_session > Zero::zero() {
|
||||
now.saturating_add(
|
||||
period.saturating_sub(block_after_last_session)
|
||||
)
|
||||
now.saturating_add(period.saturating_sub(block_after_last_session))
|
||||
} else {
|
||||
now
|
||||
// this branch happens when the session is already rotated or will rotate in this
|
||||
// block (depending on being called before or after `session::on_initialize`). Here,
|
||||
// we assume the latter, namely that this is called after `session::on_initialize`,
|
||||
// and thus we add period to it as well.
|
||||
now + period
|
||||
}
|
||||
} else {
|
||||
offset
|
||||
@@ -187,6 +189,10 @@ impl<
|
||||
// reasonable to come back here and properly calculate the weight of this function.
|
||||
0
|
||||
}
|
||||
|
||||
fn average_session_length() -> BlockNumber {
|
||||
Period::get()
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait for managing creation of new validator set.
|
||||
@@ -833,6 +839,10 @@ impl<T: Config> EstimateNextNewSession<T::BlockNumber> for Module<T> {
|
||||
T::NextSessionRotation::estimate_next_session_rotation(now)
|
||||
}
|
||||
|
||||
fn average_session_length() -> T::BlockNumber {
|
||||
T::NextSessionRotation::average_session_length()
|
||||
}
|
||||
|
||||
fn weight(now: T::BlockNumber) -> Weight {
|
||||
T::NextSessionRotation::weight(now)
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ fn periodic_session_works() {
|
||||
}
|
||||
|
||||
assert!(P::should_end_session(13u64));
|
||||
assert_eq!(P::estimate_next_session_rotation(13u64).unwrap(), 13);
|
||||
assert_eq!(P::estimate_next_session_rotation(13u64).unwrap(), 23);
|
||||
|
||||
assert!(!P::should_end_session(14u64));
|
||||
assert_eq!(P::estimate_next_session_rotation(14u64).unwrap(), 23);
|
||||
|
||||
Reference in New Issue
Block a user