Skip to content

Commit 8426101

Browse files
committed
Change to new, experimental cargo feature resolver
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.
1 parent f084d8a commit 8426101

File tree

30 files changed

+81
-62
lines changed

30 files changed

+81
-62
lines changed

.circleci/config.yml

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ executors:
1515
resource_class: small
1616

1717
commands:
18-
rust_setup:
19-
description: Set rustc version
20-
steps:
21-
- run:
22-
name: Set rustc version
23-
command: |
24-
rustup default stable
25-
rustup update stable
2618
print_versions:
2719
description: Version Info
2820
steps:
@@ -40,6 +32,7 @@ commands:
4032
echo 'export LIBRA_DUMP_LOGS=1' >> $BASH_ENV
4133
echo 'export CARGO_INCREMENTAL=0' >> $BASH_ENV
4234
echo 'export CI_TIMEOUT="timeout 40m"' >> $BASH_ENV
35+
echo 'export CARGO="$(rustup which --toolchain nightly cargo) -Z features=all"' >> $BASH_ENV
4336
install_deps:
4437
steps:
4538
- run:
@@ -48,14 +41,15 @@ commands:
4841
sudo apt-get update
4942
sudo apt-get install -y cmake curl clang llvm
5043
rustup component add clippy rustfmt
44+
rustup toolchain install nightly
5145
install_code_coverage_deps:
5246
steps:
5347
- run:
5448
name: Install grcov and lcov
5549
command: |
5650
sudo apt-get update
5751
sudo apt-get install lcov
58-
cargo install --force grcov
52+
$(CARGO) install --force grcov
5953
install_docker_linter:
6054
steps:
6155
- run:
@@ -64,11 +58,6 @@ commands:
6458
export HADOLINT=${HOME}/hadolint
6559
export HADOLINT_VER=v1.17.4
6660
curl -sL -o ${HADOLINT} "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VER}/hadolint-$(uname -s)-$(uname -m)" && chmod 700 ${HADOLINT}
67-
install_rust_nightly_toolchain:
68-
steps:
69-
- run:
70-
name: Install nightly toolchain for features not in beta/stable
71-
command: rustup install nightly
7261
find_dockerfile_changes:
7362
steps:
7463
- run:
@@ -82,7 +71,6 @@ commands:
8271
build_setup:
8372
steps:
8473
- checkout
85-
- rust_setup
8674
- print_versions
8775
- env_setup
8876
- install_deps
@@ -104,37 +92,37 @@ jobs:
10492
- run:
10593
name: Linting
10694
command: |
107-
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo x lint
108-
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo xclippy --workspace --all-targets
109-
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo xfmt --check
110-
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || cargo install cargo-guppy --git http://github.com/calibra/cargo-guppy --rev 8b2bc45c0cd6323a7a2b8170ddad6d2a5b79047b
111-
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || [[ -z $(cargo guppy dups --target x86_64-unknown-linux-gnu --kind directthirdparty) ]]
95+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO x lint
96+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO xclippy --workspace --all-targets
97+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO xfmt --check
98+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO install cargo-guppy --git http://github.com/calibra/cargo-guppy --rev 8b2bc45c0cd6323a7a2b8170ddad6d2a5b79047b
99+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || [[ -z $($CARGO guppy dups --target x86_64-unknown-linux-gnu --kind directthirdparty) ]]
112100
- run:
113101
name: Build Release
114102
command: |
115-
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 cargo build -j 16 --release
103+
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 --release
116104
- run:
117105
name: Build Dev
118106
command: |
119-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16
120-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p libra-swarm
121-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p cluster-test
122-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p libra-fuzzer
123-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p language_benchmarks
124-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p cost-synthesis
125-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 cargo build -j 16 -p test-generation
107+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16
108+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p libra-swarm
109+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p cluster-test
110+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p libra-fuzzer
111+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p language_benchmarks
112+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p cost-synthesis
113+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p test-generation
126114
- run:
127115
name: Run All Non Flaky Unit Tests
128116
command: |
129-
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT cargo test --all-features --workspace --exclude libra-node --exclude libra-crypto --exclude testsuite --exclude consensus
117+
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO test --all-features --workspace --exclude libra-node --exclude libra-crypto --exclude testsuite --exclude consensus
130118
- run:
131119
name: Run Cryptography Unit Tests with the formally verified backend
132120
command: |
133-
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || ( RUST_BACKTRACE=1 cd crypto/crypto && $CI_TIMEOUT cargo test --features='std fiat_u64_backend fuzzing' --no-default-features )
121+
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || ( RUST_BACKTRACE=1 cd crypto/crypto && $CI_TIMEOUT $CARGO test --features='std fiat_u64_backend fuzzing' --no-default-features )
134122
- run:
135123
name: Run All End to End Tests
136124
command: |
137-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT cargo x test --package testsuite -- --test-threads 1
125+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO x test --package testsuite -- --test-threads 1
138126
- run:
139127
name: Run Quarantined Unit Tests 3 (consensus) times
140128
command: |
@@ -155,16 +143,16 @@ jobs:
155143
steps:
156144
- build_setup
157145
- run:
158-
name: Install Cargo Audit
146+
name: Install cargo-audit
159147
command: |
160-
cargo install --force cargo-audit
148+
$CARGO install --force cargo-audit
161149
- run:
162150
# NOTE ignored advisory rules
163151
# RUSTSEC-2018-0015 - term
164152
# RUSTSEC-2019-0031 - spin
165153
name: Audit crates
166154
command: |
167-
cargo audit --deny-warnings \
155+
$CARGO audit --deny-warnings \
168156
--ignore RUSTSEC-2018-0015 \
169157
--ignore RUSTSEC-2019-0031
170158
- build_teardown
@@ -174,7 +162,6 @@ jobs:
174162
steps:
175163
- build_setup
176164
- install_code_coverage_deps
177-
- install_rust_nightly_toolchain
178165
- run:
179166
name: Setup code coverage output
180167
command: echo "export CODECOV_OUTPUT=codecov" >> $BASH_ENV

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ members = [
108108

109109
# NOTE: These members should never include crates that require fuzzing
110110
# features or test features. These are the crates we want built with no extra
111-
# test-only code included.
111+
# test-only code included. These are essentially the main libra release
112+
# binaries.
112113
default-members = [
113114
"client/cli",
114115
"language/compiler",

admission_control/admission-control-service/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ serde_json = "1.0"
3232

3333
[dev-dependencies]
3434
assert_matches = "1.3.0"
35+
proptest = "0.9.4"
36+
libra-mempool = { path = "../../mempool", version = "0.1.0", features = ["fuzzing"] }
37+
libra-proptest-helpers = { path = "../../common/proptest-helpers" }
38+
libra-prost-ext = { path = "../../common/prost-ext", version = "0.1.0" }
39+
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }
40+
storage-service = { path = "../../storage/storage-service" }
3541
vm-validator = { path = "../../vm-validator", version = "0.1.0" }
3642

3743
[features]

client/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ transaction-builder = { path = "../../language/transaction-builder", version = "
4242

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

4647
[features]
4748
default = []

config/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ libra-logger = { path = "../common/logger", version = "0.1.0" }
2929
libra-temppath = { path = "../common/temppath", version = "0.1.0" }
3030
libra-types = { path = "../types", version = "0.1.0" }
3131

32+
[dev-dependencies]
33+
libra-crypto = { path = "../crypto/crypto", version = "0.1.0", features = ["fuzzing"] }
34+
3235
[features]
3336
default = []
3437
fuzzing = ["libra-crypto/fuzzing", "libra-types/fuzzing"]

consensus/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ prometheus = { version = "0.8.0", default-features = false }
3131
proptest = { version = "0.9.4", optional = true }
3232

3333
channel = { path = "../common/channel", version = "0.1.0" }
34-
consensus-types = { path = "consensus-types", version = "0.1.0", default-features = false }
34+
consensus-types = { path = "consensus-types", version = "0.1.0" }
3535
crash-handler = { path = "../common/crash-handler", version = "0.1.0" }
3636
debug-interface = { path = "../common/debug-interface", version = "0.1.0" }
3737
executor = { path = "../execution/executor", version = "0.1.0" }
@@ -57,6 +57,9 @@ cached = "0.12.0"
5757
proptest = "0.9.4"
5858
tempfile = "3.1.0"
5959

60+
consensus-types = { path = "consensus-types", version = "0.1.0", features = ["fuzzing"] }
61+
libra-config = { path = "../config", version = "0.1.0", features = ["fuzzing"] }
62+
libra-mempool = { path = "../mempool", version = "0.1.0", features = ["fuzzing"] }
6063
vm-genesis = { path = "../language/tools/vm-genesis", version = "0.1.0" }
6164
vm-validator = { path = "../vm-validator", version = "0.1.0" }
6265

consensus/consensus-types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ libra-types = { path = "../../types", version = "0.1.0" }
2121

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

2526
[features]
2627
default = []

consensus/safety-rules/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ workspace-builder = { path = "../../common/workspace-builder", version = "0.1.0"
2828
criterion = "0.3"
2929
rand = { version = "0.6.5", default-features = false }
3030
tempfile = "3.1.0"
31+
consensus-types = { path = "../consensus-types", version = "0.1.0", features = ["fuzzing"] }
32+
libra-config = { path = "../../config", version = "0.1.0", features = ["fuzzing"] }
3133

3234
[[bench]]
3335
name = "safety_rules"

consensus/src/chained_bft/chained_bft_smr_test.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct SMRNode {
4444
commit_cb_receiver: mpsc::UnboundedReceiver<LedgerInfoWithSignatures>,
4545
storage: Arc<MockStorage<TestPayload>>,
4646
state_sync: mpsc::UnboundedReceiver<Vec<usize>>,
47-
shared_mempool: MockSharedMempool,
4847
}
4948

5049
impl SMRNode {
@@ -101,7 +100,6 @@ impl SMRNode {
101100
commit_cb_receiver,
102101
storage,
103102
state_sync,
104-
shared_mempool,
105103
}
106104
}
107105

consensus/src/chained_bft/event_processor_test.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ pub struct NodeSetup {
6565
storage: Arc<MockStorage<TestPayload>>,
6666
signer: ValidatorSigner,
6767
proposer_author: Author,
68-
validators: Arc<ValidatorVerifier>,
6968
safety_rules_manager: SafetyRulesManager<TestPayload>,
7069
}
7170

@@ -199,7 +198,6 @@ impl NodeSetup {
199198
storage,
200199
signer,
201200
proposer_author,
202-
validators,
203201
safety_rules_manager,
204202
}
205203
}

consensus/src/chained_bft/test_utils/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ pub fn build_simple_tree() -> (
6161
(vec![genesis_block, a1, a2, a3, b1, b2, c1], block_store)
6262
}
6363

64-
pub fn build_chain() -> Vec<Arc<ExecutedBlock<TestPayload>>> {
65-
let mut inserter = TreeInserter::default();
66-
let block_store = inserter.block_store();
67-
let genesis = block_store.root();
68-
let a1 = inserter.insert_block_with_qc(certificate_for_genesis(), &genesis, 1);
69-
let a2 = inserter.insert_block(&a1, 2, None);
70-
let a3 = inserter.insert_block(&a2, 3, Some(genesis.block_info()));
71-
let a4 = inserter.insert_block(&a3, 4, Some(a1.block_info()));
72-
let a5 = inserter.insert_block(&a4, 5, Some(a2.block_info()));
73-
let a6 = inserter.insert_block(&a5, 6, Some(a3.block_info()));
74-
let a7 = inserter.insert_block(&a6, 7, Some(a4.block_info()));
75-
vec![genesis, a1, a2, a3, a4, a5, a6, a7]
76-
}
77-
7864
pub fn build_empty_tree() -> Arc<BlockStore<TestPayload>> {
7965
let (initial_data, storage) = EmptyStorage::start_for_testing();
8066
Arc::new(BlockStore::new(

execution/executor/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ executor-utils = { path = "../executor-utils", version = "0.1.0" }
4242
storage-service = { path = "../../storage/storage-service", version = "0.1.0" }
4343
stdlib = { path = "../../language/stdlib", version = "0.1.0" }
4444
transaction-builder = { path = "../../language/transaction-builder", version = "0.1.0" }
45-
45+
libra-config = { path = "../../config", version = "0.1.0", features = ["fuzzing"] }
46+
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }
4647
vm-genesis = { path = "../../language/tools/vm-genesis", version = "0.1.0" }
4748

4849
[features]

json-rpc/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ libra-temppath = { path = "../common/temppath", version = "0.1.0", optional = tr
3737
storage-proto = { path = "../storage/storage-proto", version = "0.1.0" }
3838

3939
[dev-dependencies]
40+
proptest = "0.9.2"
41+
reqwest = { version = "0.10.4", features = ["blocking", "json"], default_features = false }
42+
libra-crypto = { path = "../crypto/crypto", version = "0.1.0" }
43+
libra-temppath = { path = "../common/temppath", version = "0.1.0" }
44+
libra-types = { path = "../types", version = "0.1.0", features = ["fuzzing"] }
45+
libradb = { path = "../storage/libradb", version = "0.1.0", features = ["fuzzing"] }
4046
vm-validator = { path = "../vm-validator", version = "0.1.0" }
4147

4248
[features]

language/libra-vm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ serde = { version = "1.0.105", default-features = false }
3636

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

4041
[features]
4142
default = []

language/move-vm/types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ move-core-types = { path = "../../move-core/types", version = "0.1.0" }
2424

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

2829
[features]
2930
default = []

language/vm/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ num-variants = { path = "../../common/num-variants", version = "0.1.0" }
3030
[dev-dependencies]
3131
proptest = "0.9"
3232
proptest-derive = "0.1.1"
33-
libra-proptest-helpers = { path = "../../common/proptest-helpers", version = "0.1.0" }
3433
serde_json = "1"
34+
libra-proptest-helpers = { path = "../../common/proptest-helpers", version = "0.1.0" }
35+
libra-types = { path = "../../types", version = "0.1.0", features = ["fuzzing"] }
3536

3637
[features]
3738
default = []

mempool/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ storage-service = { path = "../storage/storage-service", version = "0.1.0", opti
4444
[dev-dependencies]
4545
parity-multiaddr = { version = "0.7.2", default-features = false }
4646
rand = "0.6.5"
47+
storage-service = { path = "../storage/storage-service", version = "0.1.0", features = ["fuzzing"] }
4748

4849
[build-dependencies]
4950
tonic-build = "0.1"

mempool/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
extern crate prometheus;
6161

6262
/// This module provides mocks of shared mempool for tests.
63-
#[cfg(feature = "fuzzing")]
63+
#[cfg(any(test, feature = "fuzzing"))]
6464
pub mod mocks;
6565
pub use shared_mempool::{
6666
bootstrap, generate_reconfig_subscription, CommitNotification, CommitResponse,

network/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ proptest = { version = "0.9.4", default-features = true, optional = true }
4343
[dev-dependencies]
4444
criterion = "=0.3.1"
4545
noise = { path = "noise", version = "0.1.0", features = ["testing"] }
46+
proptest = { version = "0.9.4", default-features = false }
47+
libra-proptest-helpers = { path = "../common/proptest-helpers", version = "0.1.0" }
48+
libra-types = { path = "../types", version = "0.1.0", features = ["fuzzing"] }
4649
socket-bench-server = { path = "socket-bench-server", version = "0.1.0" }
4750

4851
[features]

secure/storage/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ toml = { version = "0.5.3", default-features = false }
2424

2525
[dev-dependencies]
2626
libra-config = { path = "../../config", version = "0.1.0" }
27+
libra-crypto = { path = "../../crypto/crypto", version = "0.1.0", features = ["fuzzing"] }
2728
rand = "0.6.5"
2829

2930
[features]

state-synchronizer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ bytes = "0.5.4"
3838

3939
config-builder = { path = "../config/config-builder", version = "0.1.0" }
4040
libra-crypto = { path = "../crypto/crypto", version = "0.1.0" }
41+
libra-mempool = { path = "../mempool", version = "0.1.0", features = ["fuzzing"] }
4142
parity-multiaddr = "0.7.2"
4243
vm-genesis = { path = "../language/tools/vm-genesis", version = "0.1.0" }
4344
transaction-builder = { path = "../language/transaction-builder", version = "0.1.0" }

storage/accumulator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ libra-types = { path = "../../types", version = "0.1.0" }
1818
[dev-dependencies]
1919
rand = "0.6.5"
2020
proptest = "0.9.1"
21+
libra-crypto = { path = "../../crypto/crypto", version = "0.1.0", features = ["fuzzing"] }
2122

2223
[features]
2324
default = []

0 commit comments

Comments
 (0)