mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-29 20:27:14 +00:00
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:
@@ -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" }
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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(),
|
||||
);
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>(
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
@@ -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()
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user