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:
Kian Paimani
2021-02-23 14:46:17 +00:00
committed by GitHub
parent ba659f9440
commit 7205eea40d
34 changed files with 4092 additions and 231 deletions
+27 -7
View File
@@ -490,10 +490,16 @@ impl<
}
}
/// Something that can estimate at which block the next session rotation will happen. This should
/// be the same logical unit that dictates `ShouldEndSession` to the session module. No Assumptions
/// are made about the scheduling of the sessions.
/// Something that can estimate at which block the next session rotation will happen.
///
/// This should be the same logical unit that dictates `ShouldEndSession` to the session module. No
/// Assumptions are made about the scheduling of the sessions.
pub trait EstimateNextSessionRotation<BlockNumber> {
/// Return the average length of a session.
///
/// This may or may not be accurate.
fn average_session_length() -> BlockNumber;
/// Return the block number at which the next session rotation is estimated to happen.
///
/// None should be returned if the estimation fails to come to an answer
@@ -503,7 +509,11 @@ pub trait EstimateNextSessionRotation<BlockNumber> {
fn weight(now: BlockNumber) -> Weight;
}
impl<BlockNumber: Bounded> EstimateNextSessionRotation<BlockNumber> for () {
impl<BlockNumber: Bounded + Default> EstimateNextSessionRotation<BlockNumber> for () {
fn average_session_length() -> BlockNumber {
Default::default()
}
fn estimate_next_session_rotation(_: BlockNumber) -> Option<BlockNumber> {
Default::default()
}
@@ -513,9 +523,15 @@ impl<BlockNumber: Bounded> EstimateNextSessionRotation<BlockNumber> for () {
}
}
/// Something that can estimate at which block the next `new_session` will be triggered. This must
/// always be implemented by the session module.
/// Something that can estimate at which block the next `new_session` will be triggered.
///
/// This must always be implemented by the session module.
pub trait EstimateNextNewSession<BlockNumber> {
/// Return the average length of a session.
///
/// This may or may not be accurate.
fn average_session_length() -> BlockNumber;
/// Return the block number at which the next new session is estimated to happen.
fn estimate_next_new_session(now: BlockNumber) -> Option<BlockNumber>;
@@ -523,7 +539,11 @@ pub trait EstimateNextNewSession<BlockNumber> {
fn weight(now: BlockNumber) -> Weight;
}
impl<BlockNumber: Bounded> EstimateNextNewSession<BlockNumber> for () {
impl<BlockNumber: Bounded + Default> EstimateNextNewSession<BlockNumber> for () {
fn average_session_length() -> BlockNumber {
Default::default()
}
fn estimate_next_new_session(_: BlockNumber) -> Option<BlockNumber> {
Default::default()
}