From 9cd5985c923ad631e864325968b53d36d890b13d Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Tue, 10 Oct 2023 19:51:05 +0200 Subject: [PATCH] [meta] update to rust 1.73 This is bumping the rust version to the most recent rust version (by feature that we use) before the new edition. Signed-off-by: Vincenzo Palazzo --- .github/workflows/actions.yml | 2 +- chain/src/block/cache/test.rs | 12 +++--------- client/src/lib.rs | 1 + common/src/network.rs | 9 ++------- net/src/simulator.rs | 2 +- p2p/src/fsm/addrmgr.rs | 2 +- p2p/src/fsm/fees.rs | 2 +- p2p/src/fsm/filter_cache.rs | 6 +----- p2p/src/fsm/invmgr.rs | 7 ++++--- p2p/src/lib.rs | 2 +- rust-toolchain | 2 +- test/src/block.rs | 1 - 12 files changed, 17 insertions(+), 31 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index d3113f15..6500009d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.65 + toolchain: "1.73" profile: minimal components: clippy, rustfmt override: true diff --git a/chain/src/block/cache/test.rs b/chain/src/block/cache/test.rs index 4d6affd1..872e983a 100644 --- a/chain/src/block/cache/test.rs +++ b/chain/src/block/cache/test.rs @@ -1323,17 +1323,13 @@ fn test_cache_import_duplicate() { let a2 = a1.next(g); let a3 = a2.next(g); - assert!(matches! { - cache.import_block(a1.block(), &ctx), Ok(_) - }); + assert!(cache.import_block(a1.block(), &ctx).is_ok()); assert!(matches! { cache.import_block(a1.block(), &ctx), Err(Error::DuplicateBlock(h)) if h == a1.hash }); - assert!(matches! { - cache.import_block(a2.block(), &ctx), Ok(_) - }); + assert!(cache.import_block(a2.block(), &ctx).is_ok()); assert!(matches! { cache.import_block(a2.block(), &ctx), Err(Error::DuplicateBlock(_)) }); @@ -1343,9 +1339,7 @@ fn test_cache_import_duplicate() { // <- b3 let b3 = a1.next(g); - assert!(matches! { - cache.import_block(b3.block(), &ctx), Ok(_) - }); + assert!(cache.import_block(b3.block(), &ctx).is_ok()); assert!(matches! { cache.import_block(b3.block(), &ctx), Err(Error::DuplicateBlock(h)) if h == b3.hash diff --git a/client/src/lib.rs b/client/src/lib.rs index 77cd719d..e3269484 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -4,6 +4,7 @@ #![deny(missing_docs, unsafe_code)] mod client; mod error; +#[allow(hidden_glob_reexports)] mod event; mod peer; mod service; diff --git a/common/src/network.rs b/common/src/network.rs index b77dd9cd..7ad0e519 100644 --- a/common/src/network.rs +++ b/common/src/network.rs @@ -12,9 +12,10 @@ use bitcoin_hashes::sha256d; use crate::block::Height; /// Peer services supported by nakamoto. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Default)] pub enum Services { /// Peers with compact filter support. + #[default] All, /// Peers with only block support. Chain, @@ -29,12 +30,6 @@ impl From for ServiceFlags { } } -impl Default for Services { - fn default() -> Self { - Services::All - } -} - /// Bitcoin peer network. #[derive(Debug, Copy, Clone)] pub enum Network { diff --git a/net/src/simulator.rs b/net/src/simulator.rs index 781bb587..bed0113b 100644 --- a/net/src/simulator.rs +++ b/net/src/simulator.rs @@ -593,7 +593,7 @@ where } } Io::Event(event) => { - let events = self.events.entry(node).or_insert_with(VecDeque::new); + let events = self.events.entry(node).or_default(); if events.len() >= MAX_EVENTS { warn!(target: "sim", "Dropping event: buffer is full"); } else { diff --git a/p2p/src/fsm/addrmgr.rs b/p2p/src/fsm/addrmgr.rs index b1179501..7d24d4a1 100644 --- a/p2p/src/fsm/addrmgr.rs +++ b/p2p/src/fsm/addrmgr.rs @@ -344,7 +344,7 @@ impl AddressManager { // Peer misbehaving, got empty message or too many addresses. return; } - self.insert(addrs.into_iter(), Source::Peer(peer)); + self.insert(addrs, Source::Peer(peer)); } /// Add addresses to the address manager. The input matches that of the `addr` message diff --git a/p2p/src/fsm/fees.rs b/p2p/src/fsm/fees.rs index 96ff3282..4ec322af 100644 --- a/p2p/src/fsm/fees.rs +++ b/p2p/src/fsm/fees.rs @@ -195,7 +195,7 @@ mod tests { let estimate = fe.process(block, height as Height); estimates.insert(height, estimate); } - assert_eq!(fe.snapshots.len(), MAX_UTXO_SNAPSHOTS as usize); + assert_eq!(fe.snapshots.len(), { MAX_UTXO_SNAPSHOTS }); assert_eq!(fe.height, 21); assert_matches!(fe.snapshots.back(), Some((20, _))); diff --git a/p2p/src/fsm/filter_cache.rs b/p2p/src/fsm/filter_cache.rs index 6e7e248c..08c69e90 100644 --- a/p2p/src/fsm/filter_cache.rs +++ b/p2p/src/fsm/filter_cache.rs @@ -286,11 +286,7 @@ mod tests { for op in operations.into_iter() { op.apply(&mut cache, &mut rng); - let size = cache - .cache - .iter() - .map(|(_, f)| f.content.len()) - .sum::(); + let size = cache.cache.values().map(|f| f.content.len()).sum::(); assert!(cache.size <= cache.capacity); assert!(size == cache.size); diff --git a/p2p/src/fsm/invmgr.rs b/p2p/src/fsm/invmgr.rs index d766c9b3..bf76a3bb 100644 --- a/p2p/src/fsm/invmgr.rs +++ b/p2p/src/fsm/invmgr.rs @@ -594,9 +594,10 @@ mod tests { assert!(!invmgr.remaining.is_empty()); let Some((addr, _)) = output::test::messages(&mut invmgr) - .find(|(_, m)| matches!(m, NetworkMessage::GetData(i) if i == &inv)) else { - continue; - }; + .find(|(_, m)| matches!(m, NetworkMessage::GetData(i) if i == &inv)) + else { + continue; + }; assert!( clock.local_time() - last_request >= REQUEST_TIMEOUT, diff --git a/p2p/src/lib.rs b/p2p/src/lib.rs index 09b7825b..72ce07f5 100644 --- a/p2p/src/lib.rs +++ b/p2p/src/lib.rs @@ -1,7 +1,7 @@ //! Nakamoto's peer-to-peer library. //! //! The `p2p` crate implements the core protocol state-machine. It can be found under the -//! [fsm](crate::fsm) module. +//! [fsm] module. //! //! Nakamoto's implementation of the peer-to-peer protocol(s) is *I/O-free*. The //! core logic is implemented as a state machine with *inputs* and *outputs* and a diff --git a/rust-toolchain b/rust-toolchain index 9cf4011b..e4654bb6 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.66 +1.73 diff --git a/test/src/block.rs b/test/src/block.rs index d8bee761..7eec966a 100644 --- a/test/src/block.rs +++ b/test/src/block.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use nakamoto_common::bitcoin::blockdata::transaction::{OutPoint, TxOut}; -use nakamoto_common::block::BlockHeader; pub use nakamoto_common::block::*;