mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
Remove balancing iterations from OCW miners (#4995)
* remove random balancing from unsigned solution * tweak miner a bit * add comments * lower kusama staking limits * Revert "lower kusama staking limits" This reverts commit 8ccccbb65a97b78505ef71a796698bb067cc6ba0. * Update utils/staking-miner/src/dry_run.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * last review Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -66,33 +66,6 @@ pub type OnOnChainAccuracy = sp_runtime::Perbill;
|
||||
pub type GenesisElectionOf<T> =
|
||||
frame_election_provider_support::onchain::OnChainSequentialPhragmen<T>;
|
||||
|
||||
/// Maximum number of iterations for balancing that will be executed in the embedded miner of
|
||||
/// pallet-election-provider-multi-phase.
|
||||
pub const MINER_MAX_ITERATIONS: u32 = 10;
|
||||
|
||||
/// A source of random balance for the NPoS Solver, which is meant to be run by the off-chain worker
|
||||
/// election miner.
|
||||
pub struct OffchainRandomBalancing;
|
||||
impl frame_support::pallet_prelude::Get<Option<(usize, sp_npos_elections::ExtendedBalance)>>
|
||||
for OffchainRandomBalancing
|
||||
{
|
||||
fn get() -> Option<(usize, sp_npos_elections::ExtendedBalance)> {
|
||||
use sp_runtime::{codec::Decode, traits::TrailingZeroInput};
|
||||
let iters = match MINER_MAX_ITERATIONS {
|
||||
0 => 0,
|
||||
max @ _ => {
|
||||
let seed = sp_io::offchain::random_seed();
|
||||
let random = <u32>::decode(&mut TrailingZeroInput::new(&seed))
|
||||
.expect("input is padded with zeroes; qed") %
|
||||
max.saturating_add(1);
|
||||
random as usize
|
||||
},
|
||||
};
|
||||
|
||||
Some((iters, 0))
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation of `frame_election_provider_support::SortedListProvider` that updates the
|
||||
/// bags-list but uses [`pallet_staking::Nominators`] for `iter`. This is meant to be a transitionary
|
||||
/// implementation for runtimes to "test" out the bags-list by keeping it up to date, but not yet
|
||||
|
||||
Reference in New Issue
Block a user