Skip to content

Commit

Permalink
fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFluffy committed Jan 14, 2025
1 parent 8fbea8e commit e7671ec
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion crates/astria-auctioneer/src/auctioneer/auction/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>,
}

Expand Down
12 changes: 8 additions & 4 deletions crates/astria-auctioneer/src/auctioneer/auction/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions crates/astria-auctioneer/src/bid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion crates/astria-auctioneer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 11 additions & 12 deletions crates/astria-sequencer/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl BackgroundTasks {
}

fn abort_all(&mut self) {
self.tasks.abort_all()
self.tasks.abort_all();
}

fn cancel_all(&self) {
Expand Down Expand Up @@ -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()
Expand All @@ -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");
Expand Down

0 comments on commit e7671ec

Please sign in to comment.