Merge pull request #4277 from nymtech/chore/1.75.0-lints

Chore/1.75.0 lints
This commit is contained in:
Jędrzej Stuczyński
2024-01-02 11:42:50 +01:00
committed by GitHub
26 changed files with 117 additions and 84 deletions
@@ -1,6 +1,8 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
#![allow(unused_imports)]
use std::time::Duration;
pub use wasmtimer::{std::Instant, tokio::*};
+11 -11
View File
@@ -108,6 +108,17 @@ pub fn transpose_matrix<T: Debug>(matrix: Vec<Vec<T>>) -> Vec<Vec<T>> {
.collect::<Vec<_>>()
}
#[macro_export]
macro_rules! random_scalars_refs {
( $x: ident, $params: expr, $n: expr ) => {
let _vec = $params.n_random_scalars($n);
#[allow(clippy::map_identity)]
let $x = _vec.iter().collect::<Vec<_>>();
};
}
pub use random_scalars_refs;
#[cfg(test)]
pub mod tests {
use super::*;
@@ -170,14 +181,3 @@ pub mod tests {
.collect()
}
}
#[macro_export]
macro_rules! random_scalars_refs {
( $x: ident, $params: expr, $n: expr ) => {
let _vec = $params.n_random_scalars($n);
#[allow(clippy::map_identity)]
let $x = _vec.iter().collect::<Vec<_>>();
};
}
pub use random_scalars_refs;
+1
View File
@@ -43,6 +43,7 @@ pub(crate) enum BlockManagerError {
BlockManager(#[from] anyhow::Error),
}
#[allow(clippy::struct_field_names)] // this should get resolved properly at some point, but not now...
/// It helps to use atomic state management for new blocks.
pub(crate) struct BlockChainState {
pub(crate) last_blocks: LruCache<Hash, Block>,
+2
View File
@@ -102,6 +102,8 @@ pub(crate) struct Peer {
/// assert_eq!(peer_id, public_key.peer_id());
///
/// ```
#[allow(clippy::struct_field_names)]
// this should get resolved properly at some point, but not now...
pub peer_id: PeerId,
/// The peer's public key. It matches PeerId.
pub public_key: PublicKey,
@@ -1,3 +1,6 @@
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::country_statistics::country_nodes_distribution::CountryNodesDistribution;
use crate::state::ExplorerApiStateContext;
use rocket::serde::json::Json;
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use nym_explorer_api_requests::PrettyDetailedGatewayBond;
use rocket::response::status::NotFound;
use rocket::serde::json::Json;
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::mix_node::delegations::{
get_single_mixnode_delegations, get_single_mixnode_delegations_summed,
};
+3
View File
@@ -1,3 +1,6 @@
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::mix_nodes::models::{MixNodeActiveSetSummary, MixNodeSummary};
use crate::state::ExplorerApiStateContext;
use nym_explorer_api_requests::{MixnodeStatus, PrettyDetailedMixNodeBond};
+3
View File
@@ -1,3 +1,6 @@
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use rocket::serde::json::Json;
use rocket::{Route, State};
use rocket_okapi::okapi::openapi3::OpenApi;
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use nym_mixnet_contract_common::{MixId, MixNode};
use rocket::serde::json::Json;
use rocket::{Route, State};
@@ -1,3 +1,6 @@
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::service_providers::models::{
DirectoryService, DirectorySpDetailed, HarbourMasterService, PagedResult,
};
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use rocket::response::status::NotFound;
use rocket::serde::json::Json;
use rocket::{Route, State};
@@ -1,6 +1,9 @@
// Copyright 2022-2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::circulating_supply_api::cache::CirculatingSupplyCache;
use crate::node_status_api::models::ErrorResponse;
use nym_api_requests::models::CirculatingSupplyResponse;
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::coconut::api_routes::helpers::build_credentials_response;
use crate::coconut::error::{CoconutError, Result};
use crate::coconut::helpers::{accepted_vote_err, blind_sign};
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::network::models::{ContractInformation, NetworkDetails};
use crate::nym_contract_cache::cache::NymContractCache;
use nym_contracts_common::ContractBuildInformation;
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use super::helpers::_get_gateways_detailed;
use super::NodeStatusCache;
use crate::node_status_api::helpers::{
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::{
node_status_api::{
helpers::{_get_active_set_detailed, _get_mixnodes_detailed, _get_rewarded_set_detailed},
+3
View File
@@ -1,6 +1,9 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::node_describe_cache::DescribedNodes;
use crate::nym_contract_cache::cache::NymContractCache;
use crate::support::caching::cache::SharedCache;
+31 -45
View File
@@ -400,12 +400,12 @@ dependencies = [
[[package]]
name = "bls12_381"
version = "0.6.0"
source = "git+https://github.com/jstuczyn/bls12_381?branch=gt-serialisation#10fb6f700bfda17c8475af3bfd31e3fec15f2278"
version = "0.8.0"
source = "git+https://github.com/jstuczyn/bls12_381?branch=feature/gt-serialization-0.8.0#c4543fde7d02efea6ecfcf22e14476ddb516b483"
dependencies = [
"digest 0.9.0",
"ff 0.11.1",
"group 0.11.0",
"ff 0.13.0",
"group 0.13.0",
"pairing",
"rand_core 0.6.4",
"subtle 2.4.1",
@@ -1051,6 +1051,7 @@ dependencies = [
"byteorder",
"digest 0.9.0",
"rand_core 0.5.1",
"serde",
"subtle 2.4.1",
"zeroize",
]
@@ -1455,6 +1456,7 @@ version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7"
dependencies = [
"serde",
"signature 1.6.4",
]
@@ -1491,6 +1493,7 @@ dependencies = [
"ed25519 1.5.3",
"rand 0.7.3",
"serde",
"serde_bytes",
"sha2 0.9.9",
"zeroize",
]
@@ -1665,16 +1668,6 @@ dependencies = [
"log",
]
[[package]]
name = "ff"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924"
dependencies = [
"rand_core 0.6.4",
"subtle 2.4.1",
]
[[package]]
name = "ff"
version = "0.12.1"
@@ -1691,6 +1684,7 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449"
dependencies = [
"bitvec",
"rand_core 0.6.4",
"subtle 2.4.1",
]
@@ -2170,18 +2164,6 @@ dependencies = [
"system-deps 6.1.1",
]
[[package]]
name = "group"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89"
dependencies = [
"byteorder",
"ff 0.11.1",
"rand_core 0.6.4",
"subtle 2.4.1",
]
[[package]]
name = "group"
version = "0.12.1"
@@ -2803,9 +2785,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.147"
version = "0.2.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
[[package]]
name = "libgit2-sys"
@@ -2981,9 +2963,9 @@ dependencies = [
[[package]]
name = "mio"
version = "0.8.8"
version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09"
dependencies = [
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
@@ -3149,10 +3131,12 @@ dependencies = [
"cosmwasm-std",
"getset",
"nym-coconut-interface",
"nym-crypto",
"nym-mixnet-contract-common",
"nym-node-requests",
"schemars",
"serde",
"tendermint",
]
[[package]]
@@ -3178,9 +3162,9 @@ dependencies = [
"bls12_381",
"bs58 0.4.0",
"digest 0.9.0",
"ff 0.11.1",
"ff 0.13.0",
"getrandom 0.2.10",
"group 0.11.0",
"group 0.13.0",
"itertools 0.10.5",
"nym-dkg",
"nym-pemstore",
@@ -3256,6 +3240,8 @@ dependencies = [
"nym-pemstore",
"nym-sphinx-types",
"rand 0.7.3",
"serde",
"serde_bytes",
"subtle-encoding",
"thiserror",
"x25519-dalek 1.1.1",
@@ -3269,8 +3255,8 @@ dependencies = [
"bitvec",
"bls12_381",
"bs58 0.4.0",
"ff 0.11.1",
"group 0.11.0",
"ff 0.13.0",
"group 0.13.0",
"lazy_static",
"nym-pemstore",
"rand 0.8.5",
@@ -3566,7 +3552,6 @@ dependencies = [
"nym-crypto",
"serde",
"thiserror",
"tokio",
"x25519-dalek 2.0.0",
]
@@ -3765,11 +3750,11 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "pairing"
version = "0.21.0"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2e415e349a3006dd7d9482cdab1c980a845bed1377777d768cb693a44540b42"
checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f"
dependencies = [
"group 0.11.0",
"group 0.13.0",
]
[[package]]
@@ -5067,9 +5052,9 @@ dependencies = [
[[package]]
name = "socket2"
version = "0.5.3"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877"
checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
dependencies = [
"libc",
"windows-sys 0.48.0",
@@ -5798,9 +5783,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.31.0"
version = "1.35.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
dependencies = [
"backtrace",
"bytes",
@@ -5810,16 +5795,16 @@ dependencies = [
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2 0.5.3",
"socket2 0.5.5",
"tokio-macros",
"windows-sys 0.48.0",
]
[[package]]
name = "tokio-macros"
version = "2.1.0"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
@@ -6742,6 +6727,7 @@ checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f"
dependencies = [
"curve25519-dalek 3.2.0",
"rand_core 0.5.1",
"serde",
"zeroize",
]
@@ -109,7 +109,7 @@ impl Connection {
},
}),
})
.map_err(|e| Error::OutboundSendError(e.to_string()))?;
.map_err(|e| Error::OutboundSendFailure(e.to_string()))?;
// track pending outbound substreams
// TODO we should probably lock this? storing map values should be atomic
@@ -159,7 +159,7 @@ impl Connection {
// notify poll_close that the substream is closed
self.close_tx
.send(substream_id)
.map_err(|e| Error::InboundSendError(e.to_string()))
.map_err(|e| Error::InboundSendFailure(e.to_string()))
}
}
@@ -217,13 +217,13 @@ impl StreamMuxer for Connection {
},
}),
})
.map_err(|e| Error::OutboundSendError(e.to_string()))?;
.map_err(|e| Error::OutboundSendFailure(e.to_string()))?;
debug!("wrote OpenResponse for substream: {:?}", &msg.substream_id);
// send the substream to our own channel to be returned in poll_inbound
self.inbound_open_tx
.send(substream)
.map_err(|e| Error::InboundSendError(e.to_string()))?;
.map_err(|e| Error::InboundSendFailure(e.to_string()))?;
debug!("new inbound substream: {:?}", &msg.substream_id);
}
@@ -48,15 +48,15 @@ pub enum Error {
#[error("no substream found for given ID")]
SubstreamIdDoesNotExist(SubstreamId),
#[error("recv error: channel closed")]
OneshotRecvError(#[from] tokio::sync::oneshot::error::RecvError),
OneshotRecvFailure(#[from] tokio::sync::oneshot::error::RecvError),
#[error("recv error: channel closed")]
RecvError,
RecvFailure,
#[error("outbound send error")]
OutboundSendError(String),
OutboundSendFailure(String),
#[error("inbound send error")]
InboundSendError(String),
InboundSendFailure(String),
#[error("failed to send new connection; receiver dropped")]
ConnectionSendError,
ConnectionSendFailure,
#[error("failed to send initial TransportEvent::NewAddress")]
SendErrorTransportEvent,
#[error("dial timed out")]
@@ -62,7 +62,7 @@ async fn check_inbound(
if let Some(notify_tx) = notify_inbound_tx {
notify_tx
.send(())
.map_err(|e| Error::InboundSendError(e.to_string()))?;
.map_err(|e| Error::InboundSendFailure(e.to_string()))?;
}
handle_inbound(msg, inbound_tx).await?;
@@ -78,7 +78,7 @@ async fn handle_inbound(
let data = parse_message_data(&msg.message)?;
inbound_tx
.send(data)
.map_err(|e| Error::InboundSendError(e.to_string()))?;
.map_err(|e| Error::InboundSendFailure(e.to_string()))?;
Ok(())
}
@@ -95,7 +95,7 @@ async fn check_outbound(
)
.await
}
None => Err(Error::RecvError),
None => Err(Error::RecvFailure),
}
}
@@ -170,7 +170,7 @@ impl NymTransport {
);
inbound_tx
.send(msg.message.clone())
.map_err(|e| Error::InboundSendError(e.to_string()))?;
.map_err(|e| Error::InboundSendFailure(e.to_string()))?;
}
}
None => {
@@ -207,7 +207,7 @@ impl NymTransport {
pending_conn
.connection_tx
.send(conn)
.map_err(|_| Error::ConnectionSendError)?;
.map_err(|_| Error::ConnectionSendFailure)?;
if let Some(waker) = self.waker.take() {
waker.wake();
@@ -247,7 +247,7 @@ impl NymTransport {
message: Message::ConnectionResponse(resp),
recipient: msg.recipient.unwrap(),
})
.map_err(|e| Error::OutboundSendError(e.to_string()))?;
.map_err(|e| Error::OutboundSendFailure(e.to_string()))?;
if let Some(waker) = self.waker.take() {
waker.wake();
@@ -287,7 +287,7 @@ impl NymTransport {
);
inbound_tx
.send(msg.message.clone())
.map_err(|e| Error::InboundSendError(e.to_string()))?;
.map_err(|e| Error::InboundSendFailure(e.to_string()))?;
// try to pop queued messages and send them on inbound channel
while let Some(msg) = queue.pop() {
@@ -297,7 +297,7 @@ impl NymTransport {
);
inbound_tx
.send(msg.message.clone())
.map_err(|e| Error::InboundSendError(e.to_string()))?;
.map_err(|e| Error::InboundSendFailure(e.to_string()))?;
}
if let Some(waker) = self.waker.clone().take() {
@@ -340,7 +340,7 @@ impl NymTransport {
let upgrade = Upgrade::new(connection_rx);
connection_tx
.send((inner.peer_id, conn))
.map_err(|_| Error::ConnectionSendError)?;
.map_err(|_| Error::ConnectionSendFailure)?;
Ok(InboundTransportEvent::ConnectionRequest(upgrade))
}
Err(e) => Err(e),
@@ -380,7 +380,7 @@ impl Future for Upgrade {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.connection_tx
.poll_unpin(cx)
.map_err(|_| Error::RecvError)
.map_err(|_| Error::RecvFailure)
}
}
@@ -441,7 +441,7 @@ impl Transport for NymTransport {
message: Message::ConnectionRequest(msg),
recipient,
})
.map_err(|e| Error::OutboundSendError(e.to_string()))?;
.map_err(|e| Error::OutboundSendFailure(e.to_string()))?;
debug!("sent outbound ConnectionRequest");
if let Some(waker) = waker.take() {
@@ -555,7 +555,7 @@ mod test {
message: msg,
}),
})
.map_err(|e| Error::OutboundSendError(e.to_string()))?;
.map_err(|e| Error::OutboundSendFailure(e.to_string()))?;
Ok(())
}
}
@@ -22,7 +22,6 @@ use std::time::Duration;
use url::Url;
pub use nym_client_core::config::Config as BaseClientConfig;
pub use nym_client_core::config::{DebugConfig, GatewayEndpointConfig};
pub mod old_config_v1_1_13;
pub mod old_config_v1_1_20;
@@ -1,14 +1,15 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use rocket::serde::json::Json;
use rocket::State;
use serde::{Deserialize, Serialize};
use nym_statistics_common::StatsMessage;
// due to the macro expansion of rather old rocket macros...
#![allow(unused_imports)]
use crate::api::error::Result;
use crate::storage::NetworkStatisticsStorage;
use nym_statistics_common::StatsMessage;
use rocket::serde::json::Json;
use rocket::State;
use serde::{Deserialize, Serialize};
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct StatisticsRequest {
+1 -1
View File
@@ -92,7 +92,7 @@ impl UpgradePlan {
}
pub(crate) fn next_upgrade(&self) -> Option<&UpgradeInfo> {
self.queued_up.get(0)
self.queued_up.first()
}
pub(crate) fn pop_next_upgrade(&mut self) -> Option<UpgradeInfo> {