From ea3af281393741b147a4d78ad02bb37593e63e87 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 16 Dec 2023 20:54:24 -0500 Subject: [PATCH] Add workspace lints --- Cargo.toml | 25 +++++++++++++++++ coins/bitcoin/Cargo.toml | 7 +++++ coins/bitcoin/src/tests/crypto.rs | 2 +- coins/bitcoin/src/wallet/send.rs | 2 +- coins/bitcoin/tests/wallet.rs | 2 +- coins/ethereum/Cargo.toml | 3 ++ coins/monero/Cargo.toml | 3 ++ coins/monero/generators/Cargo.toml | 3 ++ coins/monero/src/ringct/bulletproofs/mod.rs | 4 +-- .../ringct/bulletproofs/plus/scalar_vector.rs | 6 ++-- .../plus/weighted_inner_product.rs | 2 +- coins/monero/src/rpc/http.rs | 2 +- coins/monero/src/unreduced_scalar.rs | 8 +++--- coins/monero/src/wallet/decoys.rs | 4 +++ coins/monero/src/wallet/mod.rs | 2 +- coins/monero/src/wallet/seed/classic.rs | 2 +- coins/monero/src/wallet/seed/polyseed.rs | 3 +- coins/monero/src/wallet/send/multisig.rs | 6 +++- coins/monero/tests/send.rs | 28 +++++++++---------- common/db/Cargo.toml | 3 ++ common/env/Cargo.toml | 3 ++ common/request/Cargo.toml | 3 ++ common/std-shims/Cargo.toml | 3 ++ common/zalloc/Cargo.toml | 3 ++ coordinator/Cargo.toml | 3 ++ coordinator/src/cosign_evaluator.rs | 4 +-- coordinator/src/p2p.rs | 2 +- coordinator/src/tests/tributary/chain.rs | 8 +++--- coordinator/src/tests/tributary/dkg.rs | 2 +- coordinator/src/tributary/db.rs | 2 -- coordinator/src/tributary/handle.rs | 10 +++---- coordinator/src/tributary/mod.rs | 1 - coordinator/src/tributary/scanner.rs | 3 +- coordinator/src/tributary/signing_protocol.rs | 4 +-- coordinator/tributary/Cargo.toml | 7 +++++ coordinator/tributary/src/block.rs | 2 +- coordinator/tributary/src/blockchain.rs | 2 +- coordinator/tributary/src/mempool.rs | 6 ++-- coordinator/tributary/src/provided.rs | 1 - coordinator/tributary/tendermint/Cargo.toml | 7 +++++ coordinator/tributary/tendermint/src/lib.rs | 8 +++--- .../tributary/tendermint/src/message_log.rs | 2 -- crypto/ciphersuite/Cargo.toml | 3 ++ crypto/dalek-ff-group/Cargo.toml | 3 ++ crypto/dalek-ff-group/src/lib.rs | 1 + crypto/dkg/Cargo.toml | 3 ++ crypto/dkg/src/encryption.rs | 2 +- crypto/dkg/src/lib.rs | 8 +++--- crypto/dleq/Cargo.toml | 3 ++ crypto/dleq/src/cross_group/aos.rs | 2 +- crypto/dleq/src/cross_group/bits.rs | 2 +- crypto/dleq/src/cross_group/mod.rs | 7 +++-- crypto/dleq/src/cross_group/scalar.rs | 2 +- crypto/ed448/Cargo.toml | 3 ++ crypto/ed448/src/backend.rs | 1 + crypto/ed448/src/point.rs | 2 +- crypto/ff-group-tests/Cargo.toml | 3 ++ crypto/frost/Cargo.toml | 3 ++ crypto/frost/src/algorithm.rs | 2 +- crypto/frost/src/nonce.rs | 2 +- crypto/frost/src/tests/mod.rs | 2 +- crypto/frost/src/tests/nonces.rs | 2 +- crypto/multiexp/Cargo.toml | 3 ++ crypto/multiexp/src/lib.rs | 1 + crypto/schnorr/Cargo.toml | 3 ++ crypto/schnorrkel/Cargo.toml | 3 ++ crypto/schnorrkel/src/lib.rs | 2 +- crypto/transcript/Cargo.toml | 3 ++ message-queue/Cargo.toml | 3 ++ message-queue/src/client.rs | 4 +-- message-queue/src/main.rs | 12 ++++---- mini/Cargo.toml | 3 ++ processor/Cargo.toml | 3 ++ processor/messages/Cargo.toml | 3 ++ processor/src/batch_signer.rs | 4 +-- processor/src/cosigner.rs | 4 +-- processor/src/key_gen.rs | 2 +- processor/src/multisigs/db.rs | 2 +- processor/src/multisigs/mod.rs | 4 +-- processor/src/multisigs/scanner.rs | 2 +- processor/src/multisigs/scheduler.rs | 4 +-- processor/src/networks/bitcoin.rs | 2 +- processor/src/networks/monero.rs | 4 +-- processor/src/signer.rs | 4 +-- processor/src/tests/addresses.rs | 2 +- processor/src/tests/scanner.rs | 2 +- processor/src/tests/signer.rs | 2 +- processor/src/tests/wallet.rs | 2 +- substrate/abi/Cargo.toml | 3 ++ substrate/client/Cargo.toml | 3 ++ substrate/client/src/serai/mod.rs | 1 - substrate/coins/pallet/Cargo.toml | 3 ++ substrate/coins/pallet/src/lib.rs | 1 + substrate/coins/primitives/Cargo.toml | 3 ++ substrate/dex/pallet/Cargo.toml | 3 ++ substrate/dex/pallet/src/lib.rs | 3 +- substrate/in-instructions/pallet/Cargo.toml | 3 ++ substrate/in-instructions/pallet/src/lib.rs | 1 + .../in-instructions/primitives/Cargo.toml | 3 ++ substrate/node/Cargo.toml | 7 +++++ substrate/node/src/service.rs | 4 +-- substrate/primitives/Cargo.toml | 3 ++ substrate/runtime/Cargo.toml | 3 ++ substrate/runtime/src/lib.rs | 2 ++ substrate/signals/pallet/Cargo.toml | 3 ++ substrate/signals/pallet/src/lib.rs | 7 ++++- substrate/signals/primitives/Cargo.toml | 3 ++ substrate/validator-sets/pallet/Cargo.toml | 3 ++ substrate/validator-sets/pallet/src/lib.rs | 11 ++++++-- .../validator-sets/primitives/Cargo.toml | 3 ++ tests/coordinator/Cargo.toml | 3 ++ tests/coordinator/src/tests/batch.rs | 6 ++-- tests/coordinator/src/tests/key_gen.rs | 4 +-- tests/coordinator/src/tests/sign.rs | 2 +- tests/docker/Cargo.toml | 3 ++ tests/full-stack/Cargo.toml | 3 ++ tests/message-queue/Cargo.toml | 3 ++ tests/no-std/Cargo.toml | 3 ++ tests/processor/Cargo.toml | 3 ++ tests/processor/src/tests/batch.rs | 2 +- tests/processor/src/tests/send.rs | 4 +-- tests/reproducible-runtime/Cargo.toml | 3 ++ 122 files changed, 329 insertions(+), 128 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a63b7461..c0a32e11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,3 +96,28 @@ lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev # subxt *can* pull these off crates.io yet there's no benefit to this sp-core-hashing = { git = "https://github.com/serai-dex/substrate" } sp-std = { git = "https://github.com/serai-dex/substrate" } + +[workspace.lints.clippy] +unwrap_or_default = "allow" +borrow_as_ptr = "deny" +cast_lossless = "deny" +cast_possible_truncation = "deny" +cast_possible_wrap = "deny" +cast_precision_loss = "deny" +cast_ptr_alignment = "deny" +cast_sign_loss = "deny" +checked_conversions = "deny" +cloned_instead_of_copied = "deny" +enum_glob_use = "deny" +expl_impl_clone_on_copy = "deny" +explicit_into_iter_loop = "deny" +explicit_iter_loop = "deny" +flat_map_option = "deny" +float_cmp = "deny" +fn_params_excessive_bools = "deny" +ignored_unit_patterns = "deny" +implicit_clone = "deny" +inefficient_to_string = "deny" +invalid_upcast_comparisons = "deny" +large_stack_arrays = "deny" +linkedlist = "deny" diff --git a/coins/bitcoin/Cargo.toml b/coins/bitcoin/Cargo.toml index d61e2fd6..4ff0f79a 100644 --- a/coins/bitcoin/Cargo.toml +++ b/coins/bitcoin/Cargo.toml @@ -8,6 +8,13 @@ authors = ["Luke Parker ", "Vrx "] edition = "2021" rust-version = "1.74" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + [dependencies] std-shims = { version = "0.1.1", path = "../../common/std-shims", default-features = false } diff --git a/coins/bitcoin/src/tests/crypto.rs b/coins/bitcoin/src/tests/crypto.rs index 7380e296..78a7215b 100644 --- a/coins/bitcoin/src/tests/crypto.rs +++ b/coins/bitcoin/src/tests/crypto.rs @@ -20,7 +20,7 @@ fn test_algorithm() { let mut keys = key_gen::<_, Secp256k1>(&mut OsRng); const MESSAGE: &[u8] = b"Hello, World!"; - for (_, keys) in keys.iter_mut() { + for keys in keys.values_mut() { let (_, offset) = make_even(keys.group_key()); *keys = keys.offset(Scalar::from(offset)); } diff --git a/coins/bitcoin/src/wallet/send.rs b/coins/bitcoin/src/wallet/send.rs index 5235ae88..5c32af4e 100644 --- a/coins/bitcoin/src/wallet/send.rs +++ b/coins/bitcoin/src/wallet/send.rs @@ -355,7 +355,7 @@ impl SignMachine for TransactionSignMachine { } fn from_cache( - _: (), + (): (), _: ThresholdKeys, _: CachedPreprocess, ) -> (Self, Self::Preprocess) { diff --git a/coins/bitcoin/tests/wallet.rs b/coins/bitcoin/tests/wallet.rs index 01a035c9..e4475933 100644 --- a/coins/bitcoin/tests/wallet.rs +++ b/coins/bitcoin/tests/wallet.rs @@ -82,7 +82,7 @@ async fn send_and_get_output(rpc: &Rpc, scanner: &Scanner, key: ProjectivePoint) fn keys() -> (HashMap>, ProjectivePoint) { let mut keys = key_gen(&mut OsRng); - for (_, keys) in keys.iter_mut() { + for keys in keys.values_mut() { *keys = tweak_keys(keys); } let key = keys.values().next().unwrap().group_key(); diff --git a/coins/ethereum/Cargo.toml b/coins/ethereum/Cargo.toml index 1d2a3d39..1d1c6dbb 100644 --- a/coins/ethereum/Cargo.toml +++ b/coins/ethereum/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] thiserror = { version = "1", default-features = false } eyre = { version = "0.6", default-features = false } diff --git a/coins/monero/Cargo.toml b/coins/monero/Cargo.toml index 7de89426..9c78e431 100644 --- a/coins/monero/Cargo.toml +++ b/coins/monero/Cargo.toml @@ -12,6 +12,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false } diff --git a/coins/monero/generators/Cargo.toml b/coins/monero/generators/Cargo.toml index 95cfa25a..5e7b745a 100644 --- a/coins/monero/generators/Cargo.toml +++ b/coins/monero/generators/Cargo.toml @@ -11,6 +11,9 @@ edition = "2021" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] std-shims = { path = "../../../common/std-shims", version = "^0.1.1", default-features = false } diff --git a/coins/monero/src/ringct/bulletproofs/mod.rs b/coins/monero/src/ringct/bulletproofs/mod.rs index 6b25b1a0..1529680d 100644 --- a/coins/monero/src/ringct/bulletproofs/mod.rs +++ b/coins/monero/src/ringct/bulletproofs/mod.rs @@ -172,8 +172,8 @@ impl Bulletproofs { write_scalar(&bp.wip.r_answer.0, w)?; write_scalar(&bp.wip.s_answer.0, w)?; write_scalar(&bp.wip.delta_answer.0, w)?; - specific_write_vec(&bp.wip.L.iter().cloned().map(|L| L.0).collect::>(), w)?; - specific_write_vec(&bp.wip.R.iter().cloned().map(|R| R.0).collect::>(), w) + specific_write_vec(&bp.wip.L.iter().copied().map(|L| L.0).collect::>(), w)?; + specific_write_vec(&bp.wip.R.iter().copied().map(|R| R.0).collect::>(), w) } } } diff --git a/coins/monero/src/ringct/bulletproofs/plus/scalar_vector.rs b/coins/monero/src/ringct/bulletproofs/plus/scalar_vector.rs index a8b0866e..7bc0c3f4 100644 --- a/coins/monero/src/ringct/bulletproofs/plus/scalar_vector.rs +++ b/coins/monero/src/ringct/bulletproofs/plus/scalar_vector.rs @@ -32,7 +32,7 @@ impl ScalarVector { pub(crate) fn add(&self, scalar: impl Borrow) -> Self { let mut res = self.clone(); - for val in res.0.iter_mut() { + for val in &mut res.0 { *val += scalar.borrow(); } res @@ -40,7 +40,7 @@ impl ScalarVector { pub(crate) fn sub(&self, scalar: impl Borrow) -> Self { let mut res = self.clone(); - for val in res.0.iter_mut() { + for val in &mut res.0 { *val -= scalar.borrow(); } res @@ -48,7 +48,7 @@ impl ScalarVector { pub(crate) fn mul(&self, scalar: impl Borrow) -> Self { let mut res = self.clone(); - for val in res.0.iter_mut() { + for val in &mut res.0 { *val *= scalar.borrow(); } res diff --git a/coins/monero/src/ringct/bulletproofs/plus/weighted_inner_product.rs b/coins/monero/src/ringct/bulletproofs/plus/weighted_inner_product.rs index 9aea2148..8ef1aa90 100644 --- a/coins/monero/src/ringct/bulletproofs/plus/weighted_inner_product.rs +++ b/coins/monero/src/ringct/bulletproofs/plus/weighted_inner_product.rs @@ -414,7 +414,7 @@ impl WipStatement { let mut multiexp = P_terms; multiexp.reserve(4 + (2 * generators.len())); - for (scalar, _) in multiexp.iter_mut() { + for (scalar, _) in &mut multiexp { *scalar *= neg_e_square; } diff --git a/coins/monero/src/rpc/http.rs b/coins/monero/src/rpc/http.rs index c0ec9ff3..e588a262 100644 --- a/coins/monero/src/rpc/http.rs +++ b/coins/monero/src/rpc/http.rs @@ -112,7 +112,7 @@ impl HttpRpc { )?; Authentication::Authenticated { username: split_userpass[0].to_string(), - password: split_userpass.get(1).unwrap_or(&"").to_string(), + password: (*split_userpass.get(1).unwrap_or(&"")).to_string(), connection: Arc::new(Mutex::new((challenge, client))), } } else { diff --git a/coins/monero/src/unreduced_scalar.rs b/coins/monero/src/unreduced_scalar.rs index 500c23f1..d0baa681 100644 --- a/coins/monero/src/unreduced_scalar.rs +++ b/coins/monero/src/unreduced_scalar.rs @@ -16,7 +16,7 @@ pub(crate) fn PRECOMPUTED_SCALARS() -> [Scalar; 8] { *PRECOMPUTED_SCALARS_CELL.get_or_init(|| { let mut precomputed_scalars = [Scalar::ONE; 8]; for (i, scalar) in precomputed_scalars.iter_mut().enumerate().skip(1) { - *scalar = Scalar::from(((i * 2) + 1) as u8); + *scalar = Scalar::from(u8::try_from((i * 2) + 1).unwrap()); } precomputed_scalars }) @@ -57,7 +57,7 @@ impl UnreducedScalar { let bits = self.as_bits(); let mut naf = [0i8; 256]; for (b, bit) in bits.into_iter().enumerate() { - naf[b] = bit as i8; + naf[b] = i8::try_from(bit).unwrap(); } for i in 0 .. 256 { @@ -127,8 +127,8 @@ impl UnreducedScalar { for &numb in self.non_adjacent_form().iter().rev() { recovered += recovered; match numb.cmp(&0) { - Ordering::Greater => recovered += precomputed_scalars[(numb as usize) / 2], - Ordering::Less => recovered -= precomputed_scalars[((-numb) as usize) / 2], + Ordering::Greater => recovered += precomputed_scalars[usize::try_from(numb).unwrap() / 2], + Ordering::Less => recovered -= precomputed_scalars[usize::try_from(-numb).unwrap() / 2], Ordering::Equal => (), } } diff --git a/coins/monero/src/wallet/decoys.rs b/coins/monero/src/wallet/decoys.rs index 23dbd40f..e3b9776f 100644 --- a/coins/monero/src/wallet/decoys.rs +++ b/coins/monero/src/wallet/decoys.rs @@ -28,6 +28,7 @@ const MATURITY: u64 = 60; const RECENT_WINDOW: usize = 15; const BLOCK_TIME: usize = 120; const BLOCKS_PER_YEAR: usize = 365 * 24 * 60 * 60 / BLOCK_TIME; +#[allow(clippy::cast_precision_loss)] const TIP_APPLICATION: f64 = (LOCK_WINDOW * BLOCK_TIME) as f64; // TODO: Resolve safety of this in case a reorg occurs/the network changes @@ -76,6 +77,7 @@ async fn select_n<'a, R: RngCore + CryptoRng, RPC: RpcConnection>( // Use a gamma distribution let mut age = Gamma::::new(19.28, 1.0 / 1.61).unwrap().sample(rng).exp(); + #[allow(clippy::cast_precision_loss)] if age > TIP_APPLICATION { age -= TIP_APPLICATION; } else { @@ -83,6 +85,7 @@ async fn select_n<'a, R: RngCore + CryptoRng, RPC: RpcConnection>( age = (rng.next_u64() % u64::try_from(RECENT_WINDOW * BLOCK_TIME).unwrap()) as f64; } + #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] let o = (age * per_second) as u64; if o < high { let i = distribution.partition_point(|s| *s < (high - 1 - o)); @@ -193,6 +196,7 @@ impl Decoys { distribution.truncate(height + 1); // height is inclusive, and 0 is a valid height let high = distribution[distribution.len() - 1]; + #[allow(clippy::cast_precision_loss)] let per_second = { let blocks = distribution.len().min(BLOCKS_PER_YEAR); let outputs = high - distribution[distribution.len().saturating_sub(blocks + 1)]; diff --git a/coins/monero/src/wallet/mod.rs b/coins/monero/src/wallet/mod.rs index b405c3ee..3b08fd97 100644 --- a/coins/monero/src/wallet/mod.rs +++ b/coins/monero/src/wallet/mod.rs @@ -80,7 +80,7 @@ pub(crate) fn shared_key( // uniqueness || let shared_key = if let Some(uniqueness) = uniqueness { - [uniqueness.as_ref(), &output_derivation].concat().to_vec() + [uniqueness.as_ref(), &output_derivation].concat() } else { output_derivation }; diff --git a/coins/monero/src/wallet/seed/classic.rs b/coins/monero/src/wallet/seed/classic.rs index 78c4f209..ffaf214e 100644 --- a/coins/monero/src/wallet/seed/classic.rs +++ b/coins/monero/src/wallet/seed/classic.rs @@ -200,7 +200,7 @@ pub(crate) fn seed_to_bytes(words: &str) -> Result<(Language, Zeroizing<[u8; 32] let mut matched_indices = Zeroizing::new(vec![]); // Iterate through all the languages - 'language: for (lang_name, lang) in LANGUAGES().iter() { + 'language: for (lang_name, lang) in LANGUAGES() { matched_indices.zeroize(); matched_indices.clear(); diff --git a/coins/monero/src/wallet/seed/polyseed.rs b/coins/monero/src/wallet/seed/polyseed.rs index b9833297..c6338ba5 100644 --- a/coins/monero/src/wallet/seed/polyseed.rs +++ b/coins/monero/src/wallet/seed/polyseed.rs @@ -55,6 +55,7 @@ const CLEAR_BITS: usize = (SECRET_SIZE * BITS_PER_BYTE) - SECRET_BITS; // 2 // Polyseed calls this CLEAR_MASK and has a very complicated formula for this fundamental // equivalency +#[allow(clippy::cast_possible_truncation)] const LAST_BYTE_SECRET_BITS_MASK: u8 = ((1 << (BITS_PER_BYTE - CLEAR_BITS)) - 1) as u8; const SECRET_BITS_PER_WORD: usize = 10; @@ -265,7 +266,7 @@ impl Polyseed { // Decode the seed into its polynomial coefficients let mut poly = [0; POLYSEED_LENGTH]; let lang = (|| { - 'language: for (name, lang) in LANGUAGES().iter() { + 'language: for (name, lang) in LANGUAGES() { for (i, word) in seed.split_whitespace().enumerate() { // Find the word's index fn check_if_matches, I: Iterator>( diff --git a/coins/monero/src/wallet/send/multisig.rs b/coins/monero/src/wallet/send/multisig.rs index 7b23d6cb..fdb23746 100644 --- a/coins/monero/src/wallet/send/multisig.rs +++ b/coins/monero/src/wallet/send/multisig.rs @@ -226,7 +226,11 @@ impl SignMachine for TransactionSignMachine { ); } - fn from_cache(_: (), _: ThresholdKeys, _: CachedPreprocess) -> (Self, Self::Preprocess) { + fn from_cache( + (): (), + _: ThresholdKeys, + _: CachedPreprocess, + ) -> (Self, Self::Preprocess) { unimplemented!( "Monero transactions don't support caching their preprocesses due to {}", "being already bound to a specific transaction" diff --git a/coins/monero/tests/send.rs b/coins/monero/tests/send.rs index cd1b919d..ca4ea5ad 100644 --- a/coins/monero/tests/send.rs +++ b/coins/monero/tests/send.rs @@ -46,7 +46,7 @@ test!( builder.add_payment(addr, 5); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0); assert_eq!(output.commitment().amount, 5); }, @@ -61,7 +61,7 @@ test!( builder.add_payment(addr, 2000000000000); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut outputs = scanner.scan_transaction(&tx).not_locked(); outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount)); assert_eq!(outputs[0].commitment().amount, 1000000000000); @@ -75,7 +75,7 @@ test!( builder.add_payment(addr, 6); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0); assert_eq!(output.commitment().amount, 6); }, @@ -92,7 +92,7 @@ test!( builder.add_payment(addr, 1000000000000); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut outputs = scanner.scan_transaction(&tx).not_locked(); outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount)); assert_eq!(outputs[0].commitment().amount, 1000000000000); @@ -157,7 +157,7 @@ test!( builder.add_payment(addr, 2000000000000); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut outputs = scanner.scan_transaction(&tx).not_locked(); outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount)); assert_eq!(outputs[0].commitment().amount, 2000000000000); @@ -170,7 +170,7 @@ test!( builder.add_payment(addr, 2); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0); assert_eq!(output.commitment().amount, 2); }, @@ -184,7 +184,7 @@ test!( builder.add_payment(addr, 1000000000000); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut outputs = scanner.scan_transaction(&tx).not_locked(); outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount)); assert_eq!(outputs[0].commitment().amount, 1000000000000); @@ -200,12 +200,12 @@ test!( } (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut scanned_tx = scanner.scan_transaction(&tx).not_locked(); let mut output_amounts = HashSet::new(); for i in 0 .. 15 { - output_amounts.insert((i + 1) as u64); + output_amounts.insert(i + 1); } for _ in 0 .. 15 { let output = scanned_tx.swap_remove(0); @@ -224,7 +224,7 @@ test!( builder.add_payment(addr, 1000000000000); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut outputs = scanner.scan_transaction(&tx).not_locked(); outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount)); assert_eq!(outputs[0].commitment().amount, 1000000000000); @@ -245,7 +245,7 @@ test!( builder.add_payment( view.address(Network::Mainnet, AddressSpec::Subaddress(subaddress)), - (i + 1) as u64, + u64::from(i + 1), ); subaddresses.push(subaddress); } @@ -259,7 +259,7 @@ test!( let mut output_amounts_by_subaddress = HashMap::new(); for i in 0 .. 15 { - output_amounts_by_subaddress.insert((i + 1) as u64, state.1[i]); + output_amounts_by_subaddress.insert(u64::try_from(i + 1).unwrap(), state.1[i]); } for _ in 0 .. 15 { let output = scanned_tx.swap_remove(0); @@ -281,7 +281,7 @@ test!( builder.add_payment(addr, 1000000000000); (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut outputs = scanner.scan_transaction(&tx).not_locked(); outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount)); assert_eq!(outputs[0].commitment().amount, 1000000000000); @@ -303,7 +303,7 @@ test!( (builder.build().unwrap(), ()) }, - |_, tx: Transaction, mut scanner: Scanner, _| async move { + |_, tx: Transaction, mut scanner: Scanner, ()| async move { let mut outputs = scanner.scan_transaction(&tx).not_locked(); outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount)); assert_eq!(outputs[0].commitment().amount, 10000); diff --git a/common/db/Cargo.toml b/common/db/Cargo.toml index 9833f755..78d486a1 100644 --- a/common/db/Cargo.toml +++ b/common/db/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.65" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] parity-db = { version = "0.4", default-features = false, optional = true } rocksdb = { version = "0.21", default-features = false, features = ["lz4"], optional = true } diff --git a/common/env/Cargo.toml b/common/env/Cargo.toml index 010b933b..8e296a66 100644 --- a/common/env/Cargo.toml +++ b/common/env/Cargo.toml @@ -12,3 +12,6 @@ rust-version = "1.60" [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true diff --git a/common/request/Cargo.toml b/common/request/Cargo.toml index 7fd69425..054e7f58 100644 --- a/common/request/Cargo.toml +++ b/common/request/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.64" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] # Deprecated here means to enable deprecated warnings, not to restore deprecated APIs hyper = { version = "0.14", default-features = false, features = ["http1", "tcp", "client", "runtime", "backports", "deprecated"] } diff --git a/common/std-shims/Cargo.toml b/common/std-shims/Cargo.toml index 3f248dc6..4861e00a 100644 --- a/common/std-shims/Cargo.toml +++ b/common/std-shims/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.70" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] spin = { version = "0.9", default-features = false, features = ["use_ticket_mutex", "once"] } hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] } diff --git a/common/zalloc/Cargo.toml b/common/zalloc/Cargo.toml index 169f08a4..1a4a6b45 100644 --- a/common/zalloc/Cargo.toml +++ b/common/zalloc/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.60" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] zeroize = { version = "^1.5", default-features = false } diff --git a/coordinator/Cargo.toml b/coordinator/Cargo.toml index cbcb3aeb..31459250 100644 --- a/coordinator/Cargo.toml +++ b/coordinator/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] async-trait = { version = "0.1", default-features = false } diff --git a/coordinator/src/cosign_evaluator.rs b/coordinator/src/cosign_evaluator.rs index 6d5b94fc..4ce7faf7 100644 --- a/coordinator/src/cosign_evaluator.rs +++ b/coordinator/src/cosign_evaluator.rs @@ -47,7 +47,7 @@ impl CosignEvaluator { // If we haven't gotten the stake data yet, return let Some(stakes) = stakes_lock.as_ref() else { return }; - let total_stake = stakes.values().cloned().sum::(); + let total_stake = stakes.values().copied().sum::(); let latest_cosigns = self.latest_cosigns.read().await; let mut highest_block = 0; @@ -319,7 +319,7 @@ impl CosignEvaluator { tokio::spawn({ async move { loop { - let cosigns = evaluator.latest_cosigns.read().await.values().cloned().collect::>(); + let cosigns = evaluator.latest_cosigns.read().await.values().copied().collect::>(); for cosign in cosigns { let mut buf = vec![]; cosign.serialize(&mut buf).unwrap(); diff --git a/coordinator/src/p2p.rs b/coordinator/src/p2p.rs index c3f27b7c..8d83b7d3 100644 --- a/coordinator/src/p2p.rs +++ b/coordinator/src/p2p.rs @@ -410,7 +410,7 @@ impl LibP2p { // If we are sending heartbeats, we should've sent one after 60s of no finalized blocks // (where a finalized block only occurs due to network activity), meaning this won't be // run - _ = tokio::time::sleep(Duration::from_secs(80).saturating_sub(time_since_last)) => { + () = tokio::time::sleep(Duration::from_secs(80).saturating_sub(time_since_last)) => { broadcast_raw( &mut swarm, &mut time_of_last_p2p_message, diff --git a/coordinator/src/tests/tributary/chain.rs b/coordinator/src/tests/tributary/chain.rs index 496f3e0d..360af7ec 100644 --- a/coordinator/src/tests/tributary/chain.rs +++ b/coordinator/src/tests/tributary/chain.rs @@ -95,7 +95,7 @@ pub async fn run_tributaries( mut tributaries: Vec<(LocalP2p, Tributary)>, ) { loop { - for (p2p, tributary) in tributaries.iter_mut() { + for (p2p, tributary) in &mut tributaries { while let Poll::Ready(msg) = poll!(p2p.receive()) { match msg.kind { P2pMessageKind::Tributary(genesis) => { @@ -170,7 +170,7 @@ async fn tributary_test() { // run_tributaries will run them ad infinitum let timeout = SystemTime::now() + Duration::from_secs(65); while (blocks < 10) && (SystemTime::now().duration_since(timeout).is_err()) { - for (p2p, tributary) in tributaries.iter_mut() { + for (p2p, tributary) in &mut tributaries { while let Poll::Ready(msg) = poll!(p2p.receive()) { match msg.kind { P2pMessageKind::Tributary(genesis) => { @@ -196,7 +196,7 @@ async fn tributary_test() { } // Handle all existing messages - for (p2p, tributary) in tributaries.iter_mut() { + for (p2p, tributary) in &mut tributaries { while let Poll::Ready(msg) = poll!(p2p.receive()) { match msg.kind { P2pMessageKind::Tributary(genesis) => { @@ -220,7 +220,7 @@ async fn tributary_test() { } assert!(tips.len() <= 2); if tips.len() == 2 { - for tip in tips.iter() { + for tip in &tips { // Find a Tributary where this isn't the tip for (_, tributary) in &tributaries { let Some(after) = tributary.reader().block_after(tip) else { continue }; diff --git a/coordinator/src/tests/tributary/dkg.rs b/coordinator/src/tests/tributary/dkg.rs index c0d6e984..446f561e 100644 --- a/coordinator/src/tests/tributary/dkg.rs +++ b/coordinator/src/tests/tributary/dkg.rs @@ -337,7 +337,7 @@ async fn dkg_test() { for (i, tx) in txs.iter().enumerate() { assert_eq!(tributaries[i].1.add_transaction(tx.clone()).await, Ok(true)); } - for tx in txs.iter() { + for tx in &txs { wait_for_tx_inclusion(&tributaries[0].1, block_before_tx, tx.hash()).await; } diff --git a/coordinator/src/tributary/db.rs b/coordinator/src/tributary/db.rs index 0aca6507..55165dda 100644 --- a/coordinator/src/tributary/db.rs +++ b/coordinator/src/tributary/db.rs @@ -127,14 +127,12 @@ impl ReattemptDb { .min(3); let upon_block = current_block_number + reattempt_delay; - #[allow(clippy::unwrap_or_default)] let mut reattempts = Self::get(txn, genesis, upon_block).unwrap_or(vec![]); reattempts.push(topic); Self::set(txn, genesis, upon_block, &reattempts); } pub fn take(txn: &mut impl DbTxn, genesis: [u8; 32], block_number: u32) -> Vec { - #[allow(clippy::unwrap_or_default)] let res = Self::get(txn, genesis, block_number).unwrap_or(vec![]); if !res.is_empty() { Self::del(txn, genesis, block_number); diff --git a/coordinator/src/tributary/handle.rs b/coordinator/src/tributary/handle.rs index 30bb661a..a7f3ea92 100644 --- a/coordinator/src/tributary/handle.rs +++ b/coordinator/src/tributary/handle.rs @@ -314,7 +314,7 @@ impl< .await; return; }; - let Ok(_) = self.check_sign_data_len(&removed, signed.signer, commitments.len()).await + let Ok(()) = self.check_sign_data_len(&removed, signed.signer, commitments.len()).await else { return; }; @@ -348,7 +348,7 @@ impl< .await; return; }; - let Ok(_) = self.check_sign_data_len(&removed, signed.signer, shares.len()).await else { + let Ok(()) = self.check_sign_data_len(&removed, signed.signer, shares.len()).await else { return; }; @@ -626,7 +626,7 @@ impl< despite us not providing that transaction", ); - for id in plan_ids.into_iter() { + for id in plan_ids { AttemptDb::recognize_topic(self.txn, genesis, Topic::Sign(id)); self .recognized_id @@ -650,7 +650,7 @@ impl< return; }; let signer = data.signed.signer; - let Ok(_) = self.check_sign_data_len(&removed, signer, data.data.len()).await else { + let Ok(()) = self.check_sign_data_len(&removed, signer, data.data.len()).await else { return; }; let expected_len = match data.label { @@ -711,7 +711,7 @@ impl< .await; return; }; - let Ok(_) = self.check_sign_data_len(&removed, data.signed.signer, data.data.len()).await + let Ok(()) = self.check_sign_data_len(&removed, data.signed.signer, data.data.len()).await else { return; }; diff --git a/coordinator/src/tributary/mod.rs b/coordinator/src/tributary/mod.rs index 5c78df88..38d9e6e9 100644 --- a/coordinator/src/tributary/mod.rs +++ b/coordinator/src/tributary/mod.rs @@ -39,7 +39,6 @@ pub fn removed_as_of_dkg_attempt( } pub fn latest_removed(getter: &impl Get, genesis: [u8; 32]) -> Vec<::G> { - #[allow(clippy::unwrap_or_default)] FatalSlashes::get(getter, genesis) .unwrap_or(vec![]) .iter() diff --git a/coordinator/src/tributary/scanner.rs b/coordinator/src/tributary/scanner.rs index c688f601..a8b9b54c 100644 --- a/coordinator/src/tributary/scanner.rs +++ b/coordinator/src/tributary/scanner.rs @@ -136,7 +136,7 @@ mod impl_pst_for_serai { signature: Signature, ) { let tx = SeraiValidatorSets::set_keys(set.network, removed, key_pair, signature); - async fn check(serai: SeraiValidatorSets<'_>, set: ValidatorSet, _: ()) -> bool { + async fn check(serai: SeraiValidatorSets<'_>, set: ValidatorSet, (): ()) -> bool { if matches!(serai.keys(set).await, Ok(Some(_))) { log::info!("another coordinator set key pair for {:?}", set); return true; @@ -293,7 +293,6 @@ impl< */ match topic { Topic::Dkg => { - #[allow(clippy::unwrap_or_default)] FatalSlashesAsOfDkgAttempt::set( self.txn, genesis, diff --git a/coordinator/src/tributary/signing_protocol.rs b/coordinator/src/tributary/signing_protocol.rs index a9df5b3c..e327ed3a 100644 --- a/coordinator/src/tributary/signing_protocol.rs +++ b/coordinator/src/tributary/signing_protocol.rs @@ -158,7 +158,7 @@ impl SigningProtocol<'_, T, C> { ) -> Result<(AlgorithmSignatureMachine, [u8; 32]), Participant> { let machine = self.preprocess_internal(participants).0; - let mut participants = serialized_preprocesses.keys().cloned().collect::>(); + let mut participants = serialized_preprocesses.keys().copied().collect::>(); participants.sort(); let mut preprocesses = HashMap::new(); for participant in participants { @@ -231,7 +231,7 @@ fn threshold_i_map_to_keys_and_musig_i_map( }; let mut sorted = vec![]; - let mut threshold_is = map.keys().cloned().collect::>(); + let mut threshold_is = map.keys().copied().collect::>(); threshold_is.sort(); for threshold_i in threshold_is { sorted.push((key_from_threshold_i(threshold_i), map.remove(&threshold_i).unwrap())); diff --git a/coordinator/tributary/Cargo.toml b/coordinator/tributary/Cargo.toml index c96c9d60..b6a5a251 100644 --- a/coordinator/tributary/Cargo.toml +++ b/coordinator/tributary/Cargo.toml @@ -7,6 +7,13 @@ repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tribut authors = ["Luke Parker "] edition = "2021" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + [dependencies] async-trait = { version = "0.1", default-features = false } thiserror = { version = "1", default-features = false } diff --git a/coordinator/tributary/src/block.rs b/coordinator/tributary/src/block.rs index d832e899..f218671c 100644 --- a/coordinator/tributary/src/block.rs +++ b/coordinator/tributary/src/block.rs @@ -207,7 +207,7 @@ impl Block { let mut last_tx_order = Order::Provided; let mut included_in_block = HashSet::new(); let mut txs = Vec::with_capacity(self.transactions.len()); - for tx in self.transactions.iter() { + for tx in &self.transactions { let tx_hash = tx.hash(); txs.push(tx_hash); diff --git a/coordinator/tributary/src/blockchain.rs b/coordinator/tributary/src/blockchain.rs index 7668de78..8b8653a9 100644 --- a/coordinator/tributary/src/blockchain.rs +++ b/coordinator/tributary/src/blockchain.rs @@ -73,7 +73,7 @@ impl Blockchain { let mut res = Self { db: Some(db.clone()), genesis, - participants: participants.iter().cloned().collect(), + participants: participants.iter().copied().collect(), block_number: 0, tip: genesis, diff --git a/coordinator/tributary/src/mempool.rs b/coordinator/tributary/src/mempool.rs index 084d1730..a723529c 100644 --- a/coordinator/tributary/src/mempool.rs +++ b/coordinator/tributary/src/mempool.rs @@ -38,7 +38,6 @@ impl Mempool { let tx_hash = tx.hash(); let transaction_key = self.transaction_key(&tx_hash); let current_mempool_key = self.current_mempool_key(); - #[allow(clippy::unwrap_or_default)] let mut current_mempool = self.db.get(¤t_mempool_key).unwrap_or(vec![]); let mut txn = self.db.txn(); @@ -182,14 +181,14 @@ impl Mempool { signer: &::G, order: Vec, ) -> Option { - self.last_nonce_in_mempool.get(&(*signer, order)).cloned().map(|nonce| nonce + 1) + self.last_nonce_in_mempool.get(&(*signer, order)).copied().map(|nonce| nonce + 1) } /// Get transactions to include in a block. pub(crate) fn block(&mut self) -> Vec> { let mut unsigned = vec![]; let mut signed = vec![]; - for hash in self.txs.keys().cloned().collect::>() { + for hash in self.txs.keys().copied().collect::>() { let tx = &self.txs[&hash]; match tx.kind() { @@ -222,7 +221,6 @@ impl Mempool { pub(crate) fn remove(&mut self, tx: &[u8; 32]) { let transaction_key = self.transaction_key(tx); let current_mempool_key = self.current_mempool_key(); - #[allow(clippy::unwrap_or_default)] let current_mempool = self.db.get(¤t_mempool_key).unwrap_or(vec![]); let mut i = 0; diff --git a/coordinator/tributary/src/provided.rs b/coordinator/tributary/src/provided.rs index 82212016..42e1e6ae 100644 --- a/coordinator/tributary/src/provided.rs +++ b/coordinator/tributary/src/provided.rs @@ -136,7 +136,6 @@ impl ProvidedTransactions { } txn.commit(); } else { - #[allow(clippy::unwrap_or_default)] let mut currently_provided = txn.get(¤t_provided_key).unwrap_or(vec![]); currently_provided.extend(tx_hash); txn.put(current_provided_key, currently_provided); diff --git a/coordinator/tributary/tendermint/Cargo.toml b/coordinator/tributary/tendermint/Cargo.toml index 19a6da4f..ba640391 100644 --- a/coordinator/tributary/tendermint/Cargo.toml +++ b/coordinator/tributary/tendermint/Cargo.toml @@ -7,6 +7,13 @@ repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tender authors = ["Luke Parker "] edition = "2021" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + [dependencies] async-trait = { version = "0.1", default-features = false } thiserror = { version = "1", default-features = false } diff --git a/coordinator/tributary/tendermint/src/lib.rs b/coordinator/tributary/tendermint/src/lib.rs index 54c3795a..188849e8 100644 --- a/coordinator/tributary/tendermint/src/lib.rs +++ b/coordinator/tributary/tendermint/src/lib.rs @@ -30,7 +30,7 @@ pub mod ext; use ext::*; pub fn commit_msg(end_time: u64, id: &[u8]) -> Vec { - [&end_time.to_le_bytes(), id].concat().to_vec() + [&end_time.to_le_bytes(), id].concat() } #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode)] @@ -398,7 +398,7 @@ impl TendermintMachine { }, // Handle our messages - _ = queue_future => { + () = queue_future => { Some((true, self.queue.pop_front().unwrap(), None)) }, @@ -752,7 +752,7 @@ impl TendermintMachine { if self.block.round().step == Step::Propose { // Delay error handling (triggering a slash) until after we vote. let (valid, err) = match self.network.validate(block).await { - Ok(_) => (true, Ok(None)), + Ok(()) => (true, Ok(None)), Err(BlockError::Temporal) => (false, Ok(None)), Err(BlockError::Fatal) => (false, { log::warn!(target: "tendermint", "Validator proposed a fatally invalid block"); @@ -812,7 +812,7 @@ impl TendermintMachine { if self.block.log.has_consensus(self.block.round().number, Data::Prevote(Some(block.id()))) { match self.network.validate(block).await { - Ok(_) => (), + Ok(()) => (), // BlockError::Temporal is due to a temporal error we have, yet a supermajority of the // network does not, Because we do not believe this block to be fatally invalid, and // because a supermajority deems it valid, accept it. diff --git a/coordinator/tributary/tendermint/src/message_log.rs b/coordinator/tributary/tendermint/src/message_log.rs index 4af1fd1c..f663dfc8 100644 --- a/coordinator/tributary/tendermint/src/message_log.rs +++ b/coordinator/tributary/tendermint/src/message_log.rs @@ -21,9 +21,7 @@ impl MessageLog { pub(crate) fn log(&mut self, signed: SignedMessageFor) -> Result> { let msg = &signed.msg; // Clarity, and safety around default != new edge cases - #[allow(clippy::unwrap_or_default)] let round = self.log.entry(msg.round).or_insert_with(HashMap::new); - #[allow(clippy::unwrap_or_default)] let msgs = round.entry(msg.sender).or_insert_with(HashMap::new); // Handle message replays without issue. It's only multiple messages which is malicious diff --git a/crypto/ciphersuite/Cargo.toml b/crypto/ciphersuite/Cargo.toml index 4641e59f..d6fe7922 100644 --- a/crypto/ciphersuite/Cargo.toml +++ b/crypto/ciphersuite/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false, optional = true } diff --git a/crypto/dalek-ff-group/Cargo.toml b/crypto/dalek-ff-group/Cargo.toml index 50c4abcf..0fe4bce0 100644 --- a/crypto/dalek-ff-group/Cargo.toml +++ b/crypto/dalek-ff-group/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.65" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rustversion = "1" diff --git a/crypto/dalek-ff-group/src/lib.rs b/crypto/dalek-ff-group/src/lib.rs index a88ef306..dcbcacc0 100644 --- a/crypto/dalek-ff-group/src/lib.rs +++ b/crypto/dalek-ff-group/src/lib.rs @@ -50,6 +50,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 { let bit_ref = black_box(bit_ref); let mut bit = black_box(*bit_ref); + #[allow(clippy::cast_lossless)] let res = black_box(bit as u8); bit.zeroize(); debug_assert!((res | 1) == 1); diff --git a/crypto/dkg/Cargo.toml b/crypto/dkg/Cargo.toml index 0eb3f541..a8d3f0a8 100644 --- a/crypto/dkg/Cargo.toml +++ b/crypto/dkg/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.70" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] thiserror = { version = "1", default-features = false, optional = true } diff --git a/crypto/dkg/src/encryption.rs b/crypto/dkg/src/encryption.rs index 4d68929c..8c5d8612 100644 --- a/crypto/dkg/src/encryption.rs +++ b/crypto/dkg/src/encryption.rs @@ -226,7 +226,7 @@ impl EncryptedMessage { use ciphersuite::group::ff::PrimeField; let mut repr = ::Repr::default(); - for b in repr.as_mut().iter_mut() { + for b in repr.as_mut() { *b = 255; } // Tries to guarantee the above assumption. diff --git a/crypto/dkg/src/lib.rs b/crypto/dkg/src/lib.rs index eb915e23..77a3bdbe 100644 --- a/crypto/dkg/src/lib.rs +++ b/crypto/dkg/src/lib.rs @@ -257,7 +257,7 @@ mod lib { self.params.zeroize(); self.secret_share.zeroize(); self.group_key.zeroize(); - for (_, share) in self.verification_shares.iter_mut() { + for share in self.verification_shares.values_mut() { share.zeroize(); } } @@ -410,10 +410,10 @@ mod lib { self.group_key.zeroize(); self.included.zeroize(); self.secret_share.zeroize(); - for (_, share) in self.original_verification_shares.iter_mut() { + for share in self.original_verification_shares.values_mut() { share.zeroize(); } - for (_, share) in self.verification_shares.iter_mut() { + for share in self.verification_shares.values_mut() { share.zeroize(); } } @@ -484,7 +484,7 @@ mod lib { ); let mut verification_shares = self.verification_shares(); - for (i, share) in verification_shares.iter_mut() { + for (i, share) in &mut verification_shares { *share *= lagrange::(*i, &included); } diff --git a/crypto/dleq/Cargo.toml b/crypto/dleq/Cargo.toml index 5afe03b3..7d8c87e9 100644 --- a/crypto/dleq/Cargo.toml +++ b/crypto/dleq/Cargo.toml @@ -12,6 +12,9 @@ rust-version = "1.73" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rustversion = "1" diff --git a/crypto/dleq/src/cross_group/aos.rs b/crypto/dleq/src/cross_group/aos.rs index 4cba3c89..5a32bf13 100644 --- a/crypto/dleq/src/cross_group/aos.rs +++ b/crypto/dleq/src/cross_group/aos.rs @@ -240,7 +240,7 @@ where } let mut s = [(G0::Scalar::ZERO, G1::Scalar::ZERO); RING_LEN]; - for s in s.iter_mut() { + for s in &mut s { *s = (read_scalar(r)?, read_scalar(r)?); } diff --git a/crypto/dleq/src/cross_group/bits.rs b/crypto/dleq/src/cross_group/bits.rs index 1995fad1..d818abce 100644 --- a/crypto/dleq/src/cross_group/bits.rs +++ b/crypto/dleq/src/cross_group/bits.rs @@ -45,7 +45,7 @@ impl BitSignature { } } - pub(crate) const fn bits(&self) -> usize { + pub(crate) const fn bits(&self) -> u8 { match self { BitSignature::ClassicLinear => 1, BitSignature::ConciseLinear => 2, diff --git a/crypto/dleq/src/cross_group/mod.rs b/crypto/dleq/src/cross_group/mod.rs index 17264866..de8256cf 100644 --- a/crypto/dleq/src/cross_group/mod.rs +++ b/crypto/dleq/src/cross_group/mod.rs @@ -42,6 +42,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 { let bit_ref = black_box(bit_ref); let mut bit = black_box(*bit_ref); + #[allow(clippy::cast_lossless)] let res = black_box(bit as u8); bit.zeroize(); debug_assert!((res | 1) == 1); @@ -278,7 +279,7 @@ where }; let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap(); - let bits_per_group = BitSignature::from(SIGNATURE).bits(); + let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits()); let mut pow_2 = (generators.0.primary, generators.1.primary); @@ -391,7 +392,7 @@ where generators: (Generators, Generators), ) -> Result<(G0, G1), DLEqError> { let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap(); - let bits_per_group = BitSignature::from(SIGNATURE).bits(); + let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits()); let has_remainder = (capacity % bits_per_group) != 0; // These shouldn't be possible, as locally created and deserialized proofs should be properly @@ -449,7 +450,7 @@ where #[cfg(feature = "serialize")] pub fn read(r: &mut R) -> io::Result { let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap(); - let bits_per_group = BitSignature::from(SIGNATURE).bits(); + let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits()); let mut bits = Vec::with_capacity(capacity / bits_per_group); for _ in 0 .. (capacity / bits_per_group) { diff --git a/crypto/dleq/src/cross_group/scalar.rs b/crypto/dleq/src/cross_group/scalar.rs index 1b8eb4e5..d57991b9 100644 --- a/crypto/dleq/src/cross_group/scalar.rs +++ b/crypto/dleq/src/cross_group/scalar.rs @@ -29,7 +29,7 @@ pub fn scalar_normalize( let mut skip = bits.len() - usize::try_from(mutual_capacity).unwrap(); // Needed to zero out the bits #[allow(unused_assignments)] - for mut bit in bits.iter_mut() { + for mut bit in &mut bits { if skip > 0 { bit.deref_mut().zeroize(); skip -= 1; diff --git a/crypto/ed448/Cargo.toml b/crypto/ed448/Cargo.toml index ce8f0f5e..2302d7b3 100644 --- a/crypto/ed448/Cargo.toml +++ b/crypto/ed448/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.65" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rustversion = "1" diff --git a/crypto/ed448/src/backend.rs b/crypto/ed448/src/backend.rs index ad2d571f..00f87a1c 100644 --- a/crypto/ed448/src/backend.rs +++ b/crypto/ed448/src/backend.rs @@ -12,6 +12,7 @@ pub(crate) fn u8_from_bool(bit_ref: &mut bool) -> u8 { let bit_ref = black_box(bit_ref); let mut bit = black_box(*bit_ref); + #[allow(clippy::cast_lossless)] let res = black_box(bit as u8); bit.zeroize(); debug_assert!((res | 1) == 1); diff --git a/crypto/ed448/src/point.rs b/crypto/ed448/src/point.rs index 3ea70b85..c3b10f79 100644 --- a/crypto/ed448/src/point.rs +++ b/crypto/ed448/src/point.rs @@ -214,7 +214,7 @@ impl Sum for Point { impl<'a> Sum<&'a Point> for Point { fn sum>(iter: I) -> Point { - Point::sum(iter.cloned()) + Point::sum(iter.copied()) } } diff --git a/crypto/ff-group-tests/Cargo.toml b/crypto/ff-group-tests/Cargo.toml index 641e5da8..bb55d5a1 100644 --- a/crypto/ff-group-tests/Cargo.toml +++ b/crypto/ff-group-tests/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.60" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rand_core = "0.6" diff --git a/crypto/frost/Cargo.toml b/crypto/frost/Cargo.toml index 8ba3ef6e..128a3667 100644 --- a/crypto/frost/Cargo.toml +++ b/crypto/frost/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] thiserror = "1" diff --git a/crypto/frost/src/algorithm.rs b/crypto/frost/src/algorithm.rs index 073b483f..59aa2dd9 100644 --- a/crypto/frost/src/algorithm.rs +++ b/crypto/frost/src/algorithm.rs @@ -184,7 +184,7 @@ impl> Algorithm fo &mut self, _: &ThresholdView, _: Participant, - _: (), + (): (), ) -> Result<(), FrostError> { Ok(()) } diff --git a/crypto/frost/src/nonce.rs b/crypto/frost/src/nonce.rs index 921480a0..8638baff 100644 --- a/crypto/frost/src/nonce.rs +++ b/crypto/frost/src/nonce.rs @@ -256,7 +256,7 @@ impl BindingFactor { } pub(crate) fn calculate_binding_factors(&mut self, transcript: &T) { - for (l, binding) in self.0.iter_mut() { + for (l, binding) in &mut self.0 { let mut transcript = transcript.clone(); transcript.append_message(b"participant", C::F::from(u64::from(u16::from(*l))).to_repr()); // It *should* be perfectly fine to reuse a binding factor for multiple nonces diff --git a/crypto/frost/src/tests/mod.rs b/crypto/frost/src/tests/mod.rs index 7e1c0acf..2659c1c7 100644 --- a/crypto/frost/src/tests/mod.rs +++ b/crypto/frost/src/tests/mod.rs @@ -177,7 +177,7 @@ pub fn sign( machines, |rng, machines| { // Cache and rebuild half of the machines - let included = machines.keys().cloned().collect::>(); + let included = machines.keys().copied().collect::>(); for i in included { if (rng.next_u64() % 2) == 0 { let cache = machines.remove(&i).unwrap().cache(); diff --git a/crypto/frost/src/tests/nonces.rs b/crypto/frost/src/tests/nonces.rs index 8031013c..99be83ff 100644 --- a/crypto/frost/src/tests/nonces.rs +++ b/crypto/frost/src/tests/nonces.rs @@ -82,7 +82,7 @@ impl Algorithm for MultiNonce { &mut self, _: &ThresholdView, _: Participant, - _: (), + (): (), ) -> Result<(), FrostError> { Ok(()) } diff --git a/crypto/multiexp/Cargo.toml b/crypto/multiexp/Cargo.toml index 2bc9ece5..95dcebaa 100644 --- a/crypto/multiexp/Cargo.toml +++ b/crypto/multiexp/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.70" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rustversion = "1" diff --git a/crypto/multiexp/src/lib.rs b/crypto/multiexp/src/lib.rs index 191977b6..8d619b61 100644 --- a/crypto/multiexp/src/lib.rs +++ b/crypto/multiexp/src/lib.rs @@ -38,6 +38,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 { let bit_ref = black_box(bit_ref); let mut bit = black_box(*bit_ref); + #[allow(clippy::cast_lossless)] let res = black_box(bit as u8); bit.zeroize(); debug_assert!((res | 1) == 1); diff --git a/crypto/schnorr/Cargo.toml b/crypto/schnorr/Cargo.toml index 06abd571..91f8722b 100644 --- a/crypto/schnorr/Cargo.toml +++ b/crypto/schnorr/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false } diff --git a/crypto/schnorrkel/Cargo.toml b/crypto/schnorrkel/Cargo.toml index 46df8f20..f5819070 100644 --- a/crypto/schnorrkel/Cargo.toml +++ b/crypto/schnorrkel/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rand_core = "0.6" zeroize = "^1.5" diff --git a/crypto/schnorrkel/src/lib.rs b/crypto/schnorrkel/src/lib.rs index 7d3b3333..bb46bc02 100644 --- a/crypto/schnorrkel/src/lib.rs +++ b/crypto/schnorrkel/src/lib.rs @@ -99,7 +99,7 @@ impl Algorithm for Schnorrkel { &mut self, _: &ThresholdView, _: Participant, - _: (), + (): (), ) -> Result<(), FrostError> { Ok(()) } diff --git a/crypto/transcript/Cargo.toml b/crypto/transcript/Cargo.toml index 920fb22f..566ad56b 100644 --- a/crypto/transcript/Cargo.toml +++ b/crypto/transcript/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.73" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rustversion = "1" diff --git a/message-queue/Cargo.toml b/message-queue/Cargo.toml index b775d6a9..95970163 100644 --- a/message-queue/Cargo.toml +++ b/message-queue/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] # Macros once_cell = { version = "1", default-features = false } diff --git a/message-queue/src/client.rs b/message-queue/src/client.rs index e46987b6..e1068082 100644 --- a/message-queue/src/client.rs +++ b/message-queue/src/client.rs @@ -67,10 +67,10 @@ impl MessageQueue { #[must_use] async fn send(socket: &mut TcpStream, msg: MessageQueueRequest) -> bool { let msg = borsh::to_vec(&msg).unwrap(); - let Ok(_) = socket.write_all(&u32::try_from(msg.len()).unwrap().to_le_bytes()).await else { + let Ok(()) = socket.write_all(&u32::try_from(msg.len()).unwrap().to_le_bytes()).await else { return false; }; - let Ok(_) = socket.write_all(&msg).await else { return false }; + let Ok(()) = socket.write_all(&msg).await else { return false }; true } diff --git a/message-queue/src/main.rs b/message-queue/src/main.rs index 80fe604c..94e89a3f 100644 --- a/message-queue/src/main.rs +++ b/message-queue/src/main.rs @@ -250,18 +250,18 @@ async fn main() { msg, SchnorrSignature::::read(&mut sig.as_slice()).unwrap(), ); - let Ok(_) = socket.write_all(&[1]).await else { break }; + let Ok(()) = socket.write_all(&[1]).await else { break }; } MessageQueueRequest::Next { from, to } => match get_next_message(from, to) { Some(msg) => { - let Ok(_) = socket.write_all(&[1]).await else { break }; + let Ok(()) = socket.write_all(&[1]).await else { break }; let msg = borsh::to_vec(&msg).unwrap(); let len = u32::try_from(msg.len()).unwrap(); - let Ok(_) = socket.write_all(&len.to_le_bytes()).await else { break }; - let Ok(_) = socket.write_all(&msg).await else { break }; + let Ok(()) = socket.write_all(&len.to_le_bytes()).await else { break }; + let Ok(()) = socket.write_all(&msg).await else { break }; } None => { - let Ok(_) = socket.write_all(&[0]).await else { break }; + let Ok(()) = socket.write_all(&[0]).await else { break }; } }, MessageQueueRequest::Ack { from, to, id, sig } => { @@ -271,7 +271,7 @@ async fn main() { id, SchnorrSignature::::read(&mut sig.as_slice()).unwrap(), ); - let Ok(_) = socket.write_all(&[1]).await else { break }; + let Ok(()) = socket.write_all(&[1]).await else { break }; } } } diff --git a/mini/Cargo.toml b/mini/Cargo.toml index fc0abf8a..dfef7e56 100644 --- a/mini/Cargo.toml +++ b/mini/Cargo.toml @@ -13,5 +13,8 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] loom = "0.7" diff --git a/processor/Cargo.toml b/processor/Cargo.toml index 6bcb37b1..e3c28477 100644 --- a/processor/Cargo.toml +++ b/processor/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] # Macros async-trait = { version = "0.1", default-features = false } diff --git a/processor/messages/Cargo.toml b/processor/messages/Cargo.toml index 951ea974..0eba999d 100644 --- a/processor/messages/Cargo.toml +++ b/processor/messages/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std"] } borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] } diff --git a/processor/src/batch_signer.rs b/processor/src/batch_signer.rs index 003397ef..d4f662b1 100644 --- a/processor/src/batch_signer.rs +++ b/processor/src/batch_signer.rs @@ -234,7 +234,7 @@ impl BatchSigner { let mut parsed = HashMap::new(); for l in { - let mut keys = preprocesses.keys().cloned().collect::>(); + let mut keys = preprocesses.keys().copied().collect::>(); keys.sort(); keys } { @@ -329,7 +329,7 @@ impl BatchSigner { let mut parsed = HashMap::new(); for l in { - let mut keys = shares.keys().cloned().collect::>(); + let mut keys = shares.keys().copied().collect::>(); keys.sort(); keys } { diff --git a/processor/src/cosigner.rs b/processor/src/cosigner.rs index d53593ab..c5c49567 100644 --- a/processor/src/cosigner.rs +++ b/processor/src/cosigner.rs @@ -150,7 +150,7 @@ impl Cosigner { let mut parsed = HashMap::new(); for l in { - let mut keys = preprocesses.keys().cloned().collect::>(); + let mut keys = preprocesses.keys().copied().collect::>(); keys.sort(); keys } { @@ -241,7 +241,7 @@ impl Cosigner { let mut parsed = HashMap::new(); for l in { - let mut keys = shares.keys().cloned().collect::>(); + let mut keys = shares.keys().copied().collect::>(); keys.sort(); keys } { diff --git a/processor/src/key_gen.rs b/processor/src/key_gen.rs index 1a35f4d2..b81ba7b5 100644 --- a/processor/src/key_gen.rs +++ b/processor/src/key_gen.rs @@ -305,7 +305,7 @@ impl KeyGen { let mut these_shares: HashMap<_, _> = substrate_shares.drain().map(|(i, share)| (i, share.serialize())).collect(); - for (i, share) in these_shares.iter_mut() { + for (i, share) in &mut these_shares { share.extend(network_shares[i].serialize()); } shares.push(these_shares); diff --git a/processor/src/multisigs/db.rs b/processor/src/multisigs/db.rs index 0a5fbbf0..b5bb643b 100644 --- a/processor/src/multisigs/db.rs +++ b/processor/src/multisigs/db.rs @@ -113,7 +113,7 @@ impl ResolvedDb { let end = i + 32; if signing[start .. end] == plan { found = true; - signing = [&signing[.. start], &signing[end ..]].concat().to_vec(); + signing = [&signing[.. start], &signing[end ..]].concat(); break; } } diff --git a/processor/src/multisigs/mod.rs b/processor/src/multisigs/mod.rs index 264c373f..8af38646 100644 --- a/processor/src/multisigs/mod.rs +++ b/processor/src/multisigs/mod.rs @@ -198,12 +198,12 @@ impl MultisigManager { ( MultisigManager { scanner, - existing: current_keys.first().cloned().map(|(activation_block, key)| MultisigViewer { + existing: current_keys.first().copied().map(|(activation_block, key)| MultisigViewer { activation_block, key, scheduler: schedulers.remove(0), }), - new: current_keys.get(1).cloned().map(|(activation_block, key)| MultisigViewer { + new: current_keys.get(1).copied().map(|(activation_block, key)| MultisigViewer { activation_block, key, scheduler: schedulers.remove(0), diff --git a/processor/src/multisigs/scanner.rs b/processor/src/multisigs/scanner.rs index f25867e7..20f1ced1 100644 --- a/processor/src/multisigs/scanner.rs +++ b/processor/src/multisigs/scanner.rs @@ -484,7 +484,7 @@ impl Scanner { let needing_ack = { let scanner_lock = scanner_hold.read().await; let scanner = scanner_lock.as_ref().unwrap(); - scanner.need_ack.front().cloned() + scanner.need_ack.front().copied() }; if let Some(needing_ack) = needing_ack { diff --git a/processor/src/multisigs/scheduler.rs b/processor/src/multisigs/scheduler.rs index 4a7d980d..41c371b9 100644 --- a/processor/src/multisigs/scheduler.rs +++ b/processor/src/multisigs/scheduler.rs @@ -197,7 +197,6 @@ impl Scheduler { let mut add_plan = |payments| { let amount = payment_amounts(&payments); - #[allow(clippy::unwrap_or_default)] self.queued_plans.entry(amount).or_insert(VecDeque::new()).push_back(payments); amount }; @@ -474,7 +473,7 @@ impl Scheduler { let per_payment = to_amortize / payments_len; let mut overage = to_amortize % payments_len; - for payment in payments.iter_mut() { + for payment in &mut payments { let to_subtract = per_payment + overage; // Only subtract the overage once overage = 0; @@ -499,7 +498,6 @@ impl Scheduler { return; } - #[allow(clippy::unwrap_or_default)] self.plans.entry(actual).or_insert(VecDeque::new()).push_back(payments); // TODO2: This shows how ridiculous the serialize function is diff --git a/processor/src/networks/bitcoin.rs b/processor/src/networks/bitcoin.rs index a4c8c89e..bae189f9 100644 --- a/processor/src/networks/bitcoin.rs +++ b/processor/src/networks/bitcoin.rs @@ -383,7 +383,7 @@ impl Bitcoin { } } fees.sort(); - let fee = fees.get(fees.len() / 2).cloned().unwrap_or(0); + let fee = fees.get(fees.len() / 2).copied().unwrap_or(0); // The DUST constant documentation notes a relay rule practically enforcing a // 1000 sat/kilo-vbyte minimum fee. diff --git a/processor/src/networks/monero.rs b/processor/src/networks/monero.rs index d2ac279d..92b502fc 100644 --- a/processor/src/networks/monero.rs +++ b/processor/src/networks/monero.rs @@ -285,7 +285,7 @@ impl Monero { fees.push(tx.rct_signatures.base.fee / u64::try_from(tx.serialize().len()).unwrap()); } fees.sort(); - let fee = fees.get(fees.len() / 2).cloned().unwrap_or(0); + let fee = fees.get(fees.len() / 2).copied().unwrap_or(0); // TODO: Set a sane minimum fee Ok(Fee { per_weight: fee.max(1500000), mask: 10000 }) @@ -665,7 +665,7 @@ impl Network for Monero { async fn publish_transaction(&self, tx: &Self::Transaction) -> Result<(), NetworkError> { match self.rpc.publish_transaction(tx).await { - Ok(_) => Ok(()), + Ok(()) => Ok(()), Err(RpcError::ConnectionError(e)) => { log::debug!("Monero ConnectionError: {e}"); Err(NetworkError::ConnectionError)? diff --git a/processor/src/signer.rs b/processor/src/signer.rs index 57c63fcd..a1c4303b 100644 --- a/processor/src/signer.rs +++ b/processor/src/signer.rs @@ -469,7 +469,7 @@ impl Signer { let mut parsed = HashMap::new(); for l in { - let mut keys = preprocesses.keys().cloned().collect::>(); + let mut keys = preprocesses.keys().copied().collect::>(); keys.sort(); keys } { @@ -549,7 +549,7 @@ impl Signer { let mut parsed = HashMap::new(); for l in { - let mut keys = shares.keys().cloned().collect::>(); + let mut keys = shares.keys().copied().collect::>(); keys.sort(); keys } { diff --git a/processor/src/tests/addresses.rs b/processor/src/tests/addresses.rs index 8d7baa9e..da20091b 100644 --- a/processor/src/tests/addresses.rs +++ b/processor/src/tests/addresses.rs @@ -78,7 +78,7 @@ async fn spend( pub async fn test_addresses(network: N) { let mut keys = frost::tests::key_gen::<_, N::Curve>(&mut OsRng); - for (_, keys) in keys.iter_mut() { + for keys in keys.values_mut() { N::tweak_keys(keys); } let key = keys[&Participant::new(1).unwrap()].group_key(); diff --git a/processor/src/tests/scanner.rs b/processor/src/tests/scanner.rs index 39e24930..ee616b7c 100644 --- a/processor/src/tests/scanner.rs +++ b/processor/src/tests/scanner.rs @@ -109,7 +109,7 @@ pub async fn test_no_deadlock_in_multisig_completed(network: N) { network.get_latest_block_number().await.unwrap() + N::CONFIRMATIONS + i, { let mut keys = key_gen(&mut OsRng); - for (_, keys) in keys.iter_mut() { + for keys in keys.values_mut() { N::tweak_keys(keys); } keys[&Participant::new(1).unwrap()].group_key() diff --git a/processor/src/tests/signer.rs b/processor/src/tests/signer.rs index 9f76ae85..8eacb9ae 100644 --- a/processor/src/tests/signer.rs +++ b/processor/src/tests/signer.rs @@ -147,7 +147,7 @@ pub async fn sign( pub async fn test_signer(network: N) { let mut keys = key_gen(&mut OsRng); - for (_, keys) in keys.iter_mut() { + for keys in keys.values_mut() { N::tweak_keys(keys); } let key = keys[&Participant::new(1).unwrap()].group_key(); diff --git a/processor/src/tests/wallet.rs b/processor/src/tests/wallet.rs index 74a6dd54..c9cc6c66 100644 --- a/processor/src/tests/wallet.rs +++ b/processor/src/tests/wallet.rs @@ -31,7 +31,7 @@ pub async fn test_wallet(network: N) { } let mut keys = key_gen(&mut OsRng); - for (_, keys) in keys.iter_mut() { + for keys in keys.values_mut() { N::tweak_keys(keys); } let key = keys[&Participant::new(1).unwrap()].group_key(); diff --git a/substrate/abi/Cargo.toml b/substrate/abi/Cargo.toml index fa235d0c..04350486 100644 --- a/substrate/abi/Cargo.toml +++ b/substrate/abi/Cargo.toml @@ -12,6 +12,9 @@ rust-version = "1.69" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] scale = { package = "parity-scale-codec", version = "3", features = ["derive"] } scale-info = { version = "2", features = ["derive"] } diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index bf81622e..e73b8ddc 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -13,6 +13,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] zeroize = "^1.5" thiserror = { version = "1", optional = true } diff --git a/substrate/client/src/serai/mod.rs b/substrate/client/src/serai/mod.rs index be9b0cff..0504be7e 100644 --- a/substrate/client/src/serai/mod.rs +++ b/substrate/client/src/serai/mod.rs @@ -317,7 +317,6 @@ impl<'a> TemporalSerai<'a> { if events.is_none() { drop(events); let mut events_write = self.events.write().await; - #[allow(clippy::unwrap_or_default)] if events_write.is_none() { *events_write = Some(self.storage("System", "Events", ()).await?.unwrap_or(vec![])); } diff --git a/substrate/coins/pallet/Cargo.toml b/substrate/coins/pallet/Cargo.toml index c05dc9fd..75011add 100644 --- a/substrate/coins/pallet/Cargo.toml +++ b/substrate/coins/pallet/Cargo.toml @@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-machete] ignored = ["scale", "scale-info"] +[lints] +workspace = true + [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2", default-features = false, features = ["derive"] } diff --git a/substrate/coins/pallet/src/lib.rs b/substrate/coins/pallet/src/lib.rs index b2a83eaf..32d75bc0 100644 --- a/substrate/coins/pallet/src/lib.rs +++ b/substrate/coins/pallet/src/lib.rs @@ -12,6 +12,7 @@ impl AllowMint for () { } } +#[allow(clippy::cast_possible_truncation)] // TODO: Investigate why Substrate generates this #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/substrate/coins/primitives/Cargo.toml b/substrate/coins/primitives/Cargo.toml index 8117bb8b..322016da 100644 --- a/substrate/coins/primitives/Cargo.toml +++ b/substrate/coins/primitives/Cargo.toml @@ -11,6 +11,9 @@ rust-version = "1.69" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] zeroize = { version = "^1.5", features = ["derive"], optional = true } diff --git a/substrate/dex/pallet/Cargo.toml b/substrate/dex/pallet/Cargo.toml index a3cb1a97..83192d6e 100644 --- a/substrate/dex/pallet/Cargo.toml +++ b/substrate/dex/pallet/Cargo.toml @@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-machete] ignored = ["scale", "scale-info"] +[lints] +workspace = true + [dependencies] scale = { package = "parity-scale-codec", version = "3.6.1", default-features = false } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } diff --git a/substrate/dex/pallet/src/lib.rs b/substrate/dex/pallet/src/lib.rs index 92857945..e079a58f 100644 --- a/substrate/dex/pallet/src/lib.rs +++ b/substrate/dex/pallet/src/lib.rs @@ -94,6 +94,7 @@ use sp_std::prelude::*; pub use types::*; pub use weights::WeightInfo; +#[allow(clippy::cast_possible_truncation)] // TODO: Investigate why Substrate generates this #[frame_support::pallet] pub mod pallet { use super::*; @@ -751,7 +752,7 @@ pub mod pallet { )?; let mut i = 0; - let path_len = path.len() as u32; + let path_len = u32::try_from(path.len()).unwrap(); #[allow(clippy::explicit_counter_loop)] for coins_pair in path.windows(2) { if let [coin1, coin2] = coins_pair { diff --git a/substrate/in-instructions/pallet/Cargo.toml b/substrate/in-instructions/pallet/Cargo.toml index 2416b291..f313a22a 100644 --- a/substrate/in-instructions/pallet/Cargo.toml +++ b/substrate/in-instructions/pallet/Cargo.toml @@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-machete] ignored = ["scale", "scale-info"] +[lints] +workspace = true + [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2", default-features = false, features = ["derive"] } diff --git a/substrate/in-instructions/pallet/src/lib.rs b/substrate/in-instructions/pallet/src/lib.rs index 1bf010a8..c9b339a3 100644 --- a/substrate/in-instructions/pallet/src/lib.rs +++ b/substrate/in-instructions/pallet/src/lib.rs @@ -9,6 +9,7 @@ use serai_primitives::{BlockHash, NetworkId}; pub use in_instructions_primitives as primitives; use primitives::*; +#[allow(clippy::cast_possible_truncation)] // TODO: Investigate why Substrate generates this #[frame_support::pallet] pub mod pallet { use sp_std::vec; diff --git a/substrate/in-instructions/primitives/Cargo.toml b/substrate/in-instructions/primitives/Cargo.toml index f7cadccb..f579f59d 100644 --- a/substrate/in-instructions/primitives/Cargo.toml +++ b/substrate/in-instructions/primitives/Cargo.toml @@ -11,6 +11,9 @@ rust-version = "1.69" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] zeroize = { version = "^1.5", features = ["derive"], optional = true } diff --git a/substrate/node/Cargo.toml b/substrate/node/Cargo.toml index 5d34fa9b..8f99c5e7 100644 --- a/substrate/node/Cargo.toml +++ b/substrate/node/Cargo.toml @@ -9,6 +9,13 @@ edition = "2021" publish = false rust-version = "1.74" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + [[bin]] name = "serai-node" diff --git a/substrate/node/src/service.rs b/substrate/node/src/service.rs index 54eed109..69445543 100644 --- a/substrate/node/src/service.rs +++ b/substrate/node/src/service.rs @@ -124,7 +124,7 @@ pub fn new_partial(config: &Configuration) -> Result Result> for IdentityValidatorIdOf { impl signals::Config for Runtime { type RuntimeEvent = RuntimeEvent; // 1 week + #[allow(clippy::cast_possible_truncation)] type RetirementValidityDuration = ConstU32<{ (7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; // 2 weeks + #[allow(clippy::cast_possible_truncation)] type RetirementLockInDuration = ConstU32<{ (2 * 7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; } diff --git a/substrate/signals/pallet/Cargo.toml b/substrate/signals/pallet/Cargo.toml index d12490c2..582a3e09 100644 --- a/substrate/signals/pallet/Cargo.toml +++ b/substrate/signals/pallet/Cargo.toml @@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-machete] ignored = ["scale", "scale-info"] +[lints] +workspace = true + [dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2", default-features = false, features = ["derive"] } diff --git a/substrate/signals/pallet/src/lib.rs b/substrate/signals/pallet/src/lib.rs index 07f28448..60fb35b1 100644 --- a/substrate/signals/pallet/src/lib.rs +++ b/substrate/signals/pallet/src/lib.rs @@ -1,6 +1,11 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[allow(deprecated, clippy::let_unit_value)] // TODO +#[allow( + deprecated, + clippy::let_unit_value, + clippy::cast_possible_truncation, + clippy::ignored_unit_patterns +)] // TODO #[frame_support::pallet] pub mod pallet { use scale_info::TypeInfo; diff --git a/substrate/signals/primitives/Cargo.toml b/substrate/signals/primitives/Cargo.toml index 7e8f41bb..1c338145 100644 --- a/substrate/signals/primitives/Cargo.toml +++ b/substrate/signals/primitives/Cargo.toml @@ -12,6 +12,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] zeroize = { version = "^1.5", features = ["derive"], optional = true } diff --git a/substrate/validator-sets/pallet/Cargo.toml b/substrate/validator-sets/pallet/Cargo.toml index 06365875..3b553788 100644 --- a/substrate/validator-sets/pallet/Cargo.toml +++ b/substrate/validator-sets/pallet/Cargo.toml @@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-machete] ignored = ["scale", "scale-info"] +[lints] +workspace = true + [dependencies] hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] } diff --git a/substrate/validator-sets/pallet/src/lib.rs b/substrate/validator-sets/pallet/src/lib.rs index 132b4364..8707fbe1 100644 --- a/substrate/validator-sets/pallet/src/lib.rs +++ b/substrate/validator-sets/pallet/src/lib.rs @@ -53,11 +53,16 @@ impl GetValidatorCount for MembershipProof { // rely on it and Substrate only relies on it to offer economic calculations we also don't rely // on fn validator_count(&self) -> u32 { - Babe::::authorities().len() as u32 + u32::try_from(Babe::::authorities().len()).unwrap() } } -#[allow(deprecated, clippy::let_unit_value)] // TODO +#[allow( + deprecated, + clippy::let_unit_value, + clippy::cast_possible_truncation, + clippy::ignored_unit_patterns +)] // TODO #[frame_support::pallet] pub mod pallet { use super::*; @@ -717,7 +722,7 @@ pub mod pallet { None, ), WeakBoundedVec::force_from( - next_validators.iter().cloned().map(|(id, w)| (BabeAuthorityId::from(id), w)).collect(), + next_validators.iter().copied().map(|(id, w)| (BabeAuthorityId::from(id), w)).collect(), None, ), Some(session), diff --git a/substrate/validator-sets/primitives/Cargo.toml b/substrate/validator-sets/primitives/Cargo.toml index fc37c27a..844e6134 100644 --- a/substrate/validator-sets/primitives/Cargo.toml +++ b/substrate/validator-sets/primitives/Cargo.toml @@ -12,6 +12,9 @@ rust-version = "1.74" all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] zeroize = { version = "^1.5", features = ["derive"], optional = true } diff --git a/tests/coordinator/Cargo.toml b/tests/coordinator/Cargo.toml index 2aa805ce..36d914c0 100644 --- a/tests/coordinator/Cargo.toml +++ b/tests/coordinator/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] hex = "0.4" diff --git a/tests/coordinator/src/tests/batch.rs b/tests/coordinator/src/tests/batch.rs index 54cda6c9..ea4555e6 100644 --- a/tests/coordinator/src/tests/batch.rs +++ b/tests/coordinator/src/tests/batch.rs @@ -40,7 +40,7 @@ pub async fn batch( ) -> u64 { let id = SubstrateSignId { session, id: SubstrateSignableId::Batch(batch.id), attempt: 0 }; - for processor in processors.iter_mut() { + for processor in &mut *processors { processor .send_message(messages::substrate::ProcessorMessage::Batch { batch: batch.clone() }) .await; @@ -92,7 +92,7 @@ pub async fn batch( let known_signer_i = Participant::new(u16::from(processor_is[known_signer])).unwrap(); assert!(!preprocesses.contains_key(&known_signer_i)); - let mut participants = preprocesses.keys().cloned().collect::>(); + let mut participants = preprocesses.keys().copied().collect::>(); for (p, preprocess) in preprocesses { assert_eq!(preprocess, [u8::try_from(u16::from(p)).unwrap(); 64]); } @@ -219,7 +219,7 @@ pub async fn batch( // Verify the coordinator sends SubstrateBlock to all processors let last_block = serai.finalized_block_by_number(last_serai_block).await.unwrap().unwrap(); - for processor in processors { + for processor in &mut *processors { // Handle a potential re-attempt message in the pipeline let mut received = processor.recv_message().await; if matches!( diff --git a/tests/coordinator/src/tests/key_gen.rs b/tests/coordinator/src/tests/key_gen.rs index 7e90ba1f..150c5d49 100644 --- a/tests/coordinator/src/tests/key_gen.rs +++ b/tests/coordinator/src/tests/key_gen.rs @@ -166,7 +166,7 @@ pub async fn key_gen( } } let mut message = None; - for processor in processors.iter_mut() { + for processor in &mut *processors { let msg = processor.recv_message().await; if message.is_none() { match msg { @@ -208,7 +208,7 @@ pub async fn key_gen( KeyPair(Public(substrate_key), network_key.try_into().unwrap()) ); - for processor in processors.iter_mut() { + for processor in &mut *processors { processor.set_substrate_key(substrate_priv_key.clone()).await; } diff --git a/tests/coordinator/src/tests/sign.rs b/tests/coordinator/src/tests/sign.rs index f2cea1df..75121f39 100644 --- a/tests/coordinator/src/tests/sign.rs +++ b/tests/coordinator/src/tests/sign.rs @@ -77,7 +77,7 @@ pub async fn sign( let known_signer_i = Participant::new(u16::from(processor_is[known_signer])).unwrap(); assert!(!preprocesses.contains_key(&known_signer_i)); - let mut participants = preprocesses.keys().cloned().collect::>(); + let mut participants = preprocesses.keys().copied().collect::>(); for (p, preprocess) in preprocesses { assert_eq!(preprocess, vec![u8::try_from(u16::from(p)).unwrap(); 128]); } diff --git a/tests/docker/Cargo.toml b/tests/docker/Cargo.toml index 8db50773..1b3a8a6e 100644 --- a/tests/docker/Cargo.toml +++ b/tests/docker/Cargo.toml @@ -13,5 +13,8 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] chrono = "0.4" diff --git a/tests/full-stack/Cargo.toml b/tests/full-stack/Cargo.toml index aa7fc11a..254e5dc8 100644 --- a/tests/full-stack/Cargo.toml +++ b/tests/full-stack/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] hex = "0.4" diff --git a/tests/message-queue/Cargo.toml b/tests/message-queue/Cargo.toml index ebffff75..2d735534 100644 --- a/tests/message-queue/Cargo.toml +++ b/tests/message-queue/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] hex = "0.4" diff --git a/tests/no-std/Cargo.toml b/tests/no-std/Cargo.toml index 37f43e6b..dc128786 100644 --- a/tests/no-std/Cargo.toml +++ b/tests/no-std/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] flexible-transcript = { path = "../../crypto/transcript", default-features = false, features = ["recommended", "merlin"] } diff --git a/tests/processor/Cargo.toml b/tests/processor/Cargo.toml index d7582eab..686dbcea 100644 --- a/tests/processor/Cargo.toml +++ b/tests/processor/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] hex = "0.4" diff --git a/tests/processor/src/tests/batch.rs b/tests/processor/src/tests/batch.rs index 459f42ee..5729fd73 100644 --- a/tests/processor/src/tests/batch.rs +++ b/tests/processor/src/tests/batch.rs @@ -280,7 +280,7 @@ fn batch_test() { // TODO: Double check how the processor handles this ID field // It should be able to assert its perfectly sequential id.attempt = attempt; - for coordinator in coordinators.iter_mut() { + for coordinator in &mut coordinators { coordinator .send_message(messages::coordinator::CoordinatorMessage::BatchReattempt { id: id.clone(), diff --git a/tests/processor/src/tests/send.rs b/tests/processor/src/tests/send.rs index 986671c1..905b32db 100644 --- a/tests/processor/src/tests/send.rs +++ b/tests/processor/src/tests/send.rs @@ -246,14 +246,14 @@ fn send_test() { // TODO: Double check how the processor handles this ID field // It should be able to assert its perfectly sequential id.attempt = attempt; - for coordinator in coordinators.iter_mut() { + for coordinator in &mut coordinators { coordinator .send_message(messages::sign::CoordinatorMessage::Reattempt { id: id.clone() }) .await; } (id, preprocesses) = recv_sign_preprocesses(&mut coordinators, Session(0), attempt).await; } - let participating = preprocesses.keys().cloned().collect::>(); + let participating = preprocesses.keys().copied().collect::>(); let tx_id = sign_tx(&mut coordinators, Session(0), id.clone(), preprocesses).await; diff --git a/tests/reproducible-runtime/Cargo.toml b/tests/reproducible-runtime/Cargo.toml index 9e1d11ec..6e024111 100644 --- a/tests/reproducible-runtime/Cargo.toml +++ b/tests/reproducible-runtime/Cargo.toml @@ -13,6 +13,9 @@ publish = false all-features = true rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] rand_core = "0.6" hex = "0.4"