Skip to content

Commit

Permalink
Change to new, experimental cargo feature resolver
Browse files Browse the repository at this point in the history
The [new cargo feature resolver](rust-lang/cargo#7820)
won't unify features across build deps, dev deps, and targets. This solves our
problem of needing to work around feature unification to avoid Clone
implementations on private key material.

This commit puts back our true dependency information into the
Cargo.tomls. Specifically, it adds dev-dependencies that enable features that
aren't enabled on normal dependencies. This will cause the feature unification
to happen when using the old resolver, but the build will be correct under the
new resolver.

In order to maintain correct builds in CI, this commit also changes CI to use
the nightly cargo with `-Z features=all` but still preserving the rustc
toolchain specified in `rustc-toolchain`. Local developer builds will likely
still use the `rustc-toolchain` version of cargo with the old resolver, but
this shouldn't cause any problems for development.
  • Loading branch information
metajack committed Mar 25, 2020
1 parent f084d8a commit 8426101
Show file tree
Hide file tree
Showing 30 changed files with 81 additions and 62 deletions.
57 changes: 22 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ executors:
resource_class: small

commands:
rust_setup:
description: Set rustc version
steps:
- run:
name: Set rustc version
command: |
rustup default stable
rustup update stable
print_versions:
description: Version Info
steps:
Expand All @@ -40,6 +32,7 @@ commands:
echo 'export LIBRA_DUMP_LOGS=1' >> $BASH_ENV
echo 'export CARGO_INCREMENTAL=0' >> $BASH_ENV
echo 'export CI_TIMEOUT="timeout 40m"' >> $BASH_ENV
echo 'export CARGO="$(rustup which --toolchain nightly cargo) -Z features=all"' >> $BASH_ENV
install_deps:
steps:
- run:
Expand All @@ -48,14 +41,15 @@ commands:
sudo apt-get update
sudo apt-get install -y cmake curl clang llvm
rustup component add clippy rustfmt
rustup toolchain install nightly
install_code_coverage_deps:
steps:
- run:
name: Install grcov and lcov
command: |
sudo apt-get update
sudo apt-get install lcov
cargo install --force grcov
$(CARGO) install --force grcov
install_docker_linter:
steps:
- run:
Expand All @@ -64,11 +58,6 @@ commands:
export HADOLINT=${HOME}/hadolint
export HADOLINT_VER=v1.17.4
curl -sL -o ${HADOLINT} "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VER}/hadolint-$(uname -s)-$(uname -m)" && chmod 700 ${HADOLINT}
install_rust_nightly_toolchain:
steps:
- run:
name: Install nightly toolchain for features not in beta/stable
command: rustup install nightly
find_dockerfile_changes:
steps:
- run:
Expand All @@ -82,7 +71,6 @@ commands:
build_setup:
steps:
- checkout
- rust_setup
- print_versions
- env_setup
- install_deps
Expand All @@ -104,37 +92,37 @@ jobs:
- run:
name: Linting
command: |
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo x lint
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo xclippy --workspace --all-targets
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo xfmt --check
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo install cargo-guppy --git https://github.com/calibra/cargo-guppy --rev 8b2bc45c0cd6323a7a2b8170ddad6d2a5b79047b
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || [[ -z $(cargo guppy dups --target x86_64-unknown-linux-gnu --kind directthirdparty) ]]
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO x lint
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO xclippy --workspace --all-targets
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO xfmt --check
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO install cargo-guppy --git https://github.com/calibra/cargo-guppy --rev 8b2bc45c0cd6323a7a2b8170ddad6d2a5b79047b
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || [[ -z $($CARGO guppy dups --target x86_64-unknown-linux-gnu --kind directthirdparty) ]]
- run:
name: Build Release
command: |
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 cargo build -j 16 --release
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 --release
- run:
name: Build Dev
command: |
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p libra-swarm
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p cluster-test
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p libra-fuzzer
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p language_benchmarks
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p cost-synthesis
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p test-generation
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p libra-swarm
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p cluster-test
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p libra-fuzzer
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p language_benchmarks
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p cost-synthesis
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p test-generation
- run:
name: Run All Non Flaky Unit Tests
command: |
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT cargo test --all-features --workspace --exclude libra-node --exclude libra-crypto --exclude testsuite --exclude consensus
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO test --all-features --workspace --exclude libra-node --exclude libra-crypto --exclude testsuite --exclude consensus
- run:
name: Run Cryptography Unit Tests with the formally verified backend
command: |
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || ( RUST_BACKTRACE=1 cd crypto/crypto && $CI_TIMEOUT cargo test --features='std fiat_u64_backend fuzzing' --no-default-features )
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || ( RUST_BACKTRACE=1 cd crypto/crypto && $CI_TIMEOUT $CARGO test --features='std fiat_u64_backend fuzzing' --no-default-features )
- run:
name: Run All End to End Tests
command: |
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT cargo x test --package testsuite -- --test-threads 1
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO x test --package testsuite -- --test-threads 1
- run:
name: Run Quarantined Unit Tests 3 (consensus) times
command: |
Expand All @@ -155,16 +143,16 @@ jobs:
steps:
- build_setup
- run:
name: Install Cargo Audit
name: Install cargo-audit
command: |
cargo install --force cargo-audit
$CARGO install --force cargo-audit
- run:
# NOTE ignored advisory rules
# RUSTSEC-2018-0015 - term
# RUSTSEC-2019-0031 - spin
name: Audit crates
command: |
cargo audit --deny-warnings \
$CARGO audit --deny-warnings \
--ignore RUSTSEC-2018-0015 \
--ignore RUSTSEC-2019-0031
- build_teardown
Expand All @@ -174,7 +162,6 @@ jobs:
steps:
- build_setup
- install_code_coverage_deps
- install_rust_nightly_toolchain
- run:
name: Setup code coverage output
command: echo "export CODECOV_OUTPUT=codecov" >> $BASH_ENV
Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ members = [

# NOTE: These members should never include crates that require fuzzing
# features or test features. These are the crates we want built with no extra
# test-only code included.
# test-only code included. These are essentially the main libra release
# binaries.
default-members = [
"client/cli",
"language/compiler",
Expand Down
6 changes: 6 additions & 0 deletions admission_control/admission-control-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ serde_json = "1.0"

[dev-dependencies]
assert_matches = "1.3.0"
proptest = "0.9.4"
libra-mempool = { path = "../../mempool", version = "0.1.0", features = ["fuzzing"] }
libra-proptest-helpers = { path = "../../common/proptest-helpers" }
libra-prost-ext = { path = "../../common/prost-ext", version = "0.1.0" }
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }
storage-service = { path = "../../storage/storage-service" }
vm-validator = { path = "../../vm-validator", version = "0.1.0" }

[features]
Expand Down
1 change: 1 addition & 0 deletions client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ transaction-builder = { path = "../../language/transaction-builder", version = "

[dev-dependencies]
proptest = "0.9.2"
libra-crypto = { path = "../../crypto/crypto", version = "0.1.0", features = ["fuzzing"] }

[features]
default = []
Expand Down
3 changes: 3 additions & 0 deletions config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ libra-logger = { path = "../common/logger", version = "0.1.0" }
libra-temppath = { path = "../common/temppath", version = "0.1.0" }
libra-types = { path = "../types", version = "0.1.0" }

[dev-dependencies]
libra-crypto = { path = "../crypto/crypto", version = "0.1.0", features = ["fuzzing"] }

[features]
default = []
fuzzing = ["libra-crypto/fuzzing", "libra-types/fuzzing"]
5 changes: 4 additions & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ prometheus = { version = "0.8.0", default-features = false }
proptest = { version = "0.9.4", optional = true }

channel = { path = "../common/channel", version = "0.1.0" }
consensus-types = { path = "consensus-types", version = "0.1.0", default-features = false }
consensus-types = { path = "consensus-types", version = "0.1.0" }
crash-handler = { path = "../common/crash-handler", version = "0.1.0" }
debug-interface = { path = "../common/debug-interface", version = "0.1.0" }
executor = { path = "../execution/executor", version = "0.1.0" }
Expand All @@ -57,6 +57,9 @@ cached = "0.12.0"
proptest = "0.9.4"
tempfile = "3.1.0"

consensus-types = { path = "consensus-types", version = "0.1.0", features = ["fuzzing"] }
libra-config = { path = "../config", version = "0.1.0", features = ["fuzzing"] }
libra-mempool = { path = "../mempool", version = "0.1.0", features = ["fuzzing"] }
vm-genesis = { path = "../language/tools/vm-genesis", version = "0.1.0" }
vm-validator = { path = "../vm-validator", version = "0.1.0" }

Expand Down
1 change: 1 addition & 0 deletions consensus/consensus-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ libra-types = { path = "../../types", version = "0.1.0" }

[dev-dependencies]
proptest = "0.9.4"
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }

[features]
default = []
Expand Down
2 changes: 2 additions & 0 deletions consensus/safety-rules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ workspace-builder = { path = "../../common/workspace-builder", version = "0.1.0"
criterion = "0.3"
rand = { version = "0.6.5", default-features = false }
tempfile = "3.1.0"
consensus-types = { path = "../consensus-types", version = "0.1.0", features = ["fuzzing"] }
libra-config = { path = "../../config", version = "0.1.0", features = ["fuzzing"] }

[[bench]]
name = "safety_rules"
Expand Down
2 changes: 0 additions & 2 deletions consensus/src/chained_bft/chained_bft_smr_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ struct SMRNode {
commit_cb_receiver: mpsc::UnboundedReceiver<LedgerInfoWithSignatures>,
storage: Arc<MockStorage<TestPayload>>,
state_sync: mpsc::UnboundedReceiver<Vec<usize>>,
shared_mempool: MockSharedMempool,
}

impl SMRNode {
Expand Down Expand Up @@ -101,7 +100,6 @@ impl SMRNode {
commit_cb_receiver,
storage,
state_sync,
shared_mempool,
}
}

Expand Down
2 changes: 0 additions & 2 deletions consensus/src/chained_bft/event_processor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ pub struct NodeSetup {
storage: Arc<MockStorage<TestPayload>>,
signer: ValidatorSigner,
proposer_author: Author,
validators: Arc<ValidatorVerifier>,
safety_rules_manager: SafetyRulesManager<TestPayload>,
}

Expand Down Expand Up @@ -199,7 +198,6 @@ impl NodeSetup {
storage,
signer,
proposer_author,
validators,
safety_rules_manager,
}
}
Expand Down
14 changes: 0 additions & 14 deletions consensus/src/chained_bft/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,6 @@ pub fn build_simple_tree() -> (
(vec![genesis_block, a1, a2, a3, b1, b2, c1], block_store)
}

pub fn build_chain() -> Vec<Arc<ExecutedBlock<TestPayload>>> {
let mut inserter = TreeInserter::default();
let block_store = inserter.block_store();
let genesis = block_store.root();
let a1 = inserter.insert_block_with_qc(certificate_for_genesis(), &genesis, 1);
let a2 = inserter.insert_block(&a1, 2, None);
let a3 = inserter.insert_block(&a2, 3, Some(genesis.block_info()));
let a4 = inserter.insert_block(&a3, 4, Some(a1.block_info()));
let a5 = inserter.insert_block(&a4, 5, Some(a2.block_info()));
let a6 = inserter.insert_block(&a5, 6, Some(a3.block_info()));
let a7 = inserter.insert_block(&a6, 7, Some(a4.block_info()));
vec![genesis, a1, a2, a3, a4, a5, a6, a7]
}

pub fn build_empty_tree() -> Arc<BlockStore<TestPayload>> {
let (initial_data, storage) = EmptyStorage::start_for_testing();
Arc::new(BlockStore::new(
Expand Down
3 changes: 2 additions & 1 deletion execution/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ executor-utils = { path = "../executor-utils", version = "0.1.0" }
storage-service = { path = "../../storage/storage-service", version = "0.1.0" }
stdlib = { path = "../../language/stdlib", version = "0.1.0" }
transaction-builder = { path = "../../language/transaction-builder", version = "0.1.0" }

libra-config = { path = "../../config", version = "0.1.0", features = ["fuzzing"] }
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }
vm-genesis = { path = "../../language/tools/vm-genesis", version = "0.1.0" }

[features]
Expand Down
6 changes: 6 additions & 0 deletions json-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ libra-temppath = { path = "../common/temppath", version = "0.1.0", optional = tr
storage-proto = { path = "../storage/storage-proto", version = "0.1.0" }

[dev-dependencies]
proptest = "0.9.2"
reqwest = { version = "0.10.4", features = ["blocking", "json"], default_features = false }
libra-crypto = { path = "../crypto/crypto", version = "0.1.0" }
libra-temppath = { path = "../common/temppath", version = "0.1.0" }
libra-types = { path = "../types", version = "0.1.0", features = ["fuzzing"] }
libradb = { path = "../storage/libradb", version = "0.1.0", features = ["fuzzing"] }
vm-validator = { path = "../vm-validator", version = "0.1.0" }

[features]
Expand Down
1 change: 1 addition & 0 deletions language/libra-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ serde = { version = "1.0.105", default-features = false }

[dev-dependencies]
proptest = "0.9"
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }

[features]
default = []
Expand Down
1 change: 1 addition & 0 deletions language/move-vm/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ move-core-types = { path = "../../move-core/types", version = "0.1.0" }

[dev-dependencies]
proptest = "0.9"
vm = { path = "../../vm", version = "0.1.0", features = ["fuzzing"] }

[features]
default = []
Expand Down
3 changes: 2 additions & 1 deletion language/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ num-variants = { path = "../../common/num-variants", version = "0.1.0" }
[dev-dependencies]
proptest = "0.9"
proptest-derive = "0.1.1"
libra-proptest-helpers = { path = "../../common/proptest-helpers", version = "0.1.0" }
serde_json = "1"
libra-proptest-helpers = { path = "../../common/proptest-helpers", version = "0.1.0" }
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }

[features]
default = []
Expand Down
1 change: 1 addition & 0 deletions mempool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ storage-service = { path = "../storage/storage-service", version = "0.1.0", opti
[dev-dependencies]
parity-multiaddr = { version = "0.7.2", default-features = false }
rand = "0.6.5"
storage-service = { path = "../storage/storage-service", version = "0.1.0", features = ["fuzzing"] }

[build-dependencies]
tonic-build = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion mempool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
extern crate prometheus;

/// This module provides mocks of shared mempool for tests.
#[cfg(feature = "fuzzing")]
#[cfg(any(test, feature = "fuzzing"))]
pub mod mocks;
pub use shared_mempool::{
bootstrap, generate_reconfig_subscription, CommitNotification, CommitResponse,
Expand Down
3 changes: 3 additions & 0 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ proptest = { version = "0.9.4", default-features = true, optional = true }
[dev-dependencies]
criterion = "=0.3.1"
noise = { path = "noise", version = "0.1.0", features = ["testing"] }
proptest = { version = "0.9.4", default-features = false }
libra-proptest-helpers = { path = "../common/proptest-helpers", version = "0.1.0" }
libra-types = { path = "../types", version = "0.1.0", features = ["fuzzing"] }
socket-bench-server = { path = "socket-bench-server", version = "0.1.0" }

[features]
Expand Down
1 change: 1 addition & 0 deletions secure/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ toml = { version = "0.5.3", default-features = false }

[dev-dependencies]
libra-config = { path = "../../config", version = "0.1.0" }
libra-crypto = { path = "../../crypto/crypto", version = "0.1.0", features = ["fuzzing"] }
rand = "0.6.5"

[features]
Expand Down
1 change: 1 addition & 0 deletions state-synchronizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ bytes = "0.5.4"

config-builder = { path = "../config/config-builder", version = "0.1.0" }
libra-crypto = { path = "../crypto/crypto", version = "0.1.0" }
libra-mempool = { path = "../mempool", version = "0.1.0", features = ["fuzzing"] }
parity-multiaddr = "0.7.2"
vm-genesis = { path = "../language/tools/vm-genesis", version = "0.1.0" }
transaction-builder = { path = "../language/transaction-builder", version = "0.1.0" }
Expand Down
1 change: 1 addition & 0 deletions storage/accumulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ libra-types = { path = "../../types", version = "0.1.0" }
[dev-dependencies]
rand = "0.6.5"
proptest = "0.9.1"
libra-crypto = { path = "../../crypto/crypto", version = "0.1.0", features = ["fuzzing"] }

[features]
default = []
Expand Down
Loading

0 comments on commit 8426101

Please sign in to comment.