Skip to content

Commit 91ba39a

Browse files
committed
chore: cargo fmt
1 parent e513997 commit 91ba39a

File tree

5 files changed

+62
-25
lines changed

5 files changed

+62
-25
lines changed

batcher/aligned-batcher/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ impl Batcher {
12731273
self.cancel_create_new_task_tx(fee_params.gas_price).await;
12741274
Err(BatcherError::ReceiptNotFoundError)
12751275
}
1276-
Err(RetryError::Permanent(e))|Err(RetryError::Transient(e)) => Err(e),
1276+
Err(RetryError::Permanent(e)) | Err(RetryError::Transient(e)) => Err(e),
12771277
}
12781278
}
12791279

batcher/aligned-batcher/src/retry/batcher_retryables.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ pub async fn create_new_task_retryable(
129129
Err(ContractError::Revert(err)) => {
130130
// Since transaction was reverted, we don't want to retry with fallback.
131131
warn!("Transaction reverted {:?}", err);
132-
return Err(RetryError::Permanent(BatcherError::TransactionSendError(err.to_string())));
132+
return Err(RetryError::Permanent(BatcherError::TransactionSendError(
133+
err.to_string(),
134+
)));
133135
}
134136
_ => {
135137
call_fallback = payment_service_fallback
@@ -146,9 +148,15 @@ pub async fn create_new_task_retryable(
146148
Ok(pending_tx) => pending_tx,
147149
Err(ContractError::Revert(err)) => {
148150
warn!("Transaction reverted {:?}", err);
149-
return Err(RetryError::Permanent(BatcherError::TransactionSendError(err.to_string())));
151+
return Err(RetryError::Permanent(BatcherError::TransactionSendError(
152+
err.to_string(),
153+
)));
154+
}
155+
Err(err) => {
156+
return Err(RetryError::Transient(BatcherError::TransactionSendError(
157+
err.to_string(),
158+
)))
150159
}
151-
Err(err) => return Err(RetryError::Transient(BatcherError::TransactionSendError(err.to_string()))),
152160
}
153161
}
154162
};

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

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ pub async fn send_messages(
5656

5757
nonce += U256::one();
5858
let msg = ClientMessage::new(verification_data.clone(), wallet.clone()).await;
59-
let msg_bin = match cbor_serialize(&msg).map_err(SubmitError::SerializationError) {
59+
let msg_bin = match cbor_serialize(&msg) {
6060
Ok(bin) => bin,
6161
Err(e) => {
6262
error!("Error while serializing message: {:?}", e);
63-
sent_verification_data.push(Err(e));
63+
sent_verification_data.push(Err(SubmitError::SerializationError(e)));
6464
return sent_verification_data;
6565
}
6666
};
67-
67+
6868
// Send the message
6969
if let Err(e) = ws_write.send(Message::Binary(msg_bin.clone())).await {
7070
error!("Error while sending message: {:?}", e);
@@ -75,7 +75,7 @@ pub async fn send_messages(
7575
debug!("{:?} Message sent", idx);
7676

7777
// Save the verification data commitment to read its response later
78-
sent_verification_data.push(Ok(verification_data));
78+
sent_verification_data.push(Ok(verification_data));
7979
}
8080

8181
info!("All proofs sent");
@@ -108,10 +108,14 @@ pub async fn receive(
108108
if let Message::Close(close_frame) = msg {
109109
warn!("Unexpected WS close");
110110
if let Some(close_msg) = close_frame {
111-
aligned_submitted_data.push(Err(SubmitError::WebSocketClosedUnexpectedlyError(close_msg.to_owned())));
111+
aligned_submitted_data.push(Err(SubmitError::WebSocketClosedUnexpectedlyError(
112+
close_msg.to_owned(),
113+
)));
112114
break;
113115
}
114-
aligned_submitted_data.push(Err(SubmitError::GenericError("Connection was closed before receive() processed all sent messages ".to_string())));
116+
aligned_submitted_data.push(Err(SubmitError::GenericError(
117+
"Connection was closed before receive() processed all sent messages ".to_string(),
118+
)));
115119
break;
116120
}
117121

@@ -126,16 +130,25 @@ pub async fn receive(
126130
}
127131
};
128132

129-
let related_verification_data = match match_batcher_response_with_stored_verification_data(&batch_inclusion_data_message, &mut sent_verification_data_rev) {
133+
let related_verification_data = match match_batcher_response_with_stored_verification_data(
134+
&batch_inclusion_data_message,
135+
&mut sent_verification_data_rev,
136+
) {
130137
Ok(data) => data,
131138
Err(e) => {
132-
warn!("Error while matching batcher response with sent data: {:?}", e);
139+
warn!(
140+
"Error while matching batcher response with sent data: {:?}",
141+
e
142+
);
133143
aligned_submitted_data.push(Err(e));
134144
break;
135145
}
136146
};
137147

138-
let aligned_verification_data = match process_batcher_response(&batch_inclusion_data_message, &related_verification_data) {
148+
let aligned_verification_data = match process_batcher_response(
149+
&batch_inclusion_data_message,
150+
&related_verification_data,
151+
) {
139152
Ok(data) => data,
140153
Err(e) => {
141154
warn!("Error while processing batcher response: {:?}", e);
@@ -254,7 +267,10 @@ fn match_batcher_response_with_stored_verification_data(
254267
) -> Result<VerificationDataCommitment, SubmitError> {
255268
debug!("Matching verification data with batcher response ...");
256269
let mut index = None;
257-
for (i, sent_nonced_verification_data) in sent_verification_data_rev.iter_mut().enumerate().rev() { // iterate in reverse since the last element is the most probable to match
270+
for (i, sent_nonced_verification_data) in
271+
sent_verification_data_rev.iter_mut().enumerate().rev()
272+
{
273+
// iterate in reverse since the last element is the most probable to match
258274
if let Ok(sent_nonced_verification_data) = sent_nonced_verification_data {
259275
if sent_nonced_verification_data.nonce == batch_inclusion_data.user_nonce {
260276
debug!("local nonced verification data matched with batcher response");
@@ -276,7 +292,9 @@ fn match_batcher_response_with_stored_verification_data(
276292
// Returns the biggest nonce from the sent verification data
277293
// Used to know which is the last proof sent to the Batcher,
278294
// to know when to stop reading the WS for responses
279-
fn get_biggest_nonce(sent_verification_data: &[Result<NoncedVerificationData, SubmitError>]) -> U256 {
295+
fn get_biggest_nonce(
296+
sent_verification_data: &[Result<NoncedVerificationData, SubmitError>],
297+
) -> U256 {
280298
let mut biggest_nonce = U256::zero();
281299
for verification_data in sent_verification_data.iter() {
282300
if let Ok(verification_data) = verification_data {

batcher/aligned-sdk/src/sdk.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ pub async fn submit_multiple_and_wait_verification(
101101
let mut error_awaiting_batch_verification: Option<errors::SubmitError> = None;
102102
for aligned_verification_data_item in aligned_verification_data.iter() {
103103
if let Ok(aligned_verification_data_item) = aligned_verification_data_item {
104-
if let Err(e) = await_batch_verification(aligned_verification_data_item, eth_rpc_url, network).await {
104+
if let Err(e) =
105+
await_batch_verification(aligned_verification_data_item, eth_rpc_url, network).await
106+
{
105107
error_awaiting_batch_verification = Some(e);
106108
break;
107109
}
@@ -250,9 +252,7 @@ pub async fn submit_multiple(
250252
) -> Vec<Result<AlignedVerificationData, errors::SubmitError>> {
251253
let (ws_stream, _) = match connect_async(batcher_url).await {
252254
Ok((ws_stream, response)) => (ws_stream, response),
253-
Err(e) => {
254-
return vec![Err(errors::SubmitError::WebSocketConnectionError(e))]
255-
}
255+
Err(e) => return vec![Err(errors::SubmitError::WebSocketConnectionError(e))],
256256
};
257257

258258
debug!("WebSocket handshake has been successfully completed");
@@ -407,7 +407,9 @@ pub async fn submit_and_wait_verification(
407407
match aligned_verification_data.get(0) {
408408
Some(Ok(aligned_verification_data)) => Ok(aligned_verification_data.clone()),
409409
Some(Err(e)) => Err(errors::SubmitError::GenericError(e.to_string())),
410-
None => Err(errors::SubmitError::GenericError("No response from the batcher".to_string())),
410+
None => Err(errors::SubmitError::GenericError(
411+
"No response from the batcher".to_string(),
412+
)),
411413
}
412414
}
413415

@@ -460,7 +462,9 @@ pub async fn submit(
460462
match aligned_verification_data.get(0) {
461463
Some(Ok(aligned_verification_data)) => Ok(aligned_verification_data.clone()),
462464
Some(Err(e)) => Err(errors::SubmitError::GenericError(e.to_string())),
463-
None => Err(errors::SubmitError::GenericError("No response from the batcher".to_string())),
465+
None => Err(errors::SubmitError::GenericError(
466+
"No response from the batcher".to_string(),
467+
)),
464468
}
465469
}
466470

@@ -687,7 +691,10 @@ pub fn save_response(
687691
batch_inclusion_data_directory_path: PathBuf,
688692
aligned_verification_data: &AlignedVerificationData,
689693
) -> Result<(), errors::FileError> {
690-
info!("Saving batch inclusion data files in folder {}", batch_inclusion_data_directory_path.display());
694+
info!(
695+
"Saving batch inclusion data files in folder {}",
696+
batch_inclusion_data_directory_path.display()
697+
);
691698
save_response_cbor(
692699
batch_inclusion_data_directory_path.clone(),
693700
&aligned_verification_data.clone(),

batcher/aligned/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,17 @@ async fn main() -> Result<(), AlignedError> {
336336
for aligned_verification_data in aligned_verification_data_vec {
337337
match aligned_verification_data {
338338
Ok(aligned_verification_data) => {
339-
info!("Proof submitted to aligned. Batch merkle root: 0x{}", hex::encode(aligned_verification_data.batch_merkle_root));
339+
info!(
340+
"Proof submitted to aligned. Batch merkle root: 0x{}",
341+
hex::encode(aligned_verification_data.batch_merkle_root)
342+
);
340343
save_response(
341344
batch_inclusion_data_directory_path.clone(),
342345
&aligned_verification_data,
343346
)?;
344-
unique_batch_merkle_roots.insert(aligned_verification_data.batch_merkle_root);
345-
},
347+
unique_batch_merkle_roots
348+
.insert(aligned_verification_data.batch_merkle_root);
349+
}
346350
Err(e) => {
347351
warn!("Error while submitting proof: {:?}", e);
348352
let nonce_file = format!("nonce_{:?}.bin", wallet.address());

0 commit comments

Comments
 (0)