diff --git a/Cargo.lock b/Cargo.lock index 3ea81ef776..2e33f93ccf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1883,6 +1883,28 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +[[package]] +name = "git-version" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94918e83f1e01dedc2e361d00ce9487b14c58c7f40bab148026fa39d42cb41e2" +dependencies = [ + "git-version-macro", + "proc-macro-hack", +] + +[[package]] +name = "git-version-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34a97a52fdee1870a34fa6e4b77570cba531b27d1838874fef4429a791a3d657" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "glob" version = "0.3.0" @@ -2744,6 +2766,7 @@ dependencies = [ "environment", "eth2_testnet_config", "futures 0.3.5", + "git-version", "logging", "slog", "slog-async", diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index a3100d94bd..5e27ac40aa 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -25,6 +25,7 @@ validator_client = { "path" = "../validator_client" } account_manager = { "path" = "../account_manager" } clap_utils = { path = "../common/clap_utils" } eth2_testnet_config = { path = "../common/eth2_testnet_config" } +git-version = "0.3.4" [dev-dependencies] tempfile = "3.1.0" diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index ac7b32ffdd..1c03e505f8 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -7,20 +7,23 @@ use clap_utils; use env_logger::{Builder, Env}; use environment::EnvironmentBuilder; use eth2_testnet_config::HARDCODED_TESTNET; +use git_version::git_describe; use slog::{crit, info, warn}; use std::path::PathBuf; use std::process::exit; use types::EthSpec; use validator_client::ProductionValidatorClient; +pub const GIT_LATEST_COMMIT: &str = git_describe!("--always", "--dirty=-modified"); pub const DEFAULT_DATA_DIR: &str = ".lighthouse"; pub const CLIENT_CONFIG_FILENAME: &str = "beacon-node.toml"; pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml"; fn main() { // Parse the CLI parameters. + let version = format!("{} commit {}", crate_version!(), GIT_LATEST_COMMIT); let matches = App::new("Lighthouse") - .version(crate_version!()) + .version(version.as_str()) .author("Sigma Prime ") .setting(clap::AppSettings::ColoredHelp) .about(