diff --git a/Cargo.lock b/Cargo.lock index cac297b14..87bd7e0d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "account_manager" version = "0.3.5" @@ -3756,6 +3758,7 @@ dependencies = [ "slog-async", "slog-term", "sloggers", + "target_check", "task_executor", "tempfile", "tokio 1.5.0", @@ -6331,6 +6334,13 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "target_check" +version = "0.1.0" +dependencies = [ + "static_assertions", +] + [[package]] name = "target_info" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 89f4b0f2f..4b9a5b1b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ members = [ "common/sensitive_url", "common/slot_clock", "common/task_executor", + "common/target_check", "common/test_random_derive", "common/validator_dir", "common/warp_utils", diff --git a/common/target_check/Cargo.toml b/common/target_check/Cargo.toml new file mode 100644 index 000000000..8981483ee --- /dev/null +++ b/common/target_check/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "target_check" +version = "0.1.0" +authors = ["Michael Sproul "] +edition = "2018" + +[dependencies] +static_assertions = "1.1.0" diff --git a/common/target_check/src/lib.rs b/common/target_check/src/lib.rs new file mode 100644 index 000000000..09f8c2bb6 --- /dev/null +++ b/common/target_check/src/lib.rs @@ -0,0 +1,11 @@ +//! This crate checks properties of the target architecture to ensure that it's compatible with +//! Lighthouse. +use static_assertions::assert_cfg; + +// In many places we assume `usize` and `u64` have the same in-memory representation. +// We also use memory-mapped files extensively which are only really viable with 64-bit addressing. +// It's unlikely we will want to support 128-bit architectures any time soon. +assert_cfg!( + target_pointer_width = "64", + "Lighthouse requires a 64-bit CPU and operating system", +); diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 7746d5895..ff6c69547 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -47,6 +47,7 @@ lazy_static = "1.4.0" serde_json = "1.0.59" task_executor = { path = "../common/task_executor" } malloc_utils = { path = "../common/malloc_utils" } +target_check = { path = "../common/target_check" } [dev-dependencies] tempfile = "3.1.0" @@ -57,3 +58,8 @@ eth2_libp2p = { path = "../beacon_node/eth2_libp2p" } [[test]] name = "lighthouse_tests" path = "tests/main.rs" + +# Prevent cargo-udeps from flagging the dummy package `target_check`, which exists only +# to assert properties of the compilation target. +[package.metadata.cargo-udeps.ignore] +normal = ["target_check"]