Add top-level feature to enable Milagro (#1428)

## Proposed Changes

In the continuing war against unportable binaries I figured we should have an option to enable building the Lighthouse binary itself with Milagro. This PR adds a `milagro` feature that can be used with `cargo install --path lighthouse --features milagro --force --locked`. The BLS library in-use will also show up under `lighthouse --version` like this:

```
Lighthouse 0.1.2-7d8acc20a(modified)
BLS Library: milagro
```

Future work: add other cool stuff like the compiler version and CPU target to `--version`.
This commit is contained in:
Michael Sproul 2020-08-01 05:52:55 +00:00
parent d0f1a3e59f
commit 3ea01ac26b
3 changed files with 20 additions and 0 deletions

1
Cargo.lock generated
View File

@ -563,6 +563,7 @@ dependencies = [
[[package]] [[package]]
name = "blst" name = "blst"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/sigp/blst.git?rev=dad1ad0cd22861e5773bee177bee4e1684792605#dad1ad0cd22861e5773bee177bee4e1684792605"
dependencies = [ dependencies = [
"cc", "cc",
"glob", "glob",

View File

@ -9,6 +9,8 @@ edition = "2018"
write_ssz_files = ["beacon_node/write_ssz_files"] write_ssz_files = ["beacon_node/write_ssz_files"]
# Compiles the BLS crypto code so that the binary is portable across machines. # Compiles the BLS crypto code so that the binary is portable across machines.
portable = ["bls/supranational-portable"] portable = ["bls/supranational-portable"]
# Uses the slower Milagro BLS library, which is written in native Rust.
milagro = ["bls/milagro"]
[dependencies] [dependencies]
beacon_node = { "path" = "../beacon_node" } beacon_node = { "path" = "../beacon_node" }

View File

@ -21,6 +21,16 @@ pub const VERSION: &str = git_version!(
pub const DEFAULT_DATA_DIR: &str = ".lighthouse"; pub const DEFAULT_DATA_DIR: &str = ".lighthouse";
pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml"; pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml";
fn bls_library_name() -> &'static str {
if cfg!(feature = "portable") {
"blst-portable"
} else if cfg!(feature = "milagro") {
"milagro"
} else {
"blst"
}
}
fn main() { fn main() {
// Parse the CLI parameters. // Parse the CLI parameters.
let matches = App::new("Lighthouse") let matches = App::new("Lighthouse")
@ -31,6 +41,13 @@ fn main() {
"Ethereum 2.0 client by Sigma Prime. Provides a full-featured beacon \ "Ethereum 2.0 client by Sigma Prime. Provides a full-featured beacon \
node, a validator client and utilities for managing validator accounts.", node, a validator client and utilities for managing validator accounts.",
) )
.long_version(
format!(
"{}\n\
BLS Library: {}",
VERSION, bls_library_name()
).as_str()
)
.arg( .arg(
Arg::with_name("spec") Arg::with_name("spec")
.short("s") .short("s")