@@ -821,7 +821,7 @@ impl Batcher {
821821 // if they return false
822822
823823 let validation_start = std:: time:: Instant :: now ( ) ;
824-
824+
825825 if !self . msg_chain_id_is_valid ( & client_msg, & ws_conn_sink) . await {
826826 return Ok ( ( ) ) ;
827827 }
@@ -846,8 +846,12 @@ impl Batcher {
846846 else {
847847 return Ok ( ( ) ) ;
848848 } ;
849-
850- debug ! ( "Message validations completed for {:?} in {:?}" , addr_in_msg, validation_start. elapsed( ) ) ;
849+
850+ debug ! (
851+ "Message validations completed for {:?} in {:?}" ,
852+ addr_in_msg,
853+ validation_start. elapsed( )
854+ ) ;
851855
852856 let addr;
853857 let signature = client_msg. signature ;
@@ -887,7 +891,9 @@ impl Batcher {
887891 // We add a dummy user state to grab a lock on the user state
888892 let dummy_user_state = UserState :: new ( U256 :: zero ( ) ) ;
889893 self . user_states
890- . write ( ) . await . insert ( addr, Arc :: new ( Mutex :: new ( dummy_user_state) ) ) ;
894+ . write ( )
895+ . await
896+ . insert ( addr, Arc :: new ( Mutex :: new ( dummy_user_state) ) ) ;
891897 debug ! ( "Dummy user state for address {addr:?} created" ) ;
892898 }
893899
@@ -910,8 +916,12 @@ impl Batcher {
910916 send_message ( ws_conn_sink. clone ( ) , SubmitProofResponseMessage :: ServerBusy ) . await ;
911917 return Ok ( ( ) ) ;
912918 } ;
913-
914- debug ! ( "User lock acquired for {:?} in {:?}" , addr, user_state_start. elapsed( ) ) ;
919+
920+ debug ! (
921+ "User lock acquired for {:?} in {:?}" ,
922+ addr,
923+ user_state_start. elapsed( )
924+ ) ;
915925
916926 // If the user state was not present, we need to get the nonce from the Ethereum contract and update the dummy user state
917927 if !is_user_in_state {
@@ -931,7 +941,11 @@ impl Batcher {
931941 return Ok ( ( ) ) ;
932942 }
933943 } ;
934- warn ! ( "Ethereum nonce fetched for {:?} in {:?}" , addr, nonce_fetch_start. elapsed( ) ) ;
944+ warn ! (
945+ "Ethereum nonce fetched for {:?} in {:?}" ,
946+ addr,
947+ nonce_fetch_start. elapsed( )
948+ ) ;
935949 // Update the dummy user state with the correct nonce
936950 user_state_guard. nonce = ethereum_user_nonce;
937951 }
@@ -1012,7 +1026,11 @@ impl Batcher {
10121026 return Ok ( ( ) ) ;
10131027 }
10141028
1015- debug ! ( "Balance and nonce validations completed for {:?} in {:?}" , addr, balance_validation_start. elapsed( ) ) ;
1029+ debug ! (
1030+ "Balance and nonce validations completed for {:?} in {:?}" ,
1031+ addr,
1032+ balance_validation_start. elapsed( )
1033+ ) ;
10161034
10171035 let proof_verification_start = std:: time:: Instant :: now ( ) ;
10181036 if !self
@@ -1024,7 +1042,11 @@ impl Batcher {
10241042 {
10251043 return Ok ( ( ) ) ;
10261044 }
1027- debug ! ( "Proof verification completed for {:?} in {:?}" , addr, proof_verification_start. elapsed( ) ) ;
1045+ debug ! (
1046+ "Proof verification completed for {:?} in {:?}" ,
1047+ addr,
1048+ proof_verification_start. elapsed( )
1049+ ) ;
10281050
10291051 // * ---------------------------------------------------------------------*
10301052 // * Perform validation over batcher queue *
@@ -1059,7 +1081,9 @@ impl Batcher {
10591081
10601082 // Try to find any candidate whose lock we can acquire and immediately process them
10611083 for candidate_addr in eviction_candidates {
1062- if let Some ( user_state_arc) = self . user_states . read ( ) . await . get ( & candidate_addr) . cloned ( ) {
1084+ if let Some ( user_state_arc) =
1085+ self . user_states . read ( ) . await . get ( & candidate_addr) . cloned ( )
1086+ {
10631087 if let Ok ( mut user_guard) = user_state_arc. try_lock ( ) {
10641088 // Found someone whose lock we can get - now find and remove their entry
10651089 let entries_to_check: Vec < _ > = batch_state_lock
@@ -1093,7 +1117,8 @@ impl Batcher {
10931117 & removed,
10941118 & batch_state_lock. batch_queue ,
10951119 & mut user_guard,
1096- ) . await ;
1120+ )
1121+ . await ;
10971122
10981123 if let Some ( ref removed_entry_ws) = removed. messaging_sink {
10991124 let ws_sink = removed_entry_ws. clone ( ) ;
@@ -1135,7 +1160,11 @@ impl Batcher {
11351160 }
11361161 }
11371162
1138- debug ! ( "Queue management and eviction logic completed for {:?} in {:?}" , addr, queue_management_start. elapsed( ) ) ;
1163+ debug ! (
1164+ "Queue management and eviction logic completed for {:?} in {:?}" ,
1165+ addr,
1166+ queue_management_start. elapsed( )
1167+ ) ;
11391168
11401169 // * ---------------------------------------------------------------------*
11411170 // * Add message data into the queue and update user state *
@@ -1165,9 +1194,17 @@ impl Batcher {
11651194 user_state_guard. last_max_fee_limit = max_fee;
11661195 user_state_guard. proofs_in_batch += 1 ;
11671196 user_state_guard. total_fees_in_queue += max_fee;
1168- debug ! ( "Add to batch and user state update completed for {:?} in {:?}" , addr, add_to_batch_start. elapsed( ) ) ;
1197+ debug ! (
1198+ "Add to batch and user state update completed for {:?} in {:?}" ,
1199+ addr,
1200+ add_to_batch_start. elapsed( )
1201+ ) ;
11691202
1170- debug ! ( "Verification data message handled for {:?} - total time: {:?}" , addr, start_time. elapsed( ) ) ;
1203+ debug ! (
1204+ "Verification data message handled for {:?} - total time: {:?}" ,
1205+ addr,
1206+ start_time. elapsed( )
1207+ ) ;
11711208 Ok ( ( ) )
11721209 }
11731210
@@ -1429,10 +1466,10 @@ impl Batcher {
14291466
14301467 // Update metrics
14311468 let queue_len = batch_state_lock. batch_queue . len ( ) ;
1432- let queue_size_bytes: i64 = 0 ;
1469+ let queue_size_bytes: i64 = 0 ;
14331470 // let queue_size_bytes = calculate_batch_size(&batch_state_lock.batch_queue)?;
14341471 self . metrics
1435- . update_queue_metrics ( queue_len as i64 , queue_size_bytes as i64 ) ;
1472+ . update_queue_metrics ( queue_len as i64 , queue_size_bytes) ;
14361473
14371474 info ! ( "Current batch queue length: {}" , queue_len) ;
14381475
@@ -1587,7 +1624,10 @@ impl Batcher {
15871624 /// Cleans up user states after successful batch submission.
15881625 /// Resets last_max_fee_limit to U256::MAX for users who had proofs in the submitted batch
15891626 /// but now have no proofs left in the queue.
1590- async fn cleanup_user_states_after_successful_submission ( & self , finalized_batch : & [ BatchQueueEntry ] ) {
1627+ async fn cleanup_user_states_after_successful_submission (
1628+ & self ,
1629+ finalized_batch : & [ BatchQueueEntry ] ,
1630+ ) {
15911631 use std:: collections:: HashSet ;
15921632
15931633 // Get unique users from the submitted batch
@@ -1611,7 +1651,8 @@ impl Batcher {
16111651 for user_addr in users_in_batch {
16121652 if !current_user_states. contains_key ( & user_addr) {
16131653 // User has no proofs left in queue - reset their max_fee_limit
1614- if let Some ( user_state_ref) = self . user_states . read ( ) . await . get ( & user_addr) . cloned ( ) {
1654+ if let Some ( user_state_ref) = self . user_states . read ( ) . await . get ( & user_addr) . cloned ( )
1655+ {
16151656 if let Ok ( mut user_state_guard) = user_state_ref. try_lock ( ) {
16161657 user_state_guard. last_max_fee_limit = U256 :: max_value ( ) ;
16171658 }
@@ -1832,7 +1873,8 @@ impl Batcher {
18321873 }
18331874
18341875 // Clean up user states for users who had proofs in this batch but now have no proofs left
1835- self . cleanup_user_states_after_successful_submission ( finalized_batch) . await ;
1876+ self . cleanup_user_states_after_successful_submission ( finalized_batch)
1877+ . await ;
18361878
18371879 connection:: send_batch_inclusion_data_responses ( finalized_batch, & batch_merkle_tree) . await
18381880 }
0 commit comments