Skip to content

Commit a43e0bb

Browse files
committed
fmt + clippy
1 parent 2b661cd commit a43e0bb

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

batcher/aligned-batcher/src/lib.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,11 @@ impl Batcher {
658658
if self.user_balance_is_unlocked(&addr).await {
659659
send_message(
660660
ws_conn_sink.clone(),
661-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
662-
SubmitProofResponseMessage::InsufficientBalance(addr, nonced_verification_data.nonce),
661+
// last_valid_nonce = client_msg.verification_data.nonce - 1.
662+
SubmitProofResponseMessage::InsufficientBalance(
663+
addr,
664+
nonced_verification_data.nonce,
665+
),
663666
)
664667
.await;
665668
self.metrics.user_error(&["insufficient_balance", ""]);
@@ -751,8 +754,11 @@ impl Batcher {
751754
std::mem::drop(batch_state_lock);
752755
send_message(
753756
ws_conn_sink.clone(),
754-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
755-
SubmitProofResponseMessage::InsufficientBalance(addr, nonced_verification_data.nonce - 1),
757+
// last_valid_nonce = client_msg.verification_data.nonce - 1.
758+
SubmitProofResponseMessage::InsufficientBalance(
759+
addr,
760+
nonced_verification_data.nonce - 1,
761+
),
756762
)
757763
.await;
758764
self.metrics.user_error(&["insufficient_balance", ""]);
@@ -1687,8 +1693,11 @@ impl Batcher {
16871693
error!("Could not get balance for non-paying address {replacement_addr:?}");
16881694
send_message(
16891695
ws_sink.clone(),
1690-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
1691-
SubmitProofResponseMessage::InsufficientBalance(replacement_addr, client_msg.verification_data.nonce - 1),
1696+
// last_valid_nonce = client_msg.verification_data.nonce - 1.
1697+
SubmitProofResponseMessage::InsufficientBalance(
1698+
replacement_addr,
1699+
client_msg.verification_data.nonce - 1,
1700+
),
16921701
)
16931702
.await;
16941703
return Ok(());
@@ -1698,8 +1707,11 @@ impl Batcher {
16981707
error!("Insufficient funds for non-paying address {replacement_addr:?}");
16991708
send_message(
17001709
ws_sink.clone(),
1701-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
1702-
SubmitProofResponseMessage::InsufficientBalance(replacement_addr, client_msg.verification_data.nonce - 1),
1710+
// last_valid_nonce = client_msg.verification_data.nonce - 1.
1711+
SubmitProofResponseMessage::InsufficientBalance(
1712+
replacement_addr,
1713+
client_msg.verification_data.nonce - 1,
1714+
),
17031715
)
17041716
.await;
17051717
return Ok(());

batcher/aligned-sdk/src/communication/messaging.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ pub async fn receive(
127127
Ok(data) => data,
128128
Err(e) => {
129129
warn!("Error while handling batcher response: {:?}", e);
130-
// In the case of submitting multiple proofs we can have an multiple proofs be submitted but there
130+
// In the case of submitting multiple proofs we can have an multiple proofs be submitted but there
131131
// insufficient balance we still want to read and return the `batch_inclusion_data` of the proofs that were approved.
132-
// `last_valid_nonce` corresponds to the nonce of the proof that triggered InsufficientBalance.
132+
// `last_valid_nonce` corresponds to the nonce of the proof that triggered InsufficientBalance.
133133
// Therefore the other proofs are in order and we set the last_proof_nonce to the nonce of the InsufficientBalance.
134134
if let SubmitError::InsufficientBalance(_, last_valid_nonce) = e {
135135
aligned_submitted_data.push(Err(e));
136-
// last_valid_nonce = last_nonce - 1. In the case
136+
// last_valid_nonce = last_nonce - 1. In the case
137137
info!("last_proof_nonce: {}", last_proof_nonce);
138138
info!("last_valid_nonce: {}", last_valid_nonce);
139139
// In the case all proofs are insufficient balance we go over them.
@@ -184,7 +184,10 @@ pub async fn receive(
184184
debug!("Message response handled successfully");
185185

186186
info!("last_proof_nonce: {}", last_proof_nonce);
187-
info!("batch_inclusion_data_message.user_nonce: {}", batch_inclusion_data_message.user_nonce);
187+
info!(
188+
"batch_inclusion_data_message.user_nonce: {}",
189+
batch_inclusion_data_message.user_nonce
190+
);
188191

189192
if batch_inclusion_data_message.user_nonce == last_proof_nonce {
190193
break;
@@ -220,7 +223,10 @@ async fn handle_batcher_response(msg: Message) -> Result<BatchInclusionData, Sub
220223
Ok(SubmitProofResponseMessage::InsufficientBalance(addr, last_sent_valid_nonce)) => {
221224
// If we receive an invalid balance we should grab the last_sent_valid_nonce.
222225
error!("Batcher responded with insufficient balance");
223-
Err(SubmitError::InsufficientBalance(addr, last_sent_valid_nonce))
226+
Err(SubmitError::InsufficientBalance(
227+
addr,
228+
last_sent_valid_nonce,
229+
))
224230
}
225231
Ok(SubmitProofResponseMessage::InvalidChainId) => {
226232
error!("Batcher responded with invalid chain id");
@@ -332,4 +338,4 @@ fn get_biggest_nonce(
332338
}
333339
}
334340
biggest_nonce
335-
}
341+
}

batcher/aligned-sdk/src/core/errors.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ impl fmt::Display for SubmitError {
196196
SubmitError::ProofTooLarge => write!(f, "Proof too Large"),
197197
SubmitError::InvalidReplacementMessage => write!(f, "Invalid replacement message"),
198198
SubmitError::InsufficientBalance(addr, last_sent_valid_nonce) => {
199-
write!(f, "Insufficient balance, address: {} last_sent_valid_nonce: {}", addr, last_sent_valid_nonce)
199+
write!(
200+
f,
201+
"Insufficient balance, address: {} last_sent_valid_nonce: {}",
202+
addr, last_sent_valid_nonce
203+
)
200204
}
201205
SubmitError::InvalidPaymentServiceAddress(received_addr, expected_addr) => {
202206
write!(

batcher/aligned/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ async fn main() -> Result<(), AlignedError> {
395395
handle_submit_err(&e).await;
396396
// In the case of an InsufficientBalance error we record and continue processing the entire msg queue.
397397
// This covers the case of multiple submissions that succeed but fail for a comulative balance of all max_fee's.
398-
if let SubmitError::InsufficientBalance(_,_) = e {
398+
if let SubmitError::InsufficientBalance(_, _) = e {
399399
continue;
400400
} else {
401401
return Ok(());
@@ -621,8 +621,7 @@ async fn handle_submit_err(err: &SubmitError) {
621621
SubmitError::InsufficientBalance(sender_address, last_sent_valid_nonce) => {
622622
error!(
623623
"Insufficient balance to pay for the transaction, address: {} last_valid_nonce: {}",
624-
sender_address,
625-
last_sent_valid_nonce
624+
sender_address, last_sent_valid_nonce
626625
)
627626
}
628627
_ => {}

0 commit comments

Comments
 (0)