Skip to content

Commit 412fcd0

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 5ad239b commit 412fcd0

File tree

31 files changed

+107
-69
lines changed

31 files changed

+107
-69
lines changed

.circleci/config.yml

+33-38
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@ executors:
1919
resource_class: small
2020

2121
commands:
22-
rust_setup:
23-
description: Set rustc version
24-
steps:
25-
- run:
26-
name: Set rustc version
27-
command: |
28-
rustup default stable
29-
rustup update stable
3022
print_versions:
3123
description: Version Info
3224
steps:
3325
- run:
3426
name: Version Info
35-
command: rustc --version; cargo --version; rustup --version
27+
command: rustup --version
3628
env_setup:
3729
description: Environment Setup
3830
steps:
@@ -44,6 +36,7 @@ commands:
4436
echo 'export LIBRA_DUMP_LOGS=1' >> $BASH_ENV
4537
echo 'export CARGO_INCREMENTAL=0' >> $BASH_ENV
4638
echo 'export CI_TIMEOUT="timeout 40m"' >> $BASH_ENV
39+
echo 'export RUST_NIGHTLY=nightly-2020-03-18' >> $BASH_ENV
4740
install_deps:
4841
steps:
4942
- run:
@@ -52,14 +45,23 @@ commands:
5245
sudo apt-get update
5346
sudo apt-get install -y cmake curl clang llvm
5447
rustup component add clippy rustfmt
48+
rustup toolchain install $RUST_NIGHTLY
49+
- run:
50+
name: Set cargo Environment
51+
command: |
52+
# Use nightly version of cargo to access the new feature resolver
53+
echo 'export CARGO=$(rustup which --toolchain $RUST_NIGHTLY cargo)' >> $BASH_ENV
54+
# Turn on the experimental feature resolver in cargo. See:
55+
# https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features
56+
echo 'export CARGOFLAGS=-Zfeatures=all' >> $BASH_ENV
5557
install_code_coverage_deps:
5658
steps:
5759
- run:
5860
name: Install grcov and lcov
5961
command: |
6062
sudo apt-get update
6163
sudo apt-get install lcov
62-
cargo install --force grcov
64+
$CARGO $CARGOFLAGS install --force grcov
6365
install_docker_linter:
6466
steps:
6567
- run:
@@ -68,11 +70,6 @@ commands:
6870
export HADOLINT=${HOME}/hadolint
6971
export HADOLINT_VER=v1.17.4
7072
curl -sL -o ${HADOLINT} "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VER}/hadolint-$(uname -s)-$(uname -m)" && chmod 700 ${HADOLINT}
71-
install_rust_nightly_toolchain:
72-
steps:
73-
- run:
74-
name: Install nightly toolchain for features not in beta/stable
75-
command: rustup install nightly
7673
find_dockerfile_changes:
7774
steps:
7875
- run:
@@ -106,7 +103,6 @@ commands:
106103
build_setup:
107104
steps:
108105
- checkout
109-
- rust_setup
110106
- print_versions
111107
- env_setup
112108
- install_deps
@@ -127,7 +123,7 @@ jobs:
127123
command: ./scripts/git-checks.sh
128124
- run:
129125
name: Fetch workspace dependencies over network
130-
command: cargo fetch
126+
command: $CARGO $CARGOFLAGS fetch
131127
- save_cargo_package_cache
132128
- persist_to_workspace:
133129
root: /home/circleci/project
@@ -148,20 +144,20 @@ jobs:
148144
- restore_cargo_package_cache
149145
- run:
150146
name: cargo lint
151-
command: cargo x lint
147+
command: $CARGO $CARGOFLAGS x lint
152148
- run:
153149
name: cargo clippy
154-
command: cargo xclippy --workspace --all-targets
150+
command: $CARGO $CARGOFLAGS xclippy --workspace --all-targets
155151
- run:
156152
name: cargo fmt
157-
command: cargo xfmt --check
153+
command: $CARGO $CARGOFLAGS xfmt --check
158154
- run:
159155
name: cargo guppy
160156
command: |
161-
cargo install cargo-guppy \
157+
$CARGO $CARGOFLAGS install cargo-guppy \
162158
--git http://github.com/calibra/cargo-guppy \
163159
--rev 8b2bc45c0cd6323a7a2b8170ddad6d2a5b79047b
164-
[[ -z $(cargo guppy dups --target x86_64-unknown-linux-gnu \
160+
[[ -z $($CARGO $CARGOFLAGS guppy dups --target x86_64-unknown-linux-gnu \
165161
--kind directthirdparty) ]]
166162
build-dev:
167163
executor: build-executor
@@ -172,19 +168,19 @@ jobs:
172168
at: /home/circleci/project
173169
- restore_cargo_package_cache
174170
- run:
175-
command: RUST_BACKTRACE=1 cargo build -j 16
171+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16
176172
- run:
177-
command: RUST_BACKTRACE=1 cargo build -j 16 -p libra-swarm
173+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p libra-swarm
178174
- run:
179-
command: RUST_BACKTRACE=1 cargo build -j 16 -p cluster-test
175+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p cluster-test
180176
- run:
181-
command: RUST_BACKTRACE=1 cargo build -j 16 -p libra-fuzzer
177+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p libra-fuzzer
182178
- run:
183-
command: RUST_BACKTRACE=1 cargo build -j 16 -p language_benchmarks
179+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p language_benchmarks
184180
- run:
185-
command: RUST_BACKTRACE=1 cargo build -j 16 -p cost-synthesis
181+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p cost-synthesis
186182
- run:
187-
command: RUST_BACKTRACE=1 cargo build -j 16 -p test-generation
183+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p test-generation
188184
- build_teardown
189185
build-release:
190186
executor: build-executor
@@ -196,7 +192,7 @@ jobs:
196192
- restore_cargo_package_cache
197193
- run:
198194
name: Build release
199-
command: RUST_BACKTRACE=1 cargo build -j 16 --release
195+
command: RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 --release
200196
- build_teardown
201197
build-e2e-test:
202198
executor: build-executor
@@ -209,7 +205,7 @@ jobs:
209205
- run:
210206
name: Find all e2e tests
211207
command: |
212-
cargo x test --package testsuite -- --list | grep "::" | \
208+
$CARGO $CARGOFLAGS x test --package testsuite -- --list | grep "::" | \
213209
sed 's/: .*$//' > e2e_tests
214210
cat e2e_tests
215211
- persist_to_workspace:
@@ -246,7 +242,7 @@ jobs:
246242
RUST_BACKTRACE=1 $CI_TIMEOUT $libratest $target \
247243
--test-threads 1 --exact --nocapture
248244
else
249-
RUST_BACKTRACE=1 $CI_TIMEOUT cargo x test $target \
245+
RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO $CARGOFLAGS x test $target \
250246
--package testsuite -- --test-threads 1 --exact --nocapture
251247
fi
252248
done
@@ -262,7 +258,7 @@ jobs:
262258
- run:
263259
name: Run all unit tests
264260
command: |
265-
RUST_BACKTRACE=1 $CI_TIMEOUT cargo test \
261+
RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO $CARGOFLAGS test \
266262
--all-features \
267263
--workspace \
268264
--exclude libra-node \
@@ -281,7 +277,7 @@ jobs:
281277
name: Run crypto unit tests
282278
command: |
283279
cd crypto/crypto && \
284-
RUST_BACKTRACE=1 cargo test \
280+
RUST_BACKTRACE=1 $CARGO $CARGOFLAGS test \
285281
--features='std fiat_u64_backend fuzzing' \
286282
--no-default-features
287283
run-flaky-unit-test:
@@ -312,16 +308,16 @@ jobs:
312308
steps:
313309
- build_setup
314310
- run:
315-
name: Install Cargo Audit
311+
name: Install cargo-audit
316312
command: |
317-
cargo install --force cargo-audit
313+
$CARGO $CARGOFLAGS install --force cargo-audit
318314
- run:
319315
# NOTE ignored advisory rules
320316
# RUSTSEC-2018-0015 - term
321317
# RUSTSEC-2019-0031 - spin
322318
name: Audit crates
323319
command: |
324-
cargo audit --deny-warnings \
320+
$CARGO $CARGOFLAGS audit --deny-warnings \
325321
--ignore RUSTSEC-2018-0015 \
326322
--ignore RUSTSEC-2019-0031
327323
- build_teardown
@@ -331,7 +327,6 @@ jobs:
331327
steps:
332328
- build_setup
333329
- install_code_coverage_deps
334-
- install_rust_nightly_toolchain
335330
- run:
336331
name: Setup code coverage output
337332
command: echo "export CODECOV_OUTPUT=codecov" >> $BASH_ENV

Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
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

+6
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

+1
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

+3
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

+4-1
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

+1
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

+2
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

+1-3
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 {
@@ -75,7 +74,7 @@ impl SMRNode {
7574
let (state_sync_client, state_sync) = mpsc::unbounded();
7675
let (commit_cb_sender, commit_cb_receiver) = mpsc::unbounded::<LedgerInfoWithSignatures>();
7776
let shared_mempool = MockSharedMempool::new(None);
78-
let consensus_to_mempool_sender = shared_mempool.consensus_sender.clone();
77+
let consensus_to_mempool_sender = shared_mempool.consensus_sender;
7978

8079
let mut smr = ChainedBftSMR::new(
8180
network_sender,
@@ -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

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use libra_types::{
4949
block_info::BlockInfo,
5050
ledger_info::LedgerInfoWithSignatures,
5151
validator_signer::ValidatorSigner,
52-
validator_verifier::{random_validator_verifier, ValidatorVerifier},
52+
validator_verifier::{random_validator_verifier},
5353
};
5454
use network::peer_manager::{
5555
conn_status_channel, ConnectionRequestSender, PeerManagerRequestSender,
@@ -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

@@ -143,7 +142,7 @@ impl NodeSetup {
143142
playground.add_node(author, consensus_tx, network_reqs_rx, conn_mgr_reqs_rx);
144143

145144
let (self_sender, self_receiver) = channel::new_test(8);
146-
let network = NetworkSender::new(author, network_sender, self_sender, validators.clone());
145+
let network = NetworkSender::new(author, network_sender, self_sender, validators);
147146

148147
let (task, _receiver) = NetworkTask::<TestPayload>::new(network_events, self_receiver);
149148

@@ -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

-14
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

+2-1
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]

0 commit comments

Comments
 (0)