mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 19:45:41 +00:00
Allow staking miner to use different election algorithms (#3752)
* WIP * Dry run cmd working * Monitor cmd works * Configure balance with parameter type * Comments * cleannnn * Add balancing to PhragMMS * Move OffchainRanomBalancing to common * DRY mine_unchecked over config.solver * FMT * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Improve docs for any_runtime_unit! * Some cleanup * fmt * Correct capitilaztion * Improve version mismatch log * Revert "Improve version mismatch log" This reverts commit 57570403f654f1efa4307956cda2de6f0c64f70a. * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Remove Balancing struct and use Balancing Parameter type instead * update Substrate Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -18,20 +18,22 @@
|
||||
|
||||
use crate::{prelude::*, Error, SharedConfig};
|
||||
use codec::Encode;
|
||||
use frame_election_provider_support::SequentialPhragmen;
|
||||
use std::io::Write;
|
||||
|
||||
macro_rules! emergency_solution_cmd_for { ($runtime:ident) => { paste::paste! {
|
||||
/// Execute the emergency-solution command.
|
||||
pub(crate) async fn [<emergency_solution_cmd_ $runtime>](
|
||||
shared: SharedConfig,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<$crate::[<$runtime _runtime_exports>]::Runtime>> {
|
||||
use $crate::[<$runtime _runtime_exports>]::*;
|
||||
let mut ext = crate::create_election_ext::<Runtime, Block>(shared.uri.clone(), None, vec![]).await?;
|
||||
ext.execute_with(|| {
|
||||
assert!(EPM::Pallet::<Runtime>::current_phase().is_emergency());
|
||||
// NOTE: this internally calls feasibility_check, but we just re-do it here as an easy way
|
||||
// to get a `ReadySolution`.
|
||||
let (raw_solution, _) = <EPM::Pallet<Runtime>>::mine_solution(50)?;
|
||||
let (raw_solution, _) =
|
||||
<EPM::Pallet<Runtime>>::mine_solution::<SequentialPhragmen<AccountId, sp_runtime::Perbill>>()?;
|
||||
log::info!(target: LOG_TARGET, "mined solution with {:?}", &raw_solution.score);
|
||||
let ready_solution = EPM::Pallet::<Runtime>::feasibility_check(raw_solution, EPM::ElectionCompute::Signed)?;
|
||||
let encoded_ready = ready_solution.encode();
|
||||
|
||||
Reference in New Issue
Block a user