mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 03:30:38 +00:00
Add a flag to make lighthouse portable across machines (#1423)
## Issue Addressed Closes #1395 ## Proposed Changes * Add a feature to `lighthouse` and `lcli` called `portable` which enables the `portable` feature on our fork of BLST. This feature turns off the `-march=native` C compiler flag that produces binaries highly targeted to the host CPU's instruction set. * Tweak the `Makefile` so that when the `PORTABLE` environment variable is set to `true`, it compiles with this feature. * Temporarily enable `PORTABLE=true` in the Docker build so that the image on Docker Hub is portable. Eventually I think we should enable `PORTABLE=true` _only on Docker Hub_, so that users building locally can take advantage of the tasty compiler magic. This seems to be possible by setting a Docker Hub environment variable: https://docs.docker.com/docker-hub/builds/#environment-variables-for-builds ## Additional Info Tested by compiling on a very new CPU (Intel Core i7-8550U) and copying the binary to a very old CPU (Intel Core i3 530). Before the portability fix, this produced the SIGILL crash described in #1395, and after the fix, it worked smoothly. I'm in the process of testing the Docker build and running some benches to confirm that the performance penalty isn't too severe.
This commit is contained in:
parent
2ede9caaa6
commit
7d8acc20a0
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -563,7 +563,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "blst"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/sigp/blst.git?rev=968c846a2dc46e836e407bbdbac1a38a597ebc46#968c846a2dc46e836e407bbdbac1a38a597ebc46"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"glob",
|
||||
@ -2577,6 +2576,7 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
|
||||
name = "lcli"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"bls",
|
||||
"clap",
|
||||
"clap_utils",
|
||||
"deposit_contract",
|
||||
@ -2980,6 +2980,7 @@ dependencies = [
|
||||
"account_manager",
|
||||
"account_utils",
|
||||
"beacon_node",
|
||||
"bls",
|
||||
"boot_node",
|
||||
"clap",
|
||||
"clap_utils",
|
||||
|
@ -1,8 +1,10 @@
|
||||
FROM rust:1.44.1 AS builder
|
||||
FROM rust:1.45.1 AS builder
|
||||
RUN apt-get update && apt-get install -y cmake
|
||||
COPY . lighthouse
|
||||
ARG PORTABLE
|
||||
ENV PORTABLE $PORTABLE
|
||||
RUN cd lighthouse && make
|
||||
RUN cd lighthouse && cargo install --path lcli --locked
|
||||
RUN cd lighthouse && make install-lcli
|
||||
|
||||
FROM debian:buster-slim
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
|
8
Makefile
8
Makefile
@ -7,11 +7,19 @@ STATE_TRANSITION_VECTORS = "testing/state_transition_vectors"
|
||||
#
|
||||
# Binaries will most likely be found in `./target/release`
|
||||
install:
|
||||
ifeq ($(PORTABLE), true)
|
||||
cargo install --path lighthouse --force --locked --features portable
|
||||
else
|
||||
cargo install --path lighthouse --force --locked
|
||||
endif
|
||||
|
||||
# Builds the lcli binary in release (optimized).
|
||||
install-lcli:
|
||||
ifeq ($(PORTABLE), true)
|
||||
cargo install --path lcli --force --locked --features portable
|
||||
else
|
||||
cargo install --path lcli --force --locked
|
||||
endif
|
||||
|
||||
# Runs the full workspace tests in **release**, without downloading any additional
|
||||
# test vectors.
|
||||
|
@ -29,6 +29,10 @@ $ docker run sigp/lighthouse lighthouse --help
|
||||
> Note: when you're running the Docker Hub image you're relying upon a
|
||||
> pre-built binary instead of building from source.
|
||||
|
||||
> Note: due to the Docker Hub image being compiled to work on arbitrary machines, it isn't as highly
|
||||
> optimized as an image built from source. We're working to improve this, but for now if you want
|
||||
> the absolute best performance, please build the image yourself.
|
||||
|
||||
### Building the Docker Image
|
||||
|
||||
To build the image from source, navigate to
|
||||
|
@ -17,10 +17,11 @@ eth2_hashing = "0.1.0"
|
||||
ethereum-types = "0.9.1"
|
||||
arbitrary = { version = "0.4.4", features = ["derive"], optional = true }
|
||||
zeroize = { version = "1.0.0", features = ["zeroize_derive"] }
|
||||
blst = { git = "https://github.com/sigp/blst.git", rev = "968c846a2dc46e836e407bbdbac1a38a597ebc46" }
|
||||
blst = { git = "https://github.com/sigp/blst.git", rev = "dad1ad0cd22861e5773bee177bee4e1684792605" }
|
||||
|
||||
[features]
|
||||
default = ["supranational"]
|
||||
fake_crypto = []
|
||||
milagro = []
|
||||
supranational = []
|
||||
supranational-portable = ["supranational", "blst/portable"]
|
||||
|
4
hooks/build
Normal file
4
hooks/build
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Build hook to run on Docker Hub to ensure that the image is built with `PORTABLE=true`.
|
||||
docker build --build-arg PORTABLE=true -f $DOCKERFILE_PATH -t $IMAGE_NAME .
|
@ -5,9 +5,11 @@ version = "0.2.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
|
||||
[features]
|
||||
portable = ["bls/supranational-portable"]
|
||||
|
||||
[dependencies]
|
||||
bls = { path = "../crypto/bls" }
|
||||
clap = "2.33.0"
|
||||
hex = "0.4.2"
|
||||
log = "0.4.8"
|
||||
|
@ -5,7 +5,10 @@ authors = ["Sigma Prime <contact@sigmaprime.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
write_ssz_files = ["beacon_node/write_ssz_files"] # Writes debugging .ssz files to /tmp during block processing.
|
||||
# Writes debugging .ssz files to /tmp during block processing.
|
||||
write_ssz_files = ["beacon_node/write_ssz_files"]
|
||||
# Compiles the BLS crypto code so that the binary is portable across machines.
|
||||
portable = ["bls/supranational-portable"]
|
||||
|
||||
[dependencies]
|
||||
beacon_node = { "path" = "../beacon_node" }
|
||||
@ -13,6 +16,7 @@ tokio = "0.2.21"
|
||||
slog = { version = "2.5.2", features = ["max_level_trace"] }
|
||||
sloggers = "1.0.0"
|
||||
types = { "path" = "../consensus/types" }
|
||||
bls = { path = "../crypto/bls" }
|
||||
clap = "2.33.0"
|
||||
env_logger = "0.7.1"
|
||||
logging = { path = "../common/logging" }
|
||||
|
Loading…
Reference in New Issue
Block a user