-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix 5560: add support for a new staking-miner info
command
#5577
Conversation
c0a0173
to
eb54f0e
Compare
Rebased on master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only some small things 👍
@kianenigma may want to take a look as well.
@PierreBesson does the current impl. work for you ? |
Yes it looks good to me. |
utils/staking-miner/src/main.rs
Outdated
Command::Info(_info_opts) => { | ||
let runtime_version: RuntimeVersion = rpc.runtime_version(None).await.expect("runtime_version infallible; qed."); | ||
let info = Info::new(&runtime_version); | ||
let info = serde_json::to_string_pretty(&info).expect("Failed serializing version info"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implement display on Info
directly would be better no need to serialize it as JSON.
EDIT: ok, I see could be useful with JSON.
utils/staking-miner/src/info.rs
Outdated
use sp_version::RuntimeVersion; | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub(crate) struct Info { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Info
is a bit vague, I would rather call it RuntimeVersion
or something like that.
Even if it's doesn't have all the data that the RuntimeVersion
from substrate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I wanted to it vague and extensible but I don't see an immediate need for that. I will make it more specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I left the subcommand as info
since it returns several information and no longer one version but internally the struct
are now named more specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, overall the code looks quite clean but I have some comments:
I propose to change --info
to --runtime-version
because it's too vague IMO.
In addition the entire point is to fetch the runtime version
from a "specific hardcoded runtime" such as polkadot, kusama and westend which doesn't work when you just use the RuntimeVersion
from the RPC node which may be different from what's used in the miner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get the linked version, not the one over RPC. Depending on your usecase, we might also need both? I am not sure. But the one over RPC can be fetched directly by contacting that node. No need to do that with staking miner. See here:
polkadot/utils/staking-miner/src/main.rs
Line 558 in ef57112
pub(crate) async fn check_versions<T: frame_system::Config + EPM::Config>( |
@PierreBesson Note that you may need to silence the logger if you want to use the json output from a script:
Not doing so will output the following "json":
|
The initial impl. was rather naive as So the changes are mainly:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,
Fetching the remote version
and comparing to linked version seems like a niche feature as it depends on the remote node but I reckon that it would be super useful for the devops
deployment.
Would be good with some feedback from @PierreBesson regarding the output format 🙏
Totally niche indeed, as this PR is. It is mainly to help the devops team run the right version of the staking-miner and check that it is (or not) still THE right version. |
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
} | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
pub(crate) struct RuntimeVersions<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niklasad1 would be good if we backport this clean approach to the new version :) nicely done @chevdor 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Just needs to make the CI green. |
* master: zombienet: try to fix parachains upgrade test (#5724) Update dependencies (companion for substrate#11722) (#5731) Update metric name and doc (#5716) Bump reqwest from 0.11.10 to 0.11.11 (#5732) add release-engineering to CI files' reviewers (#5733) Bump parity-scale-codec from 3.1.2 to 3.1.5 (#5720) Add checklist item (#5715) Fix 5560: add support for a new `staking-miner info` command (#5577) Bump `wasmtime` to 0.38.0 and `zstd` to 0.11.2 (companion for substrate#11720) (#5707) pvf: ensure enough stack space (#5712) Bump generic-array from 0.12.3 to 0.12.4 in /bridges/fuzz/storage-proof (#5648) pvf: unignore `terminates_on_timeout` test (#5722) Bump proc-macro2 from 1.0.39 to 1.0.40 (#5719) pass $COMPANION_OVERRIDES to check_dependent_project (#5708) Bump thread_local from 1.1.0 to 1.1.4 in /bridges/fuzz/storage-proof (#5687) Bump quote from 1.0.18 to 1.0.19 (#5700) Rococo: add new pallet-beefy-mmr API (companion for substrate#11406) (#5516) Update metric before bailing out (#5706) Add publish docker staking-miner (#5710)
* Refactoring opts out * Implement info command fix #5560 * remove useless change * Remove unnecessary brackets * Fix and add tests * Promote the uri flag to global * Ignore lint identity ops * Reverse adding #[allow(identity_op)] * Add cli test for the info command * Add licende headers and fix some grumbles * Add retrieval of the linked version and make the json output optional * Fix tests * Keep it generic and renamed builtin into linked * Rebase master * Add runtimes compatibility information * Silence erroneous warning about unsafe * Fix spellcheck * Update utils/staking-miner/src/runtime_versions.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Summary
This PR fixes #5560. It adds a new
info
command that can be used to identity the runtime version that is supported by this version of thestaking-miner
. It also refactors away the clap options to a separate file.Warning breaking change (cli)
--seed-or-path
moves from being a global flag to being a flag only for the 2 commands requiring it.So the previous:
becomes now:
and the seed is not required for the other commands.
help
New
info
command:Output (human, default)
Output (
--json
)cc @kianenigma @PierreBesson @ggwpez