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:
Kian Paimani
2022-03-02 21:52:42 +00:00
committed by GitHub
parent 55e2ddd91c
commit 511344e86c
7 changed files with 30 additions and 40 deletions
+10 -6
View File
@@ -115,13 +115,17 @@ macro_rules! dry_run_cmd_for { ($runtime:ident) => { paste::paste! {
signer: Signer,
) -> Result<(), Error<$crate::[<$runtime _runtime_exports>]::Runtime>> {
use $crate::[<$runtime _runtime_exports>]::*;
let mut ext = crate::create_election_ext::<Runtime, Block>(
rpc.clone(),
config.at,
vec!["Staking".to_string(), "System".to_string()],
).await?;
force_create_snapshot::<Runtime>(&mut ext)?;
let pallets = if config.force_snapshot {
vec!["Staking".to_string(), "BagsList".to_string()]
} else {
Default::default()
};
let mut ext = crate::create_election_ext::<Runtime, Block>(rpc.clone(), config.at, pallets).await?;
if config.force_snapshot {
force_create_snapshot::<Runtime>(&mut ext)?;
};
log::debug!(target: LOG_TARGET, "solving with {:?}", config.solver);
let (raw_solution, witness) = crate::mine_with::<Runtime>(&config.solver, &mut ext, false)?;
let nonce = crate::get_account_info::<Runtime>(&rpc, &signer.account, config.at)
+10 -3
View File
@@ -343,6 +343,10 @@ struct DryRunConfig {
/// The solver algorithm to use.
#[clap(subcommand)]
solver: Solvers,
/// Force create a new snapshot, else expect one to exist onchain.
#[clap(long)]
force_snapshot: bool,
}
#[derive(Debug, Clone, Parser)]
@@ -351,12 +355,15 @@ struct SharedConfig {
#[clap(long, short, default_value = DEFAULT_URI, env = "URI")]
uri: String,
/// The seed of a funded account in hex.
/// The path to a file containing the seed of the account. If the file is not found, the seed is
/// used as-is.
///
/// Can also be provided via the `SEED` environment variable.
///
/// WARNING: Don't use an account with a large stash for this. Based on how the bot is
/// configured, it might re-try and lose funds through transaction fees/deposits.
#[clap(long, short, env = "SEED")]
seed: String,
seed_or_path: String,
}
#[derive(Debug, Clone, Parser)]
@@ -590,7 +597,7 @@ async fn main() {
};
let signer_account = any_runtime! {
signer::signer_uri_from_string::<Runtime>(&shared.seed, &rpc)
signer::signer_uri_from_string::<Runtime>(&shared.seed_or_path, &rpc)
.await
.expect("Provided account is invalid, terminating.")
};
+7 -1
View File
@@ -57,9 +57,15 @@ pub(crate) async fn signer_uri_from_string<
Hash = Hash,
> + EPM::Config,
>(
seed: &str,
mut seed_or_path: &str,
client: &SharedRpcClient,
) -> Result<Signer, Error<T>> {
seed_or_path = seed_or_path.trim();
let seed = match std::fs::read(seed_or_path) {
Ok(s) => String::from_utf8(s).map_err(|_| Error::<T>::AccountDoesNotExists)?,
Err(_) => seed_or_path.to_string(),
};
let seed = seed.trim();
let pair = Pair::from_string(seed, None)?;