2019-10-02 01:04:56 +00:00
|
|
|
.PHONY: tests
|
2019-09-07 18:19:54 +00:00
|
|
|
|
2020-05-18 11:24:23 +00:00
|
|
|
EF_TESTS = "testing/ef_tests"
|
|
|
|
STATE_TRANSITION_VECTORS = "testing/state_transition_vectors"
|
2020-08-14 22:24:27 +00:00
|
|
|
GIT_TAG := $(shell git describe --tags --candidates 1)
|
|
|
|
BIN_DIR = "bin"
|
|
|
|
|
|
|
|
X86_64_TAG = "x86_64-unknown-linux-gnu"
|
|
|
|
BUILD_PATH_X86_64 = "target/$(X86_64_TAG)/release"
|
|
|
|
AARCH64_TAG = "aarch64-unknown-linux-gnu"
|
|
|
|
BUILD_PATH_AARCH64 = "target/$(AARCH64_TAG)/release"
|
2019-09-07 18:19:54 +00:00
|
|
|
|
2020-04-19 02:20:43 +00:00
|
|
|
# Builds the Lighthouse binary in release (optimized).
|
2019-10-02 01:04:56 +00:00
|
|
|
#
|
|
|
|
# Binaries will most likely be found in `./target/release`
|
2019-11-25 04:48:24 +00:00
|
|
|
install:
|
2020-07-31 05:00:39 +00:00
|
|
|
ifeq ($(PORTABLE), true)
|
|
|
|
cargo install --path lighthouse --force --locked --features portable
|
|
|
|
else
|
2020-03-05 01:50:24 +00:00
|
|
|
cargo install --path lighthouse --force --locked
|
2020-07-31 05:00:39 +00:00
|
|
|
endif
|
2020-04-19 02:20:43 +00:00
|
|
|
|
|
|
|
# Builds the lcli binary in release (optimized).
|
|
|
|
install-lcli:
|
2020-07-31 05:00:39 +00:00
|
|
|
ifeq ($(PORTABLE), true)
|
|
|
|
cargo install --path lcli --force --locked --features portable
|
|
|
|
else
|
2020-04-15 07:46:03 +00:00
|
|
|
cargo install --path lcli --force --locked
|
2020-07-31 05:00:39 +00:00
|
|
|
endif
|
2019-09-07 18:19:54 +00:00
|
|
|
|
2020-08-11 05:16:30 +00:00
|
|
|
# The following commands use `cross` to build a cross-compile.
|
|
|
|
#
|
|
|
|
# These commands require that:
|
|
|
|
#
|
|
|
|
# - `cross` is installed (`cargo install cross`).
|
|
|
|
# - Docker is running.
|
|
|
|
# - The current user is in the `docker` group.
|
|
|
|
#
|
|
|
|
# The resulting binaries will be created in the `target/` directory.
|
|
|
|
#
|
|
|
|
# The *-portable options compile the blst library *without* the use of some
|
|
|
|
# optimized CPU functions that may not be available on some systems. This
|
|
|
|
# results in a more portable binary with ~20% slower BLS verification.
|
|
|
|
build-x86_64:
|
2020-10-28 22:19:38 +00:00
|
|
|
cross build --release --manifest-path lighthouse/Cargo.toml --target x86_64-unknown-linux-gnu --features modern
|
2020-08-11 05:16:30 +00:00
|
|
|
build-x86_64-portable:
|
|
|
|
cross build --release --manifest-path lighthouse/Cargo.toml --target x86_64-unknown-linux-gnu --features portable
|
|
|
|
build-aarch64:
|
|
|
|
cross build --release --manifest-path lighthouse/Cargo.toml --target aarch64-unknown-linux-gnu
|
|
|
|
build-aarch64-portable:
|
|
|
|
cross build --release --manifest-path lighthouse/Cargo.toml --target aarch64-unknown-linux-gnu --features portable
|
|
|
|
|
2020-08-14 22:24:27 +00:00
|
|
|
# Create a `.tar.gz` containing a binary for a specific target.
|
|
|
|
define tarball_release_binary
|
|
|
|
cp $(1)/lighthouse $(BIN_DIR)/lighthouse
|
|
|
|
cd $(BIN_DIR) && \
|
|
|
|
tar -czf lighthouse-$(GIT_TAG)-$(2)$(3).tar.gz lighthouse && \
|
|
|
|
rm lighthouse
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Create a series of `.tar.gz` files in the BIN_DIR directory, each containing
|
|
|
|
# a `lighthouse` binary for a different target.
|
|
|
|
#
|
|
|
|
# The current git tag will be used as the version in the output file names. You
|
|
|
|
# will likely need to use `git tag` and create a semver tag (e.g., `v0.2.3`).
|
|
|
|
build-release-tarballs:
|
|
|
|
[ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR)
|
|
|
|
$(MAKE) build-x86_64
|
|
|
|
$(call tarball_release_binary,$(BUILD_PATH_X86_64),$(X86_64_TAG),"")
|
|
|
|
$(MAKE) build-x86_64-portable
|
|
|
|
$(call tarball_release_binary,$(BUILD_PATH_X86_64),$(X86_64_TAG),"-portable")
|
|
|
|
$(MAKE) build-aarch64
|
|
|
|
$(call tarball_release_binary,$(BUILD_PATH_AARCH64),$(AARCH64_TAG),"")
|
|
|
|
$(MAKE) build-aarch64-portable
|
|
|
|
$(call tarball_release_binary,$(BUILD_PATH_AARCH64),$(AARCH64_TAG),"-portable")
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
# Runs the full workspace tests in **release**, without downloading any additional
|
|
|
|
# test vectors.
|
|
|
|
test-release:
|
|
|
|
cargo test --all --release --exclude ef_tests
|
|
|
|
|
|
|
|
# Runs the full workspace tests in **debug**, without downloading any additional test
|
2019-10-02 01:04:56 +00:00
|
|
|
# vectors.
|
2019-11-25 04:48:24 +00:00
|
|
|
test-debug:
|
|
|
|
cargo test --all --exclude ef_tests
|
2019-10-29 16:58:39 +00:00
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
# Runs cargo-fmt (linter).
|
|
|
|
cargo-fmt:
|
|
|
|
cargo fmt --all -- --check
|
2019-10-29 16:58:39 +00:00
|
|
|
|
2020-04-06 10:16:08 +00:00
|
|
|
# Typechecks benchmark code
|
|
|
|
check-benches:
|
|
|
|
cargo check --all --benches
|
|
|
|
|
Remove saturating arith from state_processing (#1644)
## Issue Addressed
Resolves #1100
## Proposed Changes
* Implement the `SafeArith` trait for `Slot` and `Epoch`, so that methods like `safe_add` become available.
* Tweak the `SafeArith` trait to allow a different `Rhs` type (analagous to `std::ops::Add`, etc).
* Add a `legacy-arith` feature to `types` and `state_processing` that conditionally enables implementations of
the `std` ops with saturating semantics.
* Check compilation of `types` and `state_processing` _without_ `legacy-arith` on CI,
thus guaranteeing that they only use the `SafeArith` primitives :tada:
## Additional Info
The `legacy-arith` feature gets turned on by all higher-level crates that depend on `state_processing` or `types`, thus allowing the beacon chain, networking, and other components to continue to rely on the availability of ops like `+`, `-`, `*`, etc.
**This is a consensus-breaking change**, but brings us in line with the spec, and our incompatibilities shouldn't have been reachable with any valid configuration of Eth2 parameters.
2020-09-25 05:18:21 +00:00
|
|
|
# Typechecks consensus code *without* allowing deprecated legacy arithmetic
|
|
|
|
check-consensus:
|
|
|
|
cargo check --manifest-path=consensus/state_processing/Cargo.toml --no-default-features
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
# Runs only the ef-test vectors.
|
|
|
|
run-ef-tests:
|
2019-10-29 16:58:39 +00:00
|
|
|
cargo test --release --manifest-path=$(EF_TESTS)/Cargo.toml --features "ef_tests"
|
2019-11-25 04:48:24 +00:00
|
|
|
cargo test --release --manifest-path=$(EF_TESTS)/Cargo.toml --features "ef_tests,fake_crypto"
|
2020-07-25 02:03:18 +00:00
|
|
|
cargo test --release --manifest-path=$(EF_TESTS)/Cargo.toml --features "ef_tests,milagro"
|
2019-10-29 16:58:39 +00:00
|
|
|
|
2020-05-08 23:37:21 +00:00
|
|
|
# Runs only the tests/state_transition_vectors tests.
|
|
|
|
run-state-transition-tests:
|
|
|
|
make -C $(STATE_TRANSITION_VECTORS) test
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
# Downloads and runs the EF test vectors.
|
2019-10-30 09:42:32 +00:00
|
|
|
test-ef: make-ef-tests run-ef-tests
|
2019-09-07 18:19:54 +00:00
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
# Runs the full workspace tests in release, without downloading any additional
|
|
|
|
# test vectors.
|
|
|
|
test: test-release
|
2019-10-29 16:58:39 +00:00
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
# Runs the entire test suite, downloading test vectors if required.
|
|
|
|
test-full: cargo-fmt test-release test-debug test-ef
|
2019-09-07 18:19:54 +00:00
|
|
|
|
2020-04-20 02:35:11 +00:00
|
|
|
# Lints the code for bad style and potentially unsafe arithmetic using Clippy.
|
2020-06-25 14:04:08 +00:00
|
|
|
# Clippy lints are opt-in per-crate for now. By default, everything is allowed except for performance and correctness lints.
|
2020-04-20 02:35:11 +00:00
|
|
|
lint:
|
2021-01-28 23:31:06 +00:00
|
|
|
cargo clippy --all --tests -- -D warnings
|
2020-04-20 02:35:11 +00:00
|
|
|
|
2019-10-02 01:04:56 +00:00
|
|
|
# Runs the makefile in the `ef_tests` repo.
|
|
|
|
#
|
|
|
|
# May download and extract an archive of test vectors from the ethereum
|
|
|
|
# repositories. At the time of writing, this was several hundred MB of
|
|
|
|
# downloads which extracts into several GB of test vectors.
|
|
|
|
make-ef-tests:
|
|
|
|
make -C $(EF_TESTS)
|
2019-09-07 18:19:54 +00:00
|
|
|
|
2020-05-05 23:12:28 +00:00
|
|
|
# Verifies that state_processing feature arbitrary-fuzz will compile
|
|
|
|
arbitrary-fuzz:
|
2020-05-18 11:24:23 +00:00
|
|
|
cargo check --manifest-path=consensus/state_processing/Cargo.toml --features arbitrary-fuzz
|
2020-05-05 23:12:28 +00:00
|
|
|
|
2020-05-26 07:04:39 +00:00
|
|
|
# Runs cargo audit (Audit Cargo.lock files for crates with security vulnerabilities reported to the RustSec Advisory Database)
|
|
|
|
audit:
|
|
|
|
cargo install --force cargo-audit
|
2021-03-02 05:59:49 +00:00
|
|
|
cargo audit --ignore RUSTSEC-2020-0146
|
2020-05-26 07:04:39 +00:00
|
|
|
|
2020-06-14 00:59:50 +00:00
|
|
|
# Runs `cargo udeps` to check for unused dependencies
|
|
|
|
udeps:
|
|
|
|
cargo +nightly udeps --tests --all-targets --release
|
|
|
|
|
2019-10-02 01:04:56 +00:00
|
|
|
# Performs a `cargo` clean and cleans the `ef_tests` directory.
|
|
|
|
clean:
|
|
|
|
cargo clean
|
|
|
|
make -C $(EF_TESTS) clean
|
2020-05-08 23:37:21 +00:00
|
|
|
make -C $(STATE_TRANSITION_VECTORS) clean
|