Skip to content

Commit 0016639

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 0016639

File tree

30 files changed

+88
-65
lines changed

30 files changed

+88
-65
lines changed

.circleci/config.yml

Lines changed: 26 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,7 @@ 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) -Z features=all"' >> $BASH_ENV
4340
install_deps:
4441
steps:
4542
- run:
@@ -48,14 +45,15 @@ commands:
4845
sudo apt-get update
4946
sudo apt-get install -y cmake curl clang llvm
5047
rustup component add clippy rustfmt
48+
rustup toolchain install nightly
5149
install_code_coverage_deps:
5250
steps:
5351
- run:
5452
name: Install grcov and lcov
5553
command: |
5654
sudo apt-get update
5755
sudo apt-get install lcov
58-
cargo install --force grcov
56+
$(CARGO) install --force grcov
5957
install_docker_linter:
6058
steps:
6159
- run:
@@ -64,11 +62,6 @@ commands:
6462
export HADOLINT=${HOME}/hadolint
6563
export HADOLINT_VER=v1.17.4
6664
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
7265
find_dockerfile_changes:
7366
steps:
7467
- run:
@@ -82,7 +75,6 @@ commands:
8275
build_setup:
8376
steps:
8477
- checkout
85-
- rust_setup
8678
- print_versions
8779
- env_setup
8880
- install_deps
@@ -104,37 +96,37 @@ jobs:
10496
- run:
10597
name: Linting
10698
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) ]]
99+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO x lint
100+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO xclippy --workspace --all-targets
101+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO xfmt --check
102+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || $CARGO install cargo-guppy --git http://github.com/calibra/cargo-guppy --rev 8b2bc45c0cd6323a7a2b8170ddad6d2a5b79047b
103+
[[ $CIRCLE_NODE_INDEX =~ [1234] ]] || [[ -z $($CARGO guppy dups --target x86_64-unknown-linux-gnu --kind directthirdparty) ]]
112104
- run:
113105
name: Build Release
114106
command: |
115-
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 cargo build -j 16 --release
107+
[[ $CIRCLE_NODE_INDEX =~ [0234] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 --release
116108
- run:
117109
name: Build Dev
118110
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
111+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16
112+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p libra-swarm
113+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p cluster-test
114+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p libra-fuzzer
115+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p language_benchmarks
116+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p cost-synthesis
117+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CARGO build -j 16 -p test-generation
126118
- run:
127119
name: Run All Non Flaky Unit Tests
128120
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
121+
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO test --all-features --workspace --exclude libra-node --exclude libra-crypto --exclude testsuite --exclude consensus
130122
- run:
131123
name: Run Cryptography Unit Tests with the formally verified backend
132124
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 )
125+
[[ $CIRCLE_NODE_INDEX =~ [0134] ]] || ( RUST_BACKTRACE=1 cd crypto/crypto && $CI_TIMEOUT $CARGO test --features='std fiat_u64_backend fuzzing' --no-default-features )
134126
- run:
135127
name: Run All End to End Tests
136128
command: |
137-
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT cargo x test --package testsuite -- --test-threads 1
129+
[[ $CIRCLE_NODE_INDEX =~ [0124] ]] || RUST_BACKTRACE=1 $CI_TIMEOUT $CARGO x test --package testsuite -- --test-threads 1
138130
- run:
139131
name: Run Quarantined Unit Tests 3 (consensus) times
140132
command: |
@@ -155,16 +147,16 @@ jobs:
155147
steps:
156148
- build_setup
157149
- run:
158-
name: Install Cargo Audit
150+
name: Install cargo-audit
159151
command: |
160-
cargo install --force cargo-audit
152+
$CARGO install --force cargo-audit
161153
- run:
162154
# NOTE ignored advisory rules
163155
# RUSTSEC-2018-0015 - term
164156
# RUSTSEC-2019-0031 - spin
165157
name: Audit crates
166158
command: |
167-
cargo audit --deny-warnings \
159+
$CARGO audit --deny-warnings \
168160
--ignore RUSTSEC-2018-0015 \
169161
--ignore RUSTSEC-2019-0031
170162
- build_teardown
@@ -174,7 +166,6 @@ jobs:
174166
steps:
175167
- build_setup
176168
- install_code_coverage_deps
177-
- install_rust_nightly_toolchain
178169
- run:
179170
name: Setup code coverage output
180171
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)