Adding benchmarking for new frame_election_provider_support (#11149)

* First stab at adding benchmarking for
`election-provider-support` onchain

* Adding `BoundedPhragMMS` and fixing stuff

* Fixing node runtime

* Fixing tests

* Finalising all benchmarking stuff

* better comments

* Better benchmarking config

* Better `WeightInfo` and benchmarking

* Fixing tests

* Adding some documentation

* Fixing some typos

* Incorporating review feedback

* cleanup of rustdocs

* rustdoc changes

* changes after code review

* Fixing some errors.

* Fixing dependencies post merge

* Bringing back `UnboundedExecution`

* Better rustdoc and naming

* Cargo.toml formatting
This commit is contained in:
Georges
2022-04-15 11:15:01 +01:00
committed by GitHub
parent 7dca0e467c
commit ae75a371bf
18 changed files with 365 additions and 54 deletions
@@ -17,7 +17,9 @@ static_assertions = "1.1.0"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
] }
log = { version = "0.4.14", default-features = false }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
@@ -33,11 +35,14 @@ frame-election-provider-support = { version = "4.0.0-dev", default-features = fa
# Optional imports for benchmarking
frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../benchmarking", optional = true }
pallet-election-provider-support-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../election-provider-support/benchmarking", optional = true }
rand = { version = "0.7.3", default-features = false, optional = true, features = [
"alloc",
"small_rng",
] }
strum = { optional = true, default-features = false, version = "0.23.0", features = ["derive"] }
strum = { optional = true, default-features = false, version = "0.23.0", features = [
"derive",
] }
[dev-dependencies]
parking_lot = "0.12.0"
@@ -46,7 +51,6 @@ sp-core = { version = "6.0.0", default-features = false, path = "../../primitive
sp-io = { version = "6.0.0", path = "../../primitives/io" }
sp-npos-elections = { version = "4.0.0-dev", default-features = false, path = "../../primitives/npos-elections" }
sp-tracing = { version = "5.0.0", path = "../../primitives/tracing" }
frame-election-provider-support = { version = "4.0.0-dev", path = "../election-provider-support" }
pallet-balances = { version = "4.0.0-dev", path = "../balances" }
frame-benchmarking = { version = "4.0.0-dev", path = "../benchmarking" }
@@ -276,10 +276,11 @@ parameter_types! {
}
pub struct OnChainSeqPhragmen;
impl onchain::ExecutionConfig for OnChainSeqPhragmen {
impl onchain::Config for OnChainSeqPhragmen {
type System = Runtime;
type Solver = SequentialPhragmen<AccountId, SolutionAccuracyOf<Runtime>, Balancing>;
type DataProvider = StakingMock;
type WeightInfo = ();
}
pub struct MockFallback;
@@ -304,7 +305,7 @@ impl InstantElectionProvider for MockFallback {
max_voters,
max_targets,
)
.map_err(|_| "UnboundedExecution failed")
.map_err(|_| "onchain::UnboundedExecution failed.")
} else {
super::NoFallback::<Runtime>::elect_with_bounds(max_voters, max_targets)
}