From e01e9dc020e805af5f0dc064e265d077c97710b6 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 2 Jun 2023 16:03:14 +0200 Subject: [PATCH] chore: release v1.0.0 (#588) * chore: release v1.0.0 * simplify subxt code * make listening to `finalized heads` by default * tweak changelog again --- CHANGELOG.md | 40 +++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/monitor.rs | 87 ++++++++++++++++++----------------------- src/error.rs | 2 - src/helpers.rs | 3 +- src/main.rs | 2 +- 7 files changed, 81 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a293615fe..cbdc85bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,46 @@ The format is based on [Keep a Changelog]. [Keep a Changelog]: http://keepachangelog.com/en/1.0.0/ +## [v1.0.0] - 2023-06-02 + +This is the first release staking-miner-v2 which makes it production ready +and the most noteable changes are: + + - Add support for `emergency solutions` + - Change `submission strategy if-leading` to only submit if the score is better. + - Listen to `finalized heads` by default. + +## Added +- add trimming tests ([#538](https://github.com/paritytech/staking-miner-v2/pull/538)) +- Implements emergency solution command ([#557](https://github.com/paritytech/staking-miner-v2/pull/557)) + +## Changed +- update subxt ([#571](https://github.com/paritytech/staking-miner-v2/pull/571)) +- chore(deps): bump once_cell from 1.17.1 to 1.17.2 ([#582](https://github.com/paritytech/staking-miner-v2/pull/582)) +- chore(deps): bump log from 0.4.17 to 0.4.18 ([#580](https://github.com/paritytech/staking-miner-v2/pull/580)) +- chore(deps): bump tokio from 1.28.1 to 1.28.2 ([#581](https://github.com/paritytech/staking-miner-v2/pull/581)) +- chore(deps): bump regex from 1.8.2 to 1.8.3 ([#577](https://github.com/paritytech/staking-miner-v2/pull/577)) +- chore: remove unused deps and features ([#575](https://github.com/paritytech/staking-miner-v2/pull/575)) +- chore(deps): bump regex from 1.8.1 to 1.8.2 ([#574](https://github.com/paritytech/staking-miner-v2/pull/574)) +- chore(deps): bump anyhow from 1.0.69 to 1.0.71 ([#570](https://github.com/paritytech/staking-miner-v2/pull/570)) +- chore(deps): bump scale-info from 2.6.0 to 2.7.0 ([#569](https://github.com/paritytech/staking-miner-v2/pull/569)) +- chore(deps): bump serde from 1.0.162 to 1.0.163 ([#565](https://github.com/paritytech/staking-miner-v2/pull/565)) +- chore(deps): bump tokio from 1.28.0 to 1.28.1 ([#560](https://github.com/paritytech/staking-miner-v2/pull/560)) +- chore(deps): bump serde from 1.0.160 to 1.0.162 ([#554](https://github.com/paritytech/staking-miner-v2/pull/554)) +- improve README ([#587](https://github.com/paritytech/staking-miner-v2/pull/587)) + +## Fixed +- tests: read at most 1024 lines of logs before rpc server output ([#556](https://github.com/paritytech/staking-miner-v2/pull/556)) +- helpers: parse rpc server addr ([#552](https://github.com/paritytech/staking-miner-v2/pull/552)) +- change `submission strategy == if leading` to not submit equal score ([#589](https://github.com/paritytech/staking-miner-v2/pull/589)) + +### Compatibility + +Tested against: +- Polkadot v9420 +- Kusama v9420 +- Westend v9420 + ## [v0.1.4] - 2023-05-04 This is a release to support new runtime changes in polkadot v0.9.42. diff --git a/Cargo.lock b/Cargo.lock index e84cf2465..4f4717b71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3988,7 +3988,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking-miner" -version = "0.1.4" +version = "1.0.0" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 0d5359362..f94c301d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "staking-miner" -version = "0.1.4" +version = "1.0.0" authors = ["Parity Technologies "] edition = "2021" diff --git a/src/commands/monitor.rs b/src/commands/monitor.rs index 5d8ec71b7..822793b4a 100644 --- a/src/commands/monitor.rs +++ b/src/commands/monitor.rs @@ -36,7 +36,6 @@ use subxt::{ config::Header as _, error::RpcError, rpc::{types::DryRunResult, Subscription}, - tx::TxStatus, Error as SubxtError, }; use tokio::sync::Mutex; @@ -49,7 +48,7 @@ pub struct MonitorConfig { /// Typically, finalized is safer and there is no chance of anything going wrong, but it can be /// slower. It is recommended to use finalized, if the duration of the signed phase is longer /// than the the finality delay. - #[clap(long, value_enum, default_value_t = Listen::Head)] + #[clap(long, value_enum, default_value_t = Listen::Finalized)] pub listen: Listen, /// The solver algorithm to use. @@ -408,7 +407,6 @@ where &api, signer, (solution, score, round), - block_hash, nonce, config.listen, config.dry_run, @@ -502,7 +500,6 @@ async fn submit_and_watch_solution( api: &SubxtClient, signer: Signer, (solution, score, round): (SolutionOf, sp_npos_elections::ElectionScore, u32), - block_hash: Hash, nonce: u32, listen: Listen, dry_run: bool, @@ -514,7 +511,7 @@ async fn submit_and_watch_solution( .create_signed_with_nonce(&tx, &*signer, nonce, ExtrinsicParams::default())?; if dry_run { - let dry_run_bytes = api.rpc().dry_run(xt.encoded(), Some(block_hash)).await?; + let dry_run_bytes = api.rpc().dry_run(xt.encoded(), None).await?; match dry_run_bytes.into_dry_run_result(&api.metadata())? { DryRunResult::Success => (), @@ -524,58 +521,48 @@ async fn submit_and_watch_solution( } } - let mut status_sub = xt.submit_and_watch().await.map_err(|e| { + let tx_progress = xt.submit_and_watch().await.map_err(|e| { log::warn!(target: LOG_TARGET, "submit solution failed: {:?}", e); e })?; - loop { - let status = match status_sub.next_item().await { - Some(Ok(status)) => status, - Some(Err(err)) => { - log::error!( - target: LOG_TARGET, - "watch submit extrinsic at {:?} failed: {:?}", - block_hash, - err - ); - return Err(err.into()) - }, - None => return Err(Error::SubscriptionClosed), - }; + match listen { + Listen::Head => { + let in_block = tx_progress.wait_for_in_block().await?; + let events = in_block.fetch_events().await.expect("events should exist"); - match status { - TxStatus::Ready | TxStatus::Broadcast(_) | TxStatus::Future => (), - TxStatus::InBlock(details) => { - let events = details.fetch_events().await.expect("events should exist"); + let solution_stored = events + .find_first::( + ); - let solution_stored = - events - .find_first::( - ); + if let Ok(Some(_)) = solution_stored { + log::info!("Included at {:?}", in_block.block_hash()); + } else { + return Err(Error::Other(format!( + "No SolutionStored event found at {:?}", + in_block.block_hash() + ))) + } + }, + Listen::Finalized => { + let finalized = tx_progress.wait_for_finalized_success().await?; - if let Ok(Some(_)) = solution_stored { - log::info!(target: LOG_TARGET, "Included at {:?}", details.block_hash()); - if let Listen::Head = listen { - return Ok(()) - } - } else { - return Err(Error::Other(format!( - "No SolutionStored event found at {:?}", - details.block_hash() - ))) - } - }, - TxStatus::Retracted(hash) => { - log::info!(target: LOG_TARGET, "Retracted at {:?}", hash); - }, - TxStatus::Finalized(details) => { - log::info!(target: LOG_TARGET, "Finalized at {:?}", details.block_hash()); - return Ok(()) - }, - _ => return Err(Error::TransactionRejected(format!("{:?}", status))), - } - } + let solution_stored = finalized + .find_first::( + ); + + if let Ok(Some(_)) = solution_stored { + log::info!("Finalized at {:?}", finalized.block_hash()); + } else { + return Err(Error::Other(format!( + "No SolutionStored event found at {:?}", + finalized.block_hash() + ))) + } + }, + }; + + Ok(()) } async fn heads_subscription( diff --git a/src/error.rs b/src/error.rs index 761845395..0ec98aa93 100644 --- a/src/error.rs +++ b/src/error.rs @@ -46,8 +46,6 @@ pub enum Error { InvalidMetadata(String), #[error("Transaction rejected: {0}")] TransactionRejected(String), - #[error("Subscription closed")] - SubscriptionClosed, #[error("Dynamic transaction error: {0}")] DynamicTransaction(String), #[error("Feasibility error: {0}")] diff --git a/src/helpers.rs b/src/helpers.rs index bf4a6f78c..86c1c42c9 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -88,8 +88,7 @@ pub fn kill_main_task_if_critical_err(tx: &tokio::sync::mpsc::UnboundedSender {}, + Error::EmptySnapshot => {}, Error::Subxt(SubxtError::Rpc(rpc_err)) => { log::debug!(target: LOG_TARGET, "rpc error: {:?}", rpc_err); diff --git a/src/main.rs b/src/main.rs index 9636e4176..ce5cc2621 100644 --- a/src/main.rs +++ b/src/main.rs @@ -246,7 +246,7 @@ async fn runtime_upgrade_task(api: SubxtClient, tx: oneshot::Sender) { log::info!(target: LOG_TARGET, "upgrade to version: {} successful", version); }, Err(e) => { - log::warn!(target: LOG_TARGET, "upgrade to version: {} failed: {:?}", version, e); + log::debug!(target: LOG_TARGET, "upgrade to version: {} failed: {:?}", version, e); }, } }