Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@ impl multi_block::unsigned::miner::MinerConfig for Runtime {
type MaxVotesPerVoter =
<<Self as multi_block::Config>::DataProvider as ElectionDataProvider>::MaxVotesPerVoter;
type MaxLength = MinerMaxLength;
type Solver = <Runtime as multi_block::unsigned::Config>::OffchainSolver;
type Pages = Pages;
type Solution = NposCompactSolution16;
type VoterSnapshotPerBlock = <Runtime as multi_block::Config>::VoterSnapshotPerBlock;
type TargetSnapshotPerBlock = <Runtime as multi_block::Config>::TargetSnapshotPerBlock;
// for prod, use whatever solver we are using in the miner -- phragmen algorithm
#[cfg(not(feature = "runtime-benchmarks"))]
type Solver = <Runtime as multi_block::unsigned::Config>::OffchainSolver;
// for benchmarks, use the faster solver
#[cfg(feature = "runtime-benchmarks")]
type Solver = frame_election_provider_support::QuickDirtySolver<AccountId, Perbill>;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
//! Autogenerated weights for `pallet_election_provider_multi_block`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-10-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-10-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `30261411344a`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `9203a6611a81`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -58,8 +58,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::WeightInfo f
// Proof Size summary in bytes:
// Measured: `118`
// Estimated: `1603`
// Minimum execution time: 7_306_000 picoseconds.
Weight::from_parts(7_601_000, 0)
// Minimum execution time: 7_446_000 picoseconds.
Weight::from_parts(7_812_000, 0)
.saturating_add(Weight::from_parts(0, 1603))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -86,8 +86,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::WeightInfo f
// Proof Size summary in bytes:
// Measured: `48346`
// Estimated: `2526811`
// Minimum execution time: 5_889_231_000 picoseconds.
Weight::from_parts(5_978_684_000, 0)
// Minimum execution time: 5_996_743_000 picoseconds.
Weight::from_parts(6_143_499_000, 0)
.saturating_add(Weight::from_parts(0, 2526811))
.saturating_add(T::DbWeight::get().reads(1006))
.saturating_add(T::DbWeight::get().writes(4))
Expand Down Expand Up @@ -126,8 +126,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::WeightInfo f
// Proof Size summary in bytes:
// Measured: `1495638`
// Estimated: `3241503`
// Minimum execution time: 31_397_565_000 picoseconds.
Weight::from_parts(33_054_412_000, 0)
// Minimum execution time: 33_030_368_000 picoseconds.
Weight::from_parts(33_970_009_000, 0)
.saturating_add(Weight::from_parts(0, 3241503))
.saturating_add(T::DbWeight::get().reads(2923))
.saturating_add(T::DbWeight::get().writes(6))
Expand All @@ -146,8 +146,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::WeightInfo f
// Proof Size summary in bytes:
// Measured: `592`
// Estimated: `4057`
// Minimum execution time: 48_861_000 picoseconds.
Weight::from_parts(57_380_000, 0)
// Minimum execution time: 50_428_000 picoseconds.
Weight::from_parts(59_050_000, 0)
.saturating_add(Weight::from_parts(0, 4057))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -170,8 +170,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::WeightInfo f
// Proof Size summary in bytes:
// Measured: `1479`
// Estimated: `4944`
// Minimum execution time: 74_862_000 picoseconds.
Weight::from_parts(93_436_000, 0)
// Minimum execution time: 79_507_000 picoseconds.
Weight::from_parts(83_771_000, 0)
.saturating_add(Weight::from_parts(0, 4944))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
Expand Down Expand Up @@ -208,8 +208,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::WeightInfo f
// Proof Size summary in bytes:
// Measured: `4847`
// Estimated: `85037`
// Minimum execution time: 273_049_000 picoseconds.
Weight::from_parts(329_970_000, 0)
// Minimum execution time: 288_365_000 picoseconds.
Weight::from_parts(310_587_000, 0)
.saturating_add(Weight::from_parts(0, 85037))
.saturating_add(T::DbWeight::get().reads(104))
.saturating_add(T::DbWeight::get().writes(106))
Expand All @@ -218,8 +218,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::WeightInfo f
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 198_000 picoseconds.
Weight::from_parts(234_000, 0)
// Minimum execution time: 195_000 picoseconds.
Weight::from_parts(229_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
//! Autogenerated weights for `pallet_election_provider_multi_block_signed`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-10-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-10-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `30261411344a`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `9203a6611a81`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -66,8 +66,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::signed::Weig
// Proof Size summary in bytes:
// Measured: `3252`
// Estimated: `6717`
// Minimum execution time: 82_268_000 picoseconds.
Weight::from_parts(84_404_000, 0)
// Minimum execution time: 82_298_000 picoseconds.
Weight::from_parts(85_205_000, 0)
.saturating_add(Weight::from_parts(0, 6717))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -90,8 +90,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::signed::Weig
// Proof Size summary in bytes:
// Measured: `7851`
// Estimated: `88041`
// Minimum execution time: 224_911_000 picoseconds.
Weight::from_parts(234_697_000, 0)
// Minimum execution time: 222_710_000 picoseconds.
Weight::from_parts(227_768_000, 0)
.saturating_add(Weight::from_parts(0, 88041))
.saturating_add(T::DbWeight::get().reads(39))
.saturating_add(T::DbWeight::get().writes(37))
Expand All @@ -114,8 +114,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::signed::Weig
// Proof Size summary in bytes:
// Measured: `3785`
// Estimated: `7250`
// Minimum execution time: 173_658_000 picoseconds.
Weight::from_parts(227_077_000, 0)
// Minimum execution time: 175_724_000 picoseconds.
Weight::from_parts(196_243_000, 0)
.saturating_add(Weight::from_parts(0, 7250))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -138,8 +138,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::signed::Weig
// Proof Size summary in bytes:
// Measured: `3887`
// Estimated: `7352`
// Minimum execution time: 171_867_000 picoseconds.
Weight::from_parts(212_382_000, 0)
// Minimum execution time: 159_836_000 picoseconds.
Weight::from_parts(175_455_000, 0)
.saturating_add(Weight::from_parts(0, 7352))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -160,8 +160,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::signed::Weig
// Proof Size summary in bytes:
// Measured: `4717`
// Estimated: `84907`
// Minimum execution time: 139_262_000 picoseconds.
Weight::from_parts(145_668_000, 0)
// Minimum execution time: 138_145_000 picoseconds.
Weight::from_parts(143_634_000, 0)
.saturating_add(Weight::from_parts(0, 84907))
.saturating_add(T::DbWeight::get().reads(37))
.saturating_add(T::DbWeight::get().writes(35))
Expand All @@ -183,11 +183,11 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::signed::Weig
// Proof Size summary in bytes:
// Measured: `3709 + p * (32 ±0)`
// Estimated: `7174 + p * (2507 ±0)`
// Minimum execution time: 84_803_000 picoseconds.
Weight::from_parts(86_900_104, 0)
// Minimum execution time: 83_110_000 picoseconds.
Weight::from_parts(86_716_939, 0)
.saturating_add(Weight::from_parts(0, 7174))
// Standard Error: 9_113
.saturating_add(Weight::from_parts(1_149_584, 0).saturating_mul(p.into()))
// Standard Error: 8_086
.saturating_add(Weight::from_parts(1_143_762, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(3))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
//! Autogenerated weights for `pallet_election_provider_multi_block_unsigned`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-10-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-10-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `30261411344a`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `9203a6611a81`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -68,8 +68,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::unsigned::We
// Proof Size summary in bytes:
// Measured: `351`
// Estimated: `3816`
// Minimum execution time: 38_144_000 picoseconds.
Weight::from_parts(46_852_000, 0)
// Minimum execution time: 39_895_000 picoseconds.
Weight::from_parts(47_532_000, 0)
.saturating_add(Weight::from_parts(0, 3816))
.saturating_add(T::DbWeight::get().reads(7))
}
Expand All @@ -95,8 +95,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::unsigned::We
// Proof Size summary in bytes:
// Measured: `760999`
// Estimated: `766939`
// Minimum execution time: 1_224_980_000 picoseconds.
Weight::from_parts(1_295_589_000, 0)
// Minimum execution time: 1_262_183_000 picoseconds.
Weight::from_parts(1_357_073_000, 0)
.saturating_add(Weight::from_parts(0, 766939))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(3))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
//! Autogenerated weights for `pallet_election_provider_multi_block_verifier`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-10-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-10-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `30261411344a`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `9203a6611a81`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -76,8 +76,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::verifier::We
// Proof Size summary in bytes:
// Measured: `373126`
// Estimated: `376591`
// Minimum execution time: 641_281_000 picoseconds.
Weight::from_parts(720_764_000, 0)
// Minimum execution time: 663_496_000 picoseconds.
Weight::from_parts(721_326_000, 0)
.saturating_add(Weight::from_parts(0, 376591))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
Expand Down Expand Up @@ -114,8 +114,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::verifier::We
// Proof Size summary in bytes:
// Measured: `409681`
// Estimated: `492346`
// Minimum execution time: 1_163_590_000 picoseconds.
Weight::from_parts(1_241_096_000, 0)
// Minimum execution time: 1_163_984_000 picoseconds.
Weight::from_parts(1_251_180_000, 0)
.saturating_add(Weight::from_parts(0, 492346))
.saturating_add(T::DbWeight::get().reads(76))
.saturating_add(T::DbWeight::get().writes(72))
Expand Down Expand Up @@ -152,8 +152,8 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::verifier::We
// Proof Size summary in bytes:
// Measured: `409681`
// Estimated: `492346`
// Minimum execution time: 1_129_775_000 picoseconds.
Weight::from_parts(1_227_323_000, 0)
// Minimum execution time: 1_157_787_000 picoseconds.
Weight::from_parts(1_238_823_000, 0)
.saturating_add(Weight::from_parts(0, 492346))
.saturating_add(T::DbWeight::get().reads(107))
.saturating_add(T::DbWeight::get().writes(102))
Expand Down Expand Up @@ -191,11 +191,11 @@ impl<T: frame_system::Config> pallet_election_provider_multi_block::verifier::We
// Proof Size summary in bytes:
// Measured: `417092 + v * (37 ±0)`
// Estimated: `488244 + v * (2550 ±72)`
// Minimum execution time: 853_783_000 picoseconds.
Weight::from_parts(946_789_493, 0)
// Minimum execution time: 867_534_000 picoseconds.
Weight::from_parts(949_679_491, 0)
.saturating_add(Weight::from_parts(0, 488244))
// Standard Error: 118_548
.saturating_add(Weight::from_parts(4_126_302, 0).saturating_mul(v.into()))
// Standard Error: 136_466
.saturating_add(Weight::from_parts(4_764_609, 0).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(43))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes(38))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ mod benchmarks {
Ok(())
}

