From e7671ec9ece4b984436ef19ed8da99a202d71db1 Mon Sep 17 00:00:00 2001 From: Richard Janis Goldschmidt Date: Tue, 14 Jan 2025 17:34:08 +0100 Subject: [PATCH] fix clippy lints --- .../src/auctioneer/auction/factory.rs | 2 +- .../src/auctioneer/auction/worker.rs | 12 ++++++---- crates/astria-auctioneer/src/bid/mod.rs | 7 +++--- crates/astria-auctioneer/src/config.rs | 5 +++- crates/astria-sequencer/src/grpc/mod.rs | 23 +++++++++---------- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/crates/astria-auctioneer/src/auctioneer/auction/factory.rs b/crates/astria-auctioneer/src/auctioneer/auction/factory.rs index 0019d373e5..f62a6eae33 100644 --- a/crates/astria-auctioneer/src/auctioneer/auction/factory.rs +++ b/crates/astria-auctioneer/src/auctioneer/auction/factory.rs @@ -42,7 +42,7 @@ pub(in crate::auctioneer) struct Factory { /// `last_successful_nonce + 1` is used for submitting an auction winner to Sequencer /// if an auction worker was not able to receive the last pending /// nonce from Sequencer in time. Starts unset at the beginning of the program and - /// is set externally via Factory::set_last_succesful_nonce`. + /// is set externally via `Factory::set_last_succesful_nonce`. pub(in crate::auctioneer) last_successful_nonce: Option, } diff --git a/crates/astria-auctioneer/src/auctioneer/auction/worker.rs b/crates/astria-auctioneer/src/auctioneer/auction/worker.rs index 266be3bc31..48d5fe4d13 100644 --- a/crates/astria-auctioneer/src/auctioneer/auction/worker.rs +++ b/crates/astria-auctioneer/src/auctioneer/auction/worker.rs @@ -183,14 +183,18 @@ impl Worker { let mut auction_is_open = false; let mut nonce_fetch = None; + #[expect( + clippy::semicolon_if_nothing_returned, + reason = "we want to pattern match on the latency timer's return value" + )] loop { select! { biased; () = async { - Option::as_pin_mut(latency_margin_timer.as_mut()) - .unwrap() - .await + Option::as_pin_mut(latency_margin_timer.as_mut()) + .unwrap() + .await }, if latency_margin_timer.is_some() => { info!("timer is up; bids left unprocessed: {}", self.bids.len()); break Ok(AuctionItems { @@ -324,7 +328,7 @@ async fn get_pending_nonce(sequencer_channel: SequencerChannel, address: Address match sequencer_channel.get_pending_nonce(address).await { Ok(nonce) => return nonce, Err(error) => { - error!(%error, "fetching nonce failed; immediately scheduling next fetch") + error!(%error, "fetching nonce failed; immediately scheduling next fetch"); } } } diff --git a/crates/astria-auctioneer/src/bid/mod.rs b/crates/astria-auctioneer/src/bid/mod.rs index 647520b14f..6b6b59a4a1 100644 --- a/crates/astria-auctioneer/src/bid/mod.rs +++ b/crates/astria-auctioneer/src/bid/mod.rs @@ -161,13 +161,12 @@ pub(crate) struct Allocation { impl Allocation { fn new(bid: Bid, sequencer_key: &SequencerKey) -> Self { - let bid_data = bid.clone().into_raw().encode_to_vec(); - let signature = sequencer_key.signing_key().sign(&bid_data); - let verification_key = sequencer_key.signing_key().verification_key(); let bid_bytes = pbjson_types::Any { type_url: raw::Bid::type_url(), - value: bid.clone().into_raw().encode_to_vec().into(), + value: bid.into_raw().encode_to_vec().into(), }; + let signature = sequencer_key.signing_key().sign(&bid_bytes.value); + let verification_key = sequencer_key.signing_key().verification_key(); Self { signature, verification_key, diff --git a/crates/astria-auctioneer/src/config.rs b/crates/astria-auctioneer/src/config.rs index 7ef5c971f7..4ee15e7fc1 100644 --- a/crates/astria-auctioneer/src/config.rs +++ b/crates/astria-auctioneer/src/config.rs @@ -6,7 +6,10 @@ use serde::{ // Allowed `struct_excessive_bools` because this is used as a container // for deserialization. Making this a builder-pattern is not actionable. -#[allow(clippy::struct_excessive_bools)] +#[expect( + clippy::struct_excessive_bools, + reason = "represents a config with flags" +)] #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] /// The single config for creating an astria-auctioneer service. pub struct Config { diff --git a/crates/astria-sequencer/src/grpc/mod.rs b/crates/astria-sequencer/src/grpc/mod.rs index c4a9f2974b..1dc5452f2f 100644 --- a/crates/astria-sequencer/src/grpc/mod.rs +++ b/crates/astria-sequencer/src/grpc/mod.rs @@ -56,7 +56,7 @@ impl BackgroundTasks { } fn abort_all(&mut self) { - self.tasks.abort_all() + self.tasks.abort_all(); } fn cancel_all(&self) { @@ -182,19 +182,19 @@ async fn trigger_shutdown( keep responding to gRPC requests, but there is currently no way to recover \ functionality of this service until Sequencer is restarted" ); - }) + }); } } } perform_shutdown(background_tasks) .instrument(shutdown_span) - .await + .await; } async fn perform_shutdown(mut background_tasks: BackgroundTasks) { background_tasks.cancel_all(); - match tokio::time::timeout(SHUTDOWN_TIMEOUT, async { + if let Ok(()) = tokio::time::timeout(SHUTDOWN_TIMEOUT, async { while let Some((task, res)) = background_tasks.join_next().await { let error = res .err() @@ -208,14 +208,13 @@ async fn perform_shutdown(mut background_tasks: BackgroundTasks) { }) .await { - Ok(()) => info!("all background tasks exited during shutdown window"), - Err(_) => { - error!( - tasks = background_tasks.display_running_tasks(), - "background tasks did not finish during shutdown window and will be aborted", - ); - background_tasks.abort_all(); - } + info!("all background tasks exited during shutdown window"); + } else { + error!( + tasks = background_tasks.display_running_tasks(), + "background tasks did not finish during shutdown window and will be aborted", + ); + background_tasks.abort_all(); }; info!("reached shutdown target");