From ca578dd827174107a9a978a9f4e1f4d0af95d905 Mon Sep 17 00:00:00 2001 From: nullPointerEnjoyer Date: Wed, 16 Sep 2026 17:05:04 +0400 Subject: [PATCH 1/3] fix: address clippy 1.98 lints across the workspace Mechanical, behavior-preserving fixes for the lints introduced by the newer clippy (new_without_default, let_and_return, useless_borrows / redundant references, some_filter, unused imports), so that do_checks.sh passes with the current toolchain. --- Cargo.lock | 4 +++ .../src/delta/delta_data_collection/mod.rs | 6 +++++ .../src/delta/delta_data_collection/undo.rs | 6 +++++ .../produce_block/tx_selection_by_deps.rs | 3 +-- .../src/accumulated_fee.rs | 6 +++++ .../src/constraints_accumulator.rs | 6 +++++ chainstate/src/detail/orphan_blocks/pool.rs | 6 ++--- .../test-framework/src/transaction_builder.rs | 6 +++++ chainstate/test-framework/src/utils.rs | 7 ++--- .../test-suite/src/tests/orders_tests.rs | 5 +--- .../test-suite/src/tests/processing_tests.rs | 3 +-- chainstate/types/src/block_status.rs | 9 +++++-- .../additional_info.rs | 7 ++++- mempool/src/pool/orphans/test.rs | 2 +- networking/src/transport/impls/channel.rs | 6 +++++ .../impls/stream_adapter/identity.rs | 6 +++++ networking/src/transport/impls/tcp.rs | 6 +++++ node-gui/backend/src/messages.rs | 6 +++++ node-gui/src/main_window/main_menu.rs | 6 ++--- orders-accounting/src/data.rs | 18 +++++++++++++ orders-accounting/src/storage/in_memory.rs | 6 +++++ p2p/src/peer_manager/mod.rs | 4 +-- p2p/src/sync/sync_status.rs | 6 +++++ p2p/src/sync/tests/header_list_response.rs | 6 ++--- p2p/types/src/peer_id.rs | 6 +++++ pos-accounting/src/data.rs | 6 +++++ pos-accounting/src/pool/delta/mod.rs | 6 +++++ pos-accounting/src/storage/in_memory.rs | 6 +++++ serialization/tagged/src/lib.rs | 5 ++-- storage/backend-test-suite/src/prelude.rs | 2 +- test-rpc-functions/src/empty.rs | 6 +++++ test-utils/src/basic_test_time_getter.rs | 6 +++++ test-utils/src/test_dir.rs | 2 +- tokens-accounting/src/data.rs | 18 +++++++++++++ tokens-accounting/src/storage/in_memory.rs | 6 +++++ utils/networking/src/broadcaster.rs | 7 ++++- utils/src/set_flag.rs | 7 ++++- wallet/src/send_request/mod.rs | 6 +++++ wallet/src/signer/trezor_signer/mod.rs | 6 ++--- wallet/src/wallet/tests.rs | 27 +++++++++---------- .../types/src/partially_signed_transaction.rs | 12 +++++++++ 41 files changed, 222 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5bf8e6fc1..0a1de389f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,6 +317,8 @@ dependencies = [ "parity-scale-codec", "pos-accounting", "rstest", + "serde", + "serde_json", "serialization", "test-utils", "thiserror 1.0.69", @@ -329,6 +331,7 @@ name = "api-server-stack-test-suite" version = "1.4.0" dependencies = [ "api-blockchain-scanner-lib", + "api-server-backend-test-suite", "api-server-common", "api-web-server", "async-trait", @@ -367,6 +370,7 @@ dependencies = [ "common", "crypto", "ctor", + "futures", "hex", "logging", "mempool", diff --git a/accounting/src/delta/delta_data_collection/mod.rs b/accounting/src/delta/delta_data_collection/mod.rs index f8b2d4f7b5..5ab261a867 100644 --- a/accounting/src/delta/delta_data_collection/mod.rs +++ b/accounting/src/delta/delta_data_collection/mod.rs @@ -158,6 +158,12 @@ impl FromIterator<(K, DataDelta)> for DeltaDataColle } } +impl Default for DeltaDataCollection { + fn default() -> Self { + Self::new() + } +} + /// Given two deltas, combine them into one delta, this is the basic delta data composability function fn combine_delta_data( lhs: DataDelta, diff --git a/accounting/src/delta/delta_data_collection/undo.rs b/accounting/src/delta/delta_data_collection/undo.rs index f5ac64572f..927642b808 100644 --- a/accounting/src/delta/delta_data_collection/undo.rs +++ b/accounting/src/delta/delta_data_collection/undo.rs @@ -61,3 +61,9 @@ impl DeltaDataUndoCollection { self.data } } + +impl Default for DeltaDataUndoCollection { + fn default() -> Self { + Self::new() + } +} diff --git a/blockprod/src/detail/tests/produce_block/tx_selection_by_deps.rs b/blockprod/src/detail/tests/produce_block/tx_selection_by_deps.rs index dfca2c03d8..947966ae5b 100644 --- a/blockprod/src/detail/tests/produce_block/tx_selection_by_deps.rs +++ b/blockprod/src/detail/tests/produce_block/tx_selection_by_deps.rs @@ -1339,8 +1339,7 @@ async fn assert_fees( .chainstate .call(|cs| { let tip = cs.get_best_block_id().unwrap(); - let tip_index = cs.get_gen_block_index_for_persisted_block(&tip).unwrap().unwrap(); - tip_index + cs.get_gen_block_index_for_persisted_block(&tip).unwrap().unwrap() }) .await .unwrap(); diff --git a/chainstate/constraints-value-accumulator/src/accumulated_fee.rs b/chainstate/constraints-value-accumulator/src/accumulated_fee.rs index cdd7264e76..8be4192a4b 100644 --- a/chainstate/constraints-value-accumulator/src/accumulated_fee.rs +++ b/chainstate/constraints-value-accumulator/src/accumulated_fee.rs @@ -28,6 +28,12 @@ pub struct AccumulatedFee { timelock_constrained: BTreeMap, } +impl Default for AccumulatedFee { + fn default() -> Self { + Self::new() + } +} + impl AccumulatedFee { pub fn new() -> Self { Self { diff --git a/chainstate/constraints-value-accumulator/src/constraints_accumulator.rs b/chainstate/constraints-value-accumulator/src/constraints_accumulator.rs index dace67c6bf..605e4f6ed0 100644 --- a/chainstate/constraints-value-accumulator/src/constraints_accumulator.rs +++ b/chainstate/constraints-value-accumulator/src/constraints_accumulator.rs @@ -40,6 +40,12 @@ pub struct ConstrainedValueAccumulator { timelock_constrained: BTreeMap, } +impl Default for ConstrainedValueAccumulator { + fn default() -> Self { + Self::new() + } +} + impl ConstrainedValueAccumulator { pub fn new() -> Self { Self { diff --git a/chainstate/src/detail/orphan_blocks/pool.rs b/chainstate/src/detail/orphan_blocks/pool.rs index ba165d0998..9855cda9cd 100644 --- a/chainstate/src/detail/orphan_blocks/pool.rs +++ b/chainstate/src/detail/orphan_blocks/pool.rs @@ -139,14 +139,12 @@ impl OrphanBlocksPool { // after we get all the blocks that have the same prev, we drop them from the pool res.iter().for_each(|blk| self.drop_block(&blk.get_id())); // after dropping everything, this is expected to be the only Rc left - let res = res - .drain(..) + res.drain(..) .map(|blk| { Rc::try_unwrap(blk) .expect("There cannot be more than one copy of the Rc. This is unexpected.") }) - .collect(); - res + .collect() } } diff --git a/chainstate/test-framework/src/transaction_builder.rs b/chainstate/test-framework/src/transaction_builder.rs index 44ca5876b4..692a2698af 100644 --- a/chainstate/test-framework/src/transaction_builder.rs +++ b/chainstate/test-framework/src/transaction_builder.rs @@ -31,6 +31,12 @@ pub struct TransactionBuilder { witnesses: Vec, } +impl Default for TransactionBuilder { + fn default() -> Self { + Self::new() + } +} + impl TransactionBuilder { pub fn new() -> Self { Self { diff --git a/chainstate/test-framework/src/utils.rs b/chainstate/test-framework/src/utils.rs index 86a9fa7a6f..55e96482e1 100644 --- a/chainstate/test-framework/src/utils.rs +++ b/chainstate/test-framework/src/utils.rs @@ -413,8 +413,7 @@ pub fn sign_witnesses( ) .unwrap(); - let witnesses = tx - .inputs() + tx.inputs() .iter() .enumerate() .map(|(idx, input)| { @@ -431,9 +430,7 @@ pub fn sign_witnesses( ) .unwrap() }) - .collect(); - - witnesses + .collect() } pub fn find_create_pool_tx_in_genesis(genesis: &Genesis, pool_id: &PoolId) -> Option { diff --git a/chainstate/test-suite/src/tests/orders_tests.rs b/chainstate/test-suite/src/tests/orders_tests.rs index 6ead66f4d1..bd78017c55 100644 --- a/chainstate/test-suite/src/tests/orders_tests.rs +++ b/chainstate/test-suite/src/tests/orders_tests.rs @@ -1049,10 +1049,7 @@ fn fill_order_check_storage(#[case] seed: Seed, #[case] version: OrdersVersion) / ask_amount.into_atoms(); let filled2 = (give_amount.into_atoms() * left_to_fill.into_atoms()) / ask_amount.into_atoms(); - let remainder = (give_amount - Amount::from_atoms(filled1 + filled2)) - .unwrap() - .as_non_zero(); - remainder + (give_amount - Amount::from_atoms(filled1 + filled2)).unwrap().as_non_zero() } }; diff --git a/chainstate/test-suite/src/tests/processing_tests.rs b/chainstate/test-suite/src/tests/processing_tests.rs index df6c3a56d4..8210abff72 100644 --- a/chainstate/test-suite/src/tests/processing_tests.rs +++ b/chainstate/test-suite/src/tests/processing_tests.rs @@ -1008,8 +1008,7 @@ fn read_block_reward_from_storage(#[case] seed: Seed) { .expect("Unexpected conversion error"), consensus::MiningResult::Success ); - let valid_block = Block::new_from_header(block_header, valid_block.body().clone()).unwrap(); - valid_block + Block::new_from_header(block_header, valid_block.body().clone()).unwrap() }; tf.process_block(block, BlockSource::Local).unwrap(); diff --git a/chainstate/types/src/block_status.rs b/chainstate/types/src/block_status.rs index 97cfd456f7..686063c991 100644 --- a/chainstate/types/src/block_status.rs +++ b/chainstate/types/src/block_status.rs @@ -46,8 +46,7 @@ impl BlockStatus { Self(0) } - /// Advance the last successful validation stage to the specified value. - /// Note that the stage can only be advanced one step at a time. + /// Advance the last successful validation stage to the specified value. /// Note that the stage can only be advanced one step at a time. pub fn advance_validation_stage_to(&mut self, new_stage: BlockValidationStage) { assert!(self.last_valid_stage().next() == Some(new_stage)); self.set_last_valid_stage(new_stage); @@ -149,6 +148,12 @@ impl BlockStatus { } } +impl Default for BlockStatus { + fn default() -> Self { + Self::new() + } +} + impl std::fmt::Display for BlockStatus { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "BlockStatus({:#b})", self.0) diff --git a/common/src/chain/partially_signed_transaction/additional_info.rs b/common/src/chain/partially_signed_transaction/additional_info.rs index 303be49f14..f8aaa10579 100644 --- a/common/src/chain/partially_signed_transaction/additional_info.rs +++ b/common/src/chain/partially_signed_transaction/additional_info.rs @@ -77,7 +77,6 @@ impl TxAdditionalInfo { order_info: BTreeMap::new(), } } - pub fn with_pool_info(mut self, pool_id: PoolId, info: PoolAdditionalInfo) -> Self { self.pool_info.insert(pool_id, info); self @@ -161,3 +160,9 @@ impl OutputValuesHolder for TxAdditionalInfo { .flat_map(|(_, order_info)| order_info.output_values_iter()) } } + +impl Default for TxAdditionalInfo { + fn default() -> Self { + Self::new() + } +} diff --git a/mempool/src/pool/orphans/test.rs b/mempool/src/pool/orphans/test.rs index c26ecf83e6..84375fbf8f 100644 --- a/mempool/src/pool/orphans/test.rs +++ b/mempool/src/pool/orphans/test.rs @@ -24,7 +24,7 @@ use common::{ }, primitives::{Amount, H256}, }; -use test_utils::random::{Rng, RngExt as _, Seed, make_seedable_rng}; +use test_utils::random::{Rng, Seed, make_seedable_rng}; use super::*; diff --git a/networking/src/transport/impls/channel.rs b/networking/src/transport/impls/channel.rs index e1b7d15d81..7831479723 100644 --- a/networking/src/transport/impls/channel.rs +++ b/networking/src/transport/impls/channel.rs @@ -328,6 +328,12 @@ pub enum MpscChannelTransportError { }, } +impl Default for MpscChannelTransport { + fn default() -> Self { + Self::new() + } +} + #[cfg(test)] mod tests { use std::net::SocketAddrV4; diff --git a/networking/src/transport/impls/stream_adapter/identity.rs b/networking/src/transport/impls/stream_adapter/identity.rs index 5782e74d54..f933e9eccb 100644 --- a/networking/src/transport/impls/stream_adapter/identity.rs +++ b/networking/src/transport/impls/stream_adapter/identity.rs @@ -43,3 +43,9 @@ impl StreamAdapter for Identit Box::pin(ready(Ok(base))) } } + +impl Default for IdentityStreamAdapter { + fn default() -> Self { + Self::new() + } +} diff --git a/networking/src/transport/impls/tcp.rs b/networking/src/transport/impls/tcp.rs index f803638981..9481a81790 100644 --- a/networking/src/transport/impls/tcp.rs +++ b/networking/src/transport/impls/tcp.rs @@ -149,6 +149,12 @@ impl ConnectedSocketInfo for TcpTransportStream { } } +impl Default for TcpTransportSocket { + fn default() -> Self { + Self::new() + } +} + #[cfg(test)] mod tests { use serialization::Encode; diff --git a/node-gui/backend/src/messages.rs b/node-gui/backend/src/messages.rs index d6c08d1c0d..66f8546d0c 100644 --- a/node-gui/backend/src/messages.rs +++ b/node-gui/backend/src/messages.rs @@ -44,6 +44,12 @@ pub struct WalletId(u64); static NEXT_WALLET_ID: AtomicU64 = AtomicU64::new(0); +impl Default for WalletId { + fn default() -> Self { + Self::new() + } +} + impl WalletId { pub fn new() -> Self { Self(NEXT_WALLET_ID.fetch_add(1, Ordering::Relaxed)) diff --git a/node-gui/src/main_window/main_menu.rs b/node-gui/src/main_window/main_menu.rs index b77ba76e14..213a4abb9e 100644 --- a/node-gui/src/main_window/main_menu.rs +++ b/node-gui/src/main_window/main_menu.rs @@ -100,7 +100,7 @@ fn menu_item(label: &str, msg: MenuMessage) -> Item<'_, MenuMessage, Theme, iced } fn make_menu_file<'a>(wallet_mode: WalletMode) -> Item<'a, MenuMessage, Theme, iced::Renderer> { - let root = Item::with_menu( + Item::with_menu( labeled_button("File", MenuMessage::NoOp), Menu::new(match wallet_mode { WalletMode::Hot => { @@ -199,7 +199,5 @@ fn make_menu_file<'a>(wallet_mode: WalletMode) -> Item<'a, MenuMessage, Theme, i } }) .width(300), - ); - - root + ) } diff --git a/orders-accounting/src/data.rs b/orders-accounting/src/data.rs index e050fd4daa..d785881d9d 100644 --- a/orders-accounting/src/data.rs +++ b/orders-accounting/src/data.rs @@ -98,6 +98,12 @@ pub struct OrdersAccountingData { pub give_balances: BTreeMap, } +impl Default for OrdersAccountingData { + fn default() -> Self { + Self::new() + } +} + impl OrdersAccountingData { pub fn new() -> Self { Self { @@ -115,6 +121,12 @@ pub struct OrdersAccountingDeltaData { pub(crate) give_balances: DeltaAmountCollection, } +impl Default for OrdersAccountingDeltaData { + fn default() -> Self { + Self::new() + } +} + impl OrdersAccountingDeltaData { pub fn merge_with_delta( &mut self, @@ -153,6 +165,12 @@ pub struct OrdersAccountingDeltaUndoData { pub(crate) give_balances: DeltaAmountCollection, } +impl Default for OrdersAccountingDeltaUndoData { + fn default() -> Self { + Self::new() + } +} + impl OrdersAccountingDeltaUndoData { pub fn new() -> Self { Self { diff --git a/orders-accounting/src/storage/in_memory.rs b/orders-accounting/src/storage/in_memory.rs index 9d1abf749a..aad8fc0b23 100644 --- a/orders-accounting/src/storage/in_memory.rs +++ b/orders-accounting/src/storage/in_memory.rs @@ -29,6 +29,12 @@ pub struct InMemoryOrdersAccounting { give_balances: BTreeMap, } +impl Default for InMemoryOrdersAccounting { + fn default() -> Self { + Self::new() + } +} + impl InMemoryOrdersAccounting { pub fn new() -> Self { Self { diff --git a/p2p/src/peer_manager/mod.rs b/p2p/src/peer_manager/mod.rs index b5de828e92..4b12c69905 100644 --- a/p2p/src/peer_manager/mod.rs +++ b/p2p/src/peer_manager/mod.rs @@ -2273,9 +2273,7 @@ where // should be loaded. // Note: the check for reachability is a protection against a misconfigured dns seed, // which may return bogus addresses. - let peerdb_has_no_reachable_addresses = self.peerdb.reachable_addresses().next().is_none(); - - peerdb_has_no_reachable_addresses + self.peerdb.reachable_addresses().next().is_none() } fn load_predefined_addresses(&mut self) { diff --git a/p2p/src/sync/sync_status.rs b/p2p/src/sync/sync_status.rs index 37e5168eda..a5d962e775 100644 --- a/p2p/src/sync/sync_status.rs +++ b/p2p/src/sync/sync_status.rs @@ -22,6 +22,12 @@ pub struct PeerBlockSyncStatus { pub expecting_blocks_since: Option