Skip to content

Commit

Permalink
fix(build): Fix new nightly clippy lints and cargo feature resolution (
Browse files Browse the repository at this point in the history
…#6814)

* Implement minor and patch database format versions

* Log and update database format versions when opening database

* Refactor the current list of column families into a constant

* Open all available column families, including from future Zebra versions

* Refactor note commitment tree lookups to go through the height methods

* Make Sapling/Orchard note commitment tree lookup forwards compatible

* Ignore errors reading column family lists from disk

* Update format version comments and TODOs

* Correctly log newly created database formats

* Fix a new cargo lint about resolver versions

* cargo clippy --fix --all-features --all-targets

* cargo fmt --all

* Add missing tokio feature in the state, revealed by the new resolver

* Add missing dev dependencies in zebra-node-services

* Add a missing `tokio` feature from PR #6813

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
teor2345 and mergify[bot] authored Jun 7, 2023
1 parent 59086c7 commit f3e3309
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 74 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ members = [
"tower-fallback",
]

# Use the edition 2021 dependency resolver in the workspace, to match the crates
resolver = "2"

[profile.dev]
panic = "abort"

Expand Down
2 changes: 1 addition & 1 deletion zebra-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tempfile = "3.5.0"
thiserror = "1.0.40"

futures = "0.3.28"
tokio = { version = "1.28.2", features = ["fs", "net", "time", "tracing", "macros", "rt-multi-thread"] }
tokio = { version = "1.28.2", features = ["fs", "io-util", "net", "time", "tracing", "macros", "rt-multi-thread"] }
tokio-stream = { version = "0.1.14", features = ["sync", "time"] }
tokio-util = { version = "0.7.8", features = ["codec"] }
tower = { version = "0.4.13", features = ["retry", "discover", "load", "load-shed", "timeout", "util", "buffer"] }
Expand Down
2 changes: 1 addition & 1 deletion zebra-network/src/peer/connection/tests/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ proptest! {

// Check the state after the response
let error = shared_error_slot.try_get_error();
assert!(matches!(error, None));
assert!(error.is_none());

inbound_service.expect_no_requests().await?;

Expand Down
8 changes: 3 additions & 5 deletions zebra-network/src/peer_set/initialize/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ async fn add_initial_peers_is_rate_limited() {
// Check for panics or errors in the address book updater task.
let updater_result = address_book_updater_task_handle.now_or_never();
assert!(
matches!(updater_result, None)
updater_result.is_none()
|| matches!(updater_result, Some(Err(ref join_error)) if join_error.is_cancelled())
// The task method only returns one kind of error.
// We can't check for error equality due to type erasure,
Expand Down Expand Up @@ -1643,8 +1643,7 @@ where
// Check for panics or errors in the crawler.
let crawl_result = crawl_task_handle.now_or_never();
assert!(
matches!(crawl_result, None)
|| matches!(crawl_result, Some(Err(ref e)) if e.is_cancelled()),
crawl_result.is_none() || matches!(crawl_result, Some(Err(ref e)) if e.is_cancelled()),
"unexpected error or panic in peer crawler task: {crawl_result:?}",
);

Expand Down Expand Up @@ -1749,8 +1748,7 @@ where
// Check for panics or errors in the listener.
let listen_result = listen_task_handle.now_or_never();
assert!(
matches!(listen_result, None)
|| matches!(listen_result, Some(Err(ref e)) if e.is_cancelled()),
listen_result.is_none() || matches!(listen_result, Some(Err(ref e)) if e.is_cancelled()),
"unexpected error or panic in inbound peer listener task: {listen_result:?}",
);

Expand Down
2 changes: 1 addition & 1 deletion zebra-network/src/peer_set/set/tests/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ where
.all(|harness| harness.remote_version() < minimum_version);

if all_peers_are_outdated {
prop_assert!(matches!(poll_result, None));
prop_assert!(poll_result.is_none());
} else {
prop_assert!(matches!(poll_result, Some(Ok(_))));
}
Expand Down
27 changes: 10 additions & 17 deletions zebra-network/src/peer_set/set/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,10 @@ fn peer_set_route_inv_advertised_registry_order(advertised_first: bool) {
};

assert!(
matches!(
other_handle
.try_to_receive_outbound_client_request()
.request(),
None
),
other_handle
.try_to_receive_outbound_client_request()
.request()
.is_none(),
"request routed to non-advertised peer",
);
});
Expand Down Expand Up @@ -430,12 +428,10 @@ fn peer_set_route_inv_missing_registry_order(missing_first: bool) {
};

assert!(
matches!(
missing_handle
.try_to_receive_outbound_client_request()
.request(),
None
),
missing_handle
.try_to_receive_outbound_client_request()
.request()
.is_none(),
"request routed to missing peer",
);

Expand Down Expand Up @@ -529,12 +525,9 @@ fn peer_set_route_inv_all_missing_fail() {
let missing_handle = &mut handles[0];

assert!(
matches!(
missing_handle
missing_handle
.try_to_receive_outbound_client_request()
.request(),
None
),
.request().is_none(),
"request routed to missing peer",
);

Expand Down
8 changes: 8 additions & 0 deletions zebra-node-services/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ jsonrpc-core = { version = "18.0.0", optional = true }
reqwest = { version = "0.11.18", optional = true }
serde = { version = "1.0.163", optional = true }
serde_json = { version = "1.0.95", optional = true }

[dev-dependencies]

color-eyre = "0.6.2"
jsonrpc-core = "18.0.0"
reqwest = "0.11.18"
serde = "1.0.163"
serde_json = "1.0.95"
24 changes: 12 additions & 12 deletions zebra-rpc/src/methods/tests/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -137,7 +137,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -197,7 +197,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -251,7 +251,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -307,7 +307,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -405,7 +405,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -461,7 +461,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -519,7 +519,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -552,7 +552,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

runtime.block_on(async move {
mempool.expect_no_requests().await?;
Expand Down Expand Up @@ -631,7 +631,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

// check no requests were made during this test
runtime.block_on(async move {
Expand Down Expand Up @@ -855,7 +855,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down Expand Up @@ -955,7 +955,7 @@ proptest! {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
prop_assert!(matches!(rpc_tx_queue_task_result, None));
prop_assert!(rpc_tx_queue_task_result.is_none());

Ok::<_, TestCaseError>(())
})?;
Expand Down
14 changes: 7 additions & 7 deletions zebra-rpc/src/methods/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async fn rpc_getinfo() {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -211,7 +211,7 @@ async fn rpc_getblock() {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -253,7 +253,7 @@ async fn rpc_getblock_parse_error() {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -307,7 +307,7 @@ async fn rpc_getblock_missing_error() {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -355,7 +355,7 @@ async fn rpc_getbestblockhash() {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -519,7 +519,7 @@ async fn rpc_getrawtransaction() {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -625,7 +625,7 @@ async fn rpc_getaddresstxids_invalid_arguments() {

// The queue task should continue without errors or panics
let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down
8 changes: 4 additions & 4 deletions zebra-rpc/src/server/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ fn rpc_server_spawn(parallel_cpu_threads: bool) {

// The server and queue tasks should continue without errors or panics
let rpc_server_task_result = rpc_server_task_handle.now_or_never();
assert!(matches!(rpc_server_task_result, None));
assert!(rpc_server_task_result.is_none());

let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
});

info!("waiting for RPC server to shut down...");
Expand Down Expand Up @@ -184,10 +184,10 @@ fn rpc_server_spawn_unallocated_port(parallel_cpu_threads: bool, do_shutdown: bo
} else {
// The server and queue tasks should continue without errors or panics
let rpc_server_task_result = rpc_server_task_handle.now_or_never();
assert!(matches!(rpc_server_task_result, None));
assert!(rpc_server_task_result.is_none());

let rpc_tx_queue_task_result = rpc_tx_queue_task_handle.now_or_never();
assert!(matches!(rpc_tx_queue_task_result, None));
assert!(rpc_tx_queue_task_result.is_none());
}
});

Expand Down
2 changes: 1 addition & 1 deletion zebra-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tempfile = "3.5.0"
thiserror = "1.0.40"

rayon = "1.7.0"
tokio = { version = "1.28.2", features = ["sync", "tracing"] }
tokio = { version = "1.28.2", features = ["rt-multi-thread", "sync", "tracing"] }
tower = { version = "0.4.13", features = ["buffer", "util"] }
tracing = "0.1.37"

Expand Down
Loading

0 comments on commit f3e3309

Please sign in to comment.