Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions polkadot/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@
use clap::Parser;
use std::path::PathBuf;

/// The version of the node. The passed-in version of the workers should match this.
pub const NODE_VERSION: &'static str = env!("SUBSTRATE_CLI_IMPL_VERSION");
/// The version of the node.
///
/// This is the version that is used for versioning this node binary.
/// By default the `minor` version is bumped in every release. `Major` or `patch` releases are only
/// expected in very rare cases.
///
/// The worker binaries associated to the node binary should ensure that they are using the same
/// version as the main node that started them.
pub const NODE_VERSION: &'static str = "1.1.0";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not env!("CARGO_PKG_VERSION")?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, okay, we don't want to use the commit hash in node version, but why the node version should be independent from the crate version in the first place?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because crates.io semver works differently to how we version our nodes.


#[allow(missing_docs)]
#[derive(Debug, Parser)]
Expand Down
3 changes: 2 additions & 1 deletion polkadot/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ impl SubstrateCli for Cli {
}

fn impl_version() -> String {
NODE_VERSION.into()
let commit_hash = env!("SUBSTRATE_CLI_COMMIT_HASH");
format!("{NODE_VERSION}-{commit_hash}")
}

fn description() -> String {
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/core/pvf/common/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use tokio::{io, net::UnixStream, runtime::Runtime};
/// spawning the desired worker.
#[macro_export]
macro_rules! decl_worker_main {
($expected_command:expr, $entrypoint:expr, $worker_version:expr) => {
($expected_command:expr, $entrypoint:expr, $worker_version:expr $(,)*) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

fn print_help(expected_command: &str) {
println!("{} {}", expected_command, $worker_version);
println!();
Expand Down
2 changes: 1 addition & 1 deletion polkadot/src/bin/execute-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
polkadot_node_core_pvf_common::decl_worker_main!(
"execute-worker",
polkadot_node_core_pvf_execute_worker::worker_entrypoint,
env!("SUBSTRATE_CLI_IMPL_VERSION")
polkadot_cli::NODE_VERSION,
);
2 changes: 1 addition & 1 deletion polkadot/src/bin/prepare-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
polkadot_node_core_pvf_common::decl_worker_main!(
"prepare-worker",
polkadot_node_core_pvf_prepare_worker::worker_entrypoint,
env!("SUBSTRATE_CLI_IMPL_VERSION")
polkadot_cli::NODE_VERSION,
);
1 change: 1 addition & 0 deletions substrate/utils/build-script-utils/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub fn generate_cargo_keys() {
}
};

println!("cargo:rustc-env=SUBSTRATE_CLI_COMMIT_HASH={commit}");
println!("cargo:rustc-env=SUBSTRATE_CLI_IMPL_VERSION={}", get_version(&commit))
}

Expand Down