mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 08:21:03 +00:00
Audit fixes for election/staking decoupling part 2 (#8167)
* 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 * Audit fixes for election-provider: part 2 signed phase. * Fix weight * Some grumbles. * Try and weigh to get_npos_voters * Fix build * Fix line width * 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 tests. * Fix build * Reorg some stuff * More reorg. * Reorg done. * Fix build * Another rename * Fix build * Update frame/election-provider-multi-phase/src/mock.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * nit * better doc * Line width * Fix build * Self-review * Self-review * Fix wan * 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_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs * fix build and review comments. * Update frame/election-provider-multi-phase/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * add comment 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> Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
This commit is contained in:
@@ -25,12 +25,9 @@ use sp_npos_elections::CompactSolution;
|
||||
use sp_runtime::traits::One;
|
||||
use frame_system::RawOrigin;
|
||||
pub use frame_benchmarking::{
|
||||
benchmarks,
|
||||
account,
|
||||
whitelisted_caller,
|
||||
whitelist_account,
|
||||
impl_benchmark_test_suite,
|
||||
benchmarks, account, whitelisted_caller, whitelist_account, impl_benchmark_test_suite,
|
||||
};
|
||||
|
||||
const SEED: u32 = 0;
|
||||
const MAX_SPANS: u32 = 100;
|
||||
const MAX_VALIDATORS: u32 = 1000;
|
||||
@@ -768,6 +765,39 @@ benchmarks! {
|
||||
).is_err()
|
||||
);
|
||||
}
|
||||
|
||||
get_npos_voters {
|
||||
// number of validator intention.
|
||||
let v in 200 .. 400;
|
||||
// number of nominator intention.
|
||||
let n in 200 .. 400;
|
||||
// total number of slashing spans. Assigned to validators randomly.
|
||||
let s in 1 .. 20;
|
||||
|
||||
let validators = create_validators_with_nominators_for_era::<T>(v, n, MAX_NOMINATIONS, false, None)?
|
||||
.into_iter()
|
||||
.map(|v| T::Lookup::lookup(v).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
(0..s).for_each(|index| {
|
||||
add_slashing_spans::<T>(&validators[index as usize], 10);
|
||||
});
|
||||
}: {
|
||||
let voters = <Staking<T>>::get_npos_voters();
|
||||
assert_eq!(voters.len() as u32, v + n);
|
||||
}
|
||||
|
||||
get_npos_targets {
|
||||
// number of validator intention.
|
||||
let v in 200 .. 400;
|
||||
// number of nominator intention.
|
||||
let n = 500;
|
||||
|
||||
let _ = create_validators_with_nominators_for_era::<T>(v, n, MAX_NOMINATIONS, false, None)?;
|
||||
}: {
|
||||
let targets = <Staking<T>>::get_npos_targets();
|
||||
assert_eq!(targets.len() as u32, v);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -875,7 +905,6 @@ mod tests {
|
||||
assert_ok!(test_benchmark_submit_solution_weaker::<Test>());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
|
||||
Reference in New Issue
Block a user