Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v1.3 #732

Merged
merged 12 commits into from
Dec 15, 2023
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ The format is based on [Keep a Changelog].

[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/

## [v1.3.0] - 2023-12-14
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved

The main changes of this release are as follows:
- Change the binary name to `polkadot-staking-miner` to publish on crates.io.
- Temporarly disable runtime upgrades more information below.
- Bump rust MSRV to 1.74
- Change `submit_signed_solution` extrinsic to be mortal

### Runtime upgrades are disabled

Recently, we noticed that it may be possible that the runtime upgrades won't
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
upgrade the metadata because the actual runtime upgrade is applied to the block
after 'state_subscribeRuntimeVersion' emits an event.
For that reason, runtime upgrades are temporarily disabled,
and polkadot-staking-miner is terminated.
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved

To deal with runtime upgrades, it should be sufficient to restart the client and wait a
few seconds until another block is finalized to fetch the latest metadata or verify
that the runtime upgrade has been applied successfully.

This is just a temporary fix and will be fixed in the next release.

### [Changed]
- refactor: make solution extrinsic mortal ([#728](https://github.com/paritytech/staking-miner-v2/pull/728))
- chore(deps): bump subxt, subxt-signer, scale-value ([#726](https://github.com/paritytech/staking-miner-v2/pull/726))
- chore(deps): bump clap from 4.4.10 to 4.4.11 ([#721](https://github.com/paritytech/staking-miner-v2/pull/721))
- chore(deps): bump tokio from 1.34.0 to 1.35.0 ([#724](https://github.com/paritytech/staking-miner-v2/pull/724))
- chore(deps): bump once_cell from 1.18.0 to 1.19.0 ([#722](https://github.com/paritytech/staking-miner-v2/pull/722))
- refactor: use `subxt-signer` to reduce the number of deps ([#720](https://github.com/paritytech/staking-miner-v2/pull/720))
- chore(deps): bump clap from 4.4.8 to 4.4.10 ([#719](https://github.com/paritytech/staking-miner-v2/pull/719))
- rename project to polkadot-staking-miner ([#717](https://github.com/paritytech/staking-miner-v2/pull/717))

## [v1.2.0] - 2023-11-23

The major changes of this release:
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.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-staking-miner"
version = "1.2.0"
version = "1.3.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
rust-version = "1.74.0"
Expand Down Expand Up @@ -51,4 +51,4 @@ regex = "1"

[features]
default = []
slow-tests = []
slow-tests = []
54 changes: 20 additions & 34 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ async fn main() -> Result<(), Error> {
// Start a new tokio task to perform the runtime updates in the background.
// if this fails then the miner will be stopped and has to be re-started.
let (tx_upgrade, rx_upgrade) = oneshot::channel::<Error>();
tokio::spawn(runtime_upgrade_task(client.chain_api().clone(), tx_upgrade));
tokio::spawn(runtime_upgrade_task(
client.chain_api().clone(),
tx_upgrade,
runtime_version.clone(),
));

let res = any_runtime!(chain, {
let fut = match command {
Expand Down Expand Up @@ -156,7 +160,7 @@ async fn main() -> Result<(), Error> {
run_command(fut, rx_upgrade).await
});

log::info!(target: LOG_TARGET, "round of execution finished. outcome = {:?}", res);
log::debug!(target: LOG_TARGET, "round of execution finished. outcome = {:?}", res);
res
}

Expand Down Expand Up @@ -206,49 +210,31 @@ async fn run_command(
}

/// Runs until the RPC connection fails or updating the metadata failed.
async fn runtime_upgrade_task(api: ChainClient, tx: oneshot::Sender<Error>) {
async fn runtime_upgrade_task(api: ChainClient, tx: oneshot::Sender<Error>, curr: RuntimeVersion) {
const ERR: &str = "Runtime upgrades are not supported at the moment, \
see https://github.com/paritytech/polkadot-staking-miner/issues/731 how deal with that";

let updater = api.updater();

let mut update_stream = match updater.runtime_updates().await {
Ok(u) => u,
Ok(update_stream) => update_stream,
Err(e) => {
let _ = tx.send(e.into());
return
return;
},
};

loop {
// if the runtime upgrade subscription fails then try establish a new one and if it fails quit.
let update = match update_stream.next().await {
Some(Ok(update)) => update,
_ => {
log::warn!(target: LOG_TARGET, "Runtime upgrade subscription failed");
update_stream = match updater.runtime_updates().await {
Ok(u) => u,
Err(e) => {
let _ = tx.send(e.into());
return
},
};
continue
},
};
while let Some(Ok(update)) = update_stream.next().await {
let new_version = update.runtime_version();

let version = update.runtime_version().spec_version;
match updater.apply_update(update) {
Ok(()) => {
if let Err(e) = epm::update_metadata_constants(&api) {
let _ = tx.send(e);
return
}
prometheus::on_runtime_upgrade();
log::info!(target: LOG_TARGET, "upgrade to v{} successful", version);
},
Err(e) => {
log::debug!(target: LOG_TARGET, "upgrade to v{} failed: {:?}", version, e);
},
let is_new_version = new_version.spec_version > curr.spec_version ||
new_version.transaction_version > curr.transaction_version;
if is_new_version {
break;
}
}

let _ = tx.send(Error::Other(ERR.to_string()));
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl From<subxt_rpc::RuntimeVersion> for RuntimeVersion {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, PartialEq, Debug, Clone)]
pub struct RuntimeVersion {
pub spec_name: String,
pub impl_name: String,
Expand Down
2 changes: 2 additions & 0 deletions src/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ mod hidden {
))
.unwrap()
});
#[allow(unused)]
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
static RUNTIME_UPGRADES: Lazy<Counter> = Lazy::new(|| {
register_counter!(opts!(
"staking_miner_runtime_upgrades",
Expand All @@ -178,6 +179,7 @@ mod hidden {
.unwrap()
});

#[allow(unused)]
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
pub fn on_runtime_upgrade() {
RUNTIME_UPGRADES.inc();
}
Expand Down