Skip to content

Commit

Permalink
chore: release v1.0.0 (#588)
Browse files Browse the repository at this point in the history
* chore: release v1.0.0

* simplify subxt code

* make listening to `finalized heads` by default

* tweak changelog again
  • Loading branch information
niklasad1 authored Jun 2, 2023
1 parent 0890748 commit e01e9dc
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 57 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "staking-miner"
version = "0.1.4"
version = "1.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"

Expand Down
87 changes: 37 additions & 50 deletions src/commands/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use subxt::{
config::Header as _,
error::RpcError,
rpc::{types::DryRunResult, Subscription},
tx::TxStatus,
Error as SubxtError,
};
use tokio::sync::Mutex;
Expand All @@ -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.
Expand Down Expand Up @@ -408,7 +407,6 @@ where
&api,
signer,
(solution, score, round),
block_hash,
nonce,
config.listen,
config.dry_run,
Expand Down Expand Up @@ -502,7 +500,6 @@ async fn submit_and_watch_solution<T: MinerConfig + Send + Sync + 'static>(
api: &SubxtClient,
signer: Signer,
(solution, score, round): (SolutionOf<T>, sp_npos_elections::ElectionScore, u32),
block_hash: Hash,
nonce: u32,
listen: Listen,
dry_run: bool,
Expand All @@ -514,7 +511,7 @@ async fn submit_and_watch_solution<T: MinerConfig + Send + Sync + 'static>(
.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 => (),
Expand All @@ -524,58 +521,48 @@ async fn submit_and_watch_solution<T: MinerConfig + Send + Sync + 'static>(
}
}

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::<runtime::election_provider_multi_phase::events::SolutionStored>(
);

let solution_stored =
events
.find_first::<runtime::election_provider_multi_phase::events::SolutionStored>(
);
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::<runtime::election_provider_multi_phase::events::SolutionStored>(
);

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(
Expand Down
2 changes: 0 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")]
Expand Down
3 changes: 1 addition & 2 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ pub fn kill_main_task_if_critical_err(tx: &tokio::sync::mpsc::UnboundedSender<Er
Error::TransactionRejected(_) |
Error::JoinError(_) |
Error::Feasibility(_) |
Error::EmptySnapshot |
Error::SubscriptionClosed => {},
Error::EmptySnapshot => {},
Error::Subxt(SubxtError::Rpc(rpc_err)) => {
log::debug!(target: LOG_TARGET, "rpc error: {:?}", rpc_err);

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async fn runtime_upgrade_task(api: SubxtClient, tx: oneshot::Sender<Error>) {
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);
},
}
}
Expand Down

0 comments on commit e01e9dc

Please sign in to comment.