/// NOTE: make sure this benchmark is being run with the correct `type Solver` in `MinerConfig`.
#[benchmark(extra, pov_mode = Measured)]
fn mine_solution(p: Linear<1, { T::Pages::get() }>) -> Result<(), BenchmarkError> {
#[cfg(test)]
Expand Down
4 changes: 4 additions & 0 deletions substrate/frame/election-provider-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,9 @@ pub trait NposSolver {
/// Then it iterates over the voters and assigns them to the winners.
///
/// It is only meant to be used in benchmarking.
#[cfg(feature = "runtime-benchmarks")]
pub struct QuickDirtySolver<AccountId, Accuracy>(core::marker::PhantomData<(AccountId, Accuracy)>);
#[cfg(feature = "runtime-benchmarks")]
impl<AccountId: IdentifierT, Accuracy: PerThing128> NposSolver
for QuickDirtySolver<AccountId, Accuracy>
{
Expand Down Expand Up @@ -823,11 +825,13 @@ impl<AccountId: IdentifierT, Accuracy: PerThing128> NposSolver
let mut final_winners = BTreeMap::<Self::AccountId, u128>::new();

for (voter, weight, votes) in voters {
// any of the `n` winners that we have voted for..
let our_winners = winners
.iter()
.filter(|w| votes.clone().into_iter().any(|v| v == **w))
.collect::<Vec<_>>();
let our_winners_len = our_winners.len();
// will get `1/n` of our stake/weight.
let distribution = our_winners
.into_iter()
.map(|w| {
Expand Down
20 changes: 10 additions & 10 deletions substrate/frame/staking-async/runtimes/parachain/bench_all.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# run this, then copy all files to `substrate/frame/election-provider-multi-block/src/weights/`
source ~/.zshrc

STEPS=2
REPEAT=2
STEPS=20
REPEAT=20

# if any of the command line arguments are equal to `--log=X`, set X to the below log levels
LOG="runtime::multiblock-election=info,runtime::staking-async=info,frame::benchmark=info"
Expand All @@ -11,7 +11,7 @@ if [[ "${NO_COMPILE}" == "1" ]]; then
echo "Skipping compilation because 'NO_COMPILE' was set"
else
cargo build --release -p frame-omni-bencher
FORCE_WASM_BUILD=$RANDOM WASMTIME_BACKTRACE_DETAILS=1 RUST_LOG=${LOG} cargo build --release -p pallet-staking-async-parachain-runtime --features runtime-benchmarks
FORCE_WASM_BUILD=$RANDOM SKIP_PALLET_REVIVE_FIXTURES=1 WASMTIME_BACKTRACE_DETAILS=1 RUST_LOG=${LOG} cargo build --release -p pallet-staking-async-parachain-runtime --features runtime-benchmarks
fi

WASM_BLOB_PATH=../../../../../target/release/wbuild/pallet-staking-async-parachain-runtime/pallet_staking_async_parachain_runtime.compact.wasm
Expand Down Expand Up @@ -43,12 +43,12 @@ run_benchmark() {

# run_benchmark "pallet_staking_async" "fake-dot"
run_benchmark "pallet_election_provider_multi_block" "fake-dot"
run_benchmark "pallet_election_provider_multi_block_signed" "fake-dot"
run_benchmark "pallet_election_provider_multi_block_unsigned" "fake-dot"
run_benchmark "pallet_election_provider_multi_block_verifier" "fake-dot"
# run_benchmark "pallet_election_provider_multi_block_signed" "fake-dot"
# run_benchmark "pallet_election_provider_multi_block_unsigned" "fake-dot"
# run_benchmark "pallet_election_provider_multi_block_verifier" "fake-dot"

# run_benchmark "pallet_staking_async" "fake-ksm"
run_benchmark "pallet_election_provider_multi_block" "fake-ksm"
run_benchmark "pallet_election_provider_multi_block_signed" "fake-ksm"
run_benchmark "pallet_election_provider_multi_block_unsigned" "fake-ksm"
run_benchmark "pallet_election_provider_multi_block_verifier" "fake-ksm"
# run_benchmark "pallet_election_provider_multi_block" "fake-ksm"
# run_benchmark "pallet_election_provider_multi_block_signed" "fake-ksm"
# run_benchmark "pallet_election_provider_multi_block_unsigned" "fake-ksm"
# run_benchmark "pallet_election_provider_multi_block_verifier" "fake-ksm"
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
staking_async_parachain_genesis(params, id.to_string())
},
"fake-dot" => {
params.validator_count = 500;
params.validator_count = 600;
params.dev_stakers = Some((2_500, 25_000));
staking_async_parachain_genesis(params, id.to_string())
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ impl multi_block::unsigned::miner::MinerConfig for Runtime {
type MaxVotesPerVoter =
<<Self as multi_block::Config>::DataProvider as ElectionDataProvider>::MaxVotesPerVoter;
type MaxLength = MinerMaxLength;
#[cfg(feature = "runtime-benchmarks")]
type Solver = frame_election_provider_support::QuickDirtySolver<AccountId, Perbill>;
#[cfg(not(feature = "runtime-benchmarks"))]
type Solver = <Runtime as multi_block::unsigned::Config>::OffchainSolver;
type Pages = Pages;
type Solution = NposCompactSolution16;
Expand Down
Loading