Lighthouse v0.2.0 (Medalla) (#1452)

## Issue Addressed

NA

## Proposed Changes

- Moves the git-based versioning we were doing into the `lighthouse_version` crate in `common`.
- Removes the `beacon_node/version` crate, replacing it with `lighthouse_version`.
- Bumps the version to `v0.2.0`.

## Additional Info

There are now two types of version string:

1. `const VERSION: &str = Lighthouse/v0.2.0-1419501f2+`
1. `version_with_platform() = Lighthouse/v0.2.0-1419501f2+/x86_64-linux`

(1) is handy cause it's a `const` and shorter. (2) has platform info so it's more useful. Note that the plus-sign (`+`) indicates the the git commit is dirty (it used to be `(modified)` but I had to shorten it to fit into graffiti).

These version strings are now included on:

- `lighthouse --version`
- `lcli --version`
- `curl localhost:5052/node/version`
- p2p messages when we communicate our version

You can update the version by changing this constant (version is not related to a `Cargo.toml`):

b9ad7102d5/common/lighthouse_version/src/lib.rs (L4-L15)
This commit is contained in:
Paul Hauner 2020-08-04 07:44:53 +00:00
parent d4dd25883f
commit f26adc0a36
20 changed files with 83 additions and 84 deletions

24
Cargo.lock generated
View File

@ -424,6 +424,7 @@ dependencies = [
"futures 0.3.5",
"genesis",
"hyper 0.13.7",
"lighthouse_version",
"logging",
"node_test_rig",
"rand 0.7.3",
@ -434,7 +435,6 @@ dependencies = [
"store",
"tokio 0.2.22",
"types",
"version",
]
[[package]]
@ -1546,6 +1546,7 @@ dependencies = [
"lazy_static",
"libp2p",
"lighthouse_metrics",
"lighthouse_version",
"lru",
"parking_lot 0.11.0",
"rand 0.7.3",
@ -1565,7 +1566,6 @@ dependencies = [
"tokio-util",
"types",
"unsigned-varint 0.3.3 (git+https://github.com/sigp/unsigned-varint?branch=latest-codecs)",
"version",
"void",
]
@ -2591,6 +2591,7 @@ dependencies = [
"futures 0.3.5",
"genesis",
"hex 0.4.2",
"lighthouse_version",
"log 0.4.11",
"rand 0.7.3",
"regex",
@ -2990,7 +2991,7 @@ dependencies = [
"environment",
"eth2_testnet_config",
"futures 0.3.5",
"git-version",
"lighthouse_version",
"logging",
"slog",
"slog-async",
@ -3011,6 +3012,14 @@ dependencies = [
"prometheus",
]
[[package]]
name = "lighthouse_version"
version = "0.1.0"
dependencies = [
"git-version",
"target_info",
]
[[package]]
name = "linked-hash-map"
version = "0.5.3"
@ -4342,6 +4351,7 @@ dependencies = [
"itertools 0.9.0",
"lazy_static",
"lighthouse_metrics",
"lighthouse_version",
"network",
"node_test_rig",
"operation_pool",
@ -4363,7 +4373,6 @@ dependencies = [
"types",
"uhttp_sse",
"url 2.1.1",
"version",
]
[[package]]
@ -6179,13 +6188,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version"
version = "0.1.2"
dependencies = [
"target_info",
]
[[package]]
name = "version_check"
version = "0.1.5"

View File

@ -11,7 +11,6 @@ members = [
"beacon_node/rest_api",
"beacon_node/store",
"beacon_node/timer",
"beacon_node/version",
"beacon_node/websocket_server",
"boot_node",
@ -27,6 +26,7 @@ members = [
"common/eth2_wallet_manager",
"common/hashset_delay",
"common/lighthouse_metrics",
"common/lighthouse_version",
"common/logging",
"common/remote_beacon_node",
"common/rest_types",

View File

@ -1,7 +1,7 @@
[package]
name = "beacon_node"
version = "0.1.2"
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com"]
authors = ["Paul Hauner <paul@paulhauner.com>", "Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
[lib]
@ -20,7 +20,6 @@ beacon_chain = { path = "beacon_chain" }
types = { path = "../consensus/types" }
store = { path = "./store" }
client = { path = "client" }
version = { path = "version" }
clap = "2.33.0"
rand = "0.7.3"
slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_trace"] }
@ -40,3 +39,4 @@ eth2_ssz = "0.1.2"
serde = "1.0.110"
clap_utils = { path = "../common/clap_utils" }
hyper = "0.13.5"
lighthouse_version = { path = "../common/lighthouse_version" }

View File

@ -1,7 +1,7 @@
[package]
name = "beacon_chain"
version = "0.1.2"
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com>"]
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
[features]

View File

@ -14,7 +14,7 @@ serde_derive = "1.0.110"
eth2_ssz = "0.1.2"
eth2_ssz_derive = "0.1.0"
slog = { version = "2.5.2", features = ["max_level_trace"] }
version = { path = "../version" }
lighthouse_version = { path = "../../common/lighthouse_version" }
tokio = { version = "0.2.21", features = ["time", "macros"] }
futures = "0.3.5"
error-chain = "0.12.2"

View File

@ -77,7 +77,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
let identify = Identify::new(
"lighthouse/libp2p".into(),
version::version(),
lighthouse_version::version_with_platform(),
local_key.public(),
);

View File

@ -131,7 +131,7 @@ impl Default for Config {
discv5_config,
boot_nodes: vec![],
libp2p_nodes: vec![],
client_version: version::version(),
client_version: lighthouse_version::version_with_platform(),
disable_discovery: false,
topics,
}

View File

@ -12,7 +12,6 @@ beacon_chain = { path = "../beacon_chain" }
network = { path = "../network" }
eth2_libp2p = { path = "../eth2_libp2p" }
store = { path = "../store" }
version = { path = "../version" }
serde = { version = "1.0.110", features = ["derive"] }
serde_json = "1.0.52"
serde_yaml = "0.8.11"
@ -40,6 +39,7 @@ environment = { path = "../../lighthouse/environment" }
uhttp_sse = "0.5.1"
bus = "2.2.3"
itertools = "0.9.0"
lighthouse_version = { path = "../../common/lighthouse_version" }
[dev-dependencies]
assert_matches = "1.3.0"

View File

@ -2,13 +2,14 @@ use crate::response_builder::ResponseBuilder;
use crate::{ApiError, ApiResult};
use eth2_libp2p::{types::SyncState, NetworkGlobals};
use hyper::{Body, Request};
use lighthouse_version::version_with_platform;
use rest_types::{Health, SyncingResponse, SyncingStatus};
use std::sync::Arc;
use types::{EthSpec, Slot};
/// Read the version string from the current Lighthouse build.
pub fn get_version(req: Request<Body>) -> ApiResult {
ResponseBuilder::new(&req)?.body_no_ssz(&version::version())
ResponseBuilder::new(&req)?.body_no_ssz(&version_with_platform())
}
pub fn syncing<T: EthSpec>(

View File

@ -24,7 +24,6 @@ use types::{
RelativeEpoch, Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedRoot, Slot,
SubnetId, Validator,
};
use version;
type E = MinimalEthSpec;
@ -764,7 +763,11 @@ fn get_version() {
.block_on(remote_node.http.node().get_version())
.expect("should fetch eth2 config from http api");
assert_eq!(version::version(), version, "result should be as expected");
assert_eq!(
lighthouse_version::version_with_platform(),
version,
"result should be as expected"
);
}
#[test]

View File

@ -1,11 +1,5 @@
use clap::{App, Arg};
// Default text included in blocks.
// Must be 32-bytes or will not build.
//
// |-------must be this long------|
const DEFAULT_GRAFFITI: &str = "sigp/lighthouse-0.1.2-prerelease";
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
App::new("beacon_node")
.visible_aliases(&["b", "bn", "beacon"])
@ -248,9 +242,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.arg(
Arg::with_name("graffiti")
.long("graffiti")
.help("Specify your custom graffiti to be included in blocks.")
.help(
"Specify your custom graffiti to be included in blocks. \
Defaults to the current version and commit, truncated to fit in 32 bytes. "
)
.value_name("GRAFFITI")
.default_value(DEFAULT_GRAFFITI)
.takes_value(true)
)
}

View File

@ -6,6 +6,7 @@ use eth2_libp2p::{Enr, Multiaddr};
use eth2_testnet_config::Eth2TestnetConfig;
use slog::{crit, info, Logger};
use ssz::Encode;
use std::cmp;
use std::fs;
use std::net::{IpAddr, Ipv4Addr, ToSocketAddrs};
use std::net::{TcpListener, UdpSocket};
@ -350,21 +351,22 @@ pub fn get_config<E: EthSpec>(
client_config.genesis = ClientGenesis::DepositContract;
}
if let Some(graffiti) = cli_args.value_of("graffiti") {
let graffiti_bytes = graffiti.as_bytes();
if graffiti_bytes.len() > GRAFFITI_BYTES_LEN {
let raw_graffiti = if let Some(graffiti) = cli_args.value_of("graffiti") {
if graffiti.len() > GRAFFITI_BYTES_LEN {
return Err(format!(
"Your graffiti is too long! {} bytes maximum!",
GRAFFITI_BYTES_LEN
));
} else {
// `client_config.graffiti` is initialized by default to be all 0.
// We simply copy the bytes from `graffiti_bytes` in there.
//
// Panic-free because `graffiti_bytes.len()` <= `GRAFFITI_BYTES_LEN`.
client_config.graffiti[..graffiti_bytes.len()].copy_from_slice(graffiti_bytes);
}
}
graffiti.as_bytes()
} else {
lighthouse_version::VERSION.as_bytes()
};
let trimmed_graffiti_len = cmp::min(raw_graffiti.len(), GRAFFITI_BYTES_LEN);
client_config.graffiti[..trimmed_graffiti_len]
.copy_from_slice(&raw_graffiti[..trimmed_graffiti_len]);
Ok(client_config)
}

View File

@ -1,8 +0,0 @@
[package]
name = "version"
version = "0.1.2"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
[dependencies]
target_info = "0.1.0"

View File

@ -1,25 +0,0 @@
//TODO: Build the version and hash of the built lighthouse binary
/// Version information for the Lighthouse beacon node.
// currently only supports unstable release
extern crate target_info;
use target_info::Target;
const TRACK: &str = "unstable";
/// Provides the current platform
pub fn platform() -> String {
format!("{}-{}", Target::arch(), Target::os())
}
/// Version of the beacon node.
// TODO: Find the sha3 hash, date and rust version used to build the beacon_node binary
pub fn version() -> String {
format!(
"Lighthouse/v{}-{}/{}",
env!("CARGO_PKG_VERSION"),
TRACK,
platform()
)
}

View File

@ -0,0 +1,11 @@
[package]
name = "lighthouse_version"
version = "0.1.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
git-version = "0.3.4"
target_info = "0.1.0"

View File

@ -0,0 +1,24 @@
use git_version::git_version;
use target_info::Target;
/// Returns the current version of this build of Lighthouse.
///
/// A plus-sign (`+`) is appended to the git commit if the tree is dirty.
///
/// ## Example
///
/// `Lighthouse/v0.2.0-1419501f2+`
pub const VERSION: &str = git_version!(
args = ["--always", "--dirty=+"],
prefix = "Lighthouse/v0.2.0/",
fallback = "unknown"
);
/// Returns `VERSION`, but with platform information appended to the end.
///
/// ## Example
///
/// `Lighthouse/v0.2.0-1419501f2+/x86_64-linux`
pub fn version_with_platform() -> String {
format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
}

View File

@ -34,3 +34,4 @@ eth2_libp2p = { path = "../beacon_node/eth2_libp2p" }
validator_dir = { path = "../common/validator_dir", features = ["insecure_keys"] }
rand = "0.7.2"
eth2_keystore = { path = "../crypto/eth2_keystore" }
lighthouse_version = { path = "../common/lighthouse_version" }

View File

@ -1,6 +1,5 @@
#[macro_use]
extern crate log;
mod change_genesis_time;
mod check_deposit_data;
mod deploy_deposit_contract;
@ -29,6 +28,7 @@ fn main() {
simple_logger::init_with_level(Level::Info).expect("logger should initialize");
let matches = App::new("Lighthouse CLI Tool")
.version(lighthouse_version::VERSION)
.about(
"Performs various testing-related tasks, including defining testnets.",
)

View File

@ -31,7 +31,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"
lighthouse_version = { path = "../common/lighthouse_version" }
[dev-dependencies]
tempfile = "3.1.0"

View File

@ -1,23 +1,15 @@
#[macro_use]
extern crate clap;
use beacon_node::ProductionBeaconNode;
use clap::{App, Arg, ArgMatches};
use env_logger::{Builder, Env};
use environment::EnvironmentBuilder;
use eth2_testnet_config::{Eth2TestnetConfig, DEFAULT_HARDCODED_TESTNET};
use git_version::git_version;
use lighthouse_version::VERSION;
use slog::{crit, info, warn};
use std::path::PathBuf;
use std::process::exit;
use types::EthSpec;
use validator_client::ProductionValidatorClient;
pub const VERSION: &str = git_version!(
args = ["--always", "--dirty=(modified)"],
prefix = concat!(crate_version!(), "-"),
fallback = crate_version!()
);
pub const DEFAULT_DATA_DIR: &str = ".lighthouse";
pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml";