Skip to content

Commit b119acc

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 b119acc

File tree

31 files changed

+101
-66
lines changed

31 files changed

+101
-66
lines changed

.circleci/config.yml

Lines changed: 27 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:
@@ -32,6 +24,10 @@ commands:
3224
env_setup:
3325
description: Environment Setup
3426
steps:
27+
- run:
28+
name: Set RUST_NIGHTLY
29+
command: |
30+
echo 'export RUST_NIGHTLY=nightly-2020-03-18' >> $BASH_ENV
3531
- run:
3632
name: Setup Env
3733
command: |
@@ -40,6 +36,8 @@ commands:
4036
echo 'export LIBRA_DUMP_LOGS=1' >> $BASH_ENV
4137
echo 'export CARGO_INCREMENTAL=0' >> $BASH_ENV
4238
echo 'export CI_TIMEOUT="timeout 40m"' >> $BASH_ENV
39+
echo 'export CARGO=$(rustup which --toolchain $RUST_NIGHTLY cargo)' >> $BASH_ENV
40+
echo 'export CARGOFLAGS=-Zfeatures=all' >> $BASH_ENV
4341
install_deps:
4442
steps:
4543
- run:
@@ -48,14 +46,15 @@ commands:
4846
sudo apt-get update
4947
sudo apt-get install -y cmake curl clang llvm
5048
rustup component add clippy rustfmt
49+
rustup toolchain install nightly
5150
install_code_coverage_deps:
5251
steps:
5352
- run:
5453
name: Install grcov and lcov
5554
command: |
5655
sudo apt-get update
5756
sudo apt-get install lcov
58-
cargo install --force grcov
57+
$(CARGO) install --force grcov
5958
install_docker_linter:
6059
steps:
6160
- run:
@@ -64,11 +63,6 @@ commands:
6463
export HADOLINT=${HOME}/hadolint
6564
export HADOLINT_VER=v1.17.4
6665
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
7266
find_dockerfile_changes:
7367
steps:
7468
- run:
@@ -82,7 +76,6 @@ commands:
8276
build_setup:
8377
steps:
8478
- checkout
85-
- rust_setup
8679
- print_versions
8780
- env_setup
8881
- install_deps
@@ -104,37 +97,37 @@ jobs:
10497
- run:
10598
name: Linting
10699
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) ]]
100+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO $CARGOFLAGS x lint
101+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO $CARGOFLAGS xclippy --workspace --all-targets
102+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO $CARGOFLAGS xfmt --check
103+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO $CARGOFLAGS install cargo-guppy --git http://github.com/calibra/cargo-guppy --rev 8b2bc45c0cd6323a7a2b8170ddad6d2a5b79047b
104+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || [[ -z $($CARGO $CARGOFLAGS guppy dups --target x86_64-unknown-linux-gnu --kind directthirdparty) ]]
112105
- run:
113106
name: Build Release
114107
command: |
115-
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 cargo build -j 16 --release
108+
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 --release
116109
- run:
117110
name: Build Dev
118111
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
112+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16
113+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p libra-swarm
114+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p cluster-test
115+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p libra-fuzzer
116+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p language_benchmarks
117+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p cost-synthesis
118+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO $CARGOFLAGS build -j 16 -p test-generation
126119
- run:
127120
name: Run All Non Flaky Unit Tests
128121
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
122+
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO $CARGOFLAGS test --all-features --workspace --exclude libra-node --exclude libra-crypto --exclude testsuite --exclude consensus
130123
- run:
131124
name: Run Cryptography Unit Tests with the formally verified backend
132125
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 )
126+
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || ( RUST_BACKTRACE=1 cd crypto/crypto && $CI_TIMEOUT $CARGO $CARGOFLAGS test --features='std fiat_u64_backend fuzzing' --no-default-features )
134127
- run:
135128
name: Run All End to End Tests
136129
command: |
137-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT cargo x test --package testsuite -- --test-threads 1
130+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO $CARGOFLAGSx test --package testsuite -- --test-threads 1
138131
- run:
139132
name: Run Quarantined Unit Tests 3 (consensus) times
140133
command: |
@@ -155,16 +148,16 @@ jobs:
155148
steps:
156149
- build_setup
157150
- run:
158-
name: Install Cargo Audit
151+
name: Install cargo-audit
159152
command: |
160-
cargo install --force cargo-audit
153+
$CARGO $CARGOFLAGS install --force cargo-audit
161154
- run:
162155
# NOTE ignored advisory rules
163156
# RUSTSEC-2018-0015 - term
164157
# RUSTSEC-2019-0031 - spin
165158
name: Audit crates
166159
command: |
167-
cargo audit --deny-warnings \
160+
$CARGO $CARGOFLAGS audit --deny-warnings \
168161
--ignore RUSTSEC-2018-0015 \
169162
--ignore RUSTSEC-2019-0031
170163
- build_teardown
@@ -174,7 +167,6 @@ jobs:
174167
steps:
175168
- build_setup
176169
- install_code_coverage_deps
177-
- install_rust_nightly_toolchain
178170
- run:
179171
name: Setup code coverage output
180172
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: 1 addition & 3 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 {
@@ -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

0 commit comments

Comments
 (0)