Skip to content

Commit 96def6c

Browse files
committed
refactor: comments, tracing and err messages
1 parent c48c272 commit 96def6c

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

crates/batcher/src/lib.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -933,13 +933,6 @@ impl Batcher {
933933
return Ok(());
934934
};
935935

936-
// Finally, we remove the mutex from the map
937-
//
938-
// Note: this removal is safe even if other processes are waiting on the lock
939-
// This is because it is wrapped on an Arc so the variable will still live until all clones are dropped.
940-
let mut user_mutexes = self.user_proof_processing_mutexes.lock().await;
941-
user_mutexes.remove(&addr);
942-
943936
info!("Verification data message handled");
944937
Ok(())
945938
}
@@ -1072,6 +1065,10 @@ impl Batcher {
10721065
// note that the entries are considered equal for the priority queue
10731066
// if they have the same nonce and sender, so we can remove the old entry
10741067
// by calling remove with the new entry
1068+
//
1069+
// Note: If `remove` returns `None`, it means the proof was already removed—
1070+
// likely by the batch building process running in parallel.
1071+
// This is rare but expected due to concurrent access.
10751072
let mut batch_state_lock = self.batch_state.lock().await;
10761073
if batch_state_lock
10771074
.batch_queue
@@ -1082,7 +1079,7 @@ impl Batcher {
10821079
warn!("Replacement entry for {addr:?} was not present in batcher queue");
10831080
send_message(
10841081
ws_conn_sink.clone(),
1085-
SubmitProofResponseMessage::AddToBatchError,
1082+
SubmitProofResponseMessage::InvalidReplacementMessage,
10861083
)
10871084
.await;
10881085
return;
@@ -1241,16 +1238,11 @@ impl Batcher {
12411238
}
12421239

12431240
/// Given a new block number listened from the blockchain, checks if the current batch is ready to be posted.
1244-
///
12451241
/// There are essentially two conditions to be checked:
12461242
/// * Has the current batch reached the minimum size to be posted?
12471243
/// * Has the received block number surpassed the maximum interval with respect to the last posted batch block?
12481244
///
1249-
/// If both are met then:
1250-
/// * We acquire the building batch mutex to stop processing new proof messages
1251-
/// * We acquire all the users locks to wait until all current proof messages are processed
1252-
///
1253-
/// Once we hold them, the biggest possible batch will be built, making sure that:
1245+
/// Then the batch will be made as big as possible given this two conditions:
12541246
/// * The serialized batch size needs to be smaller than the maximum batch size
12551247
/// * The batch submission fee is less than the lowest `max fee` included the batch,
12561248
/// * And the batch submission fee is more than the highest `max fee` not included the batch.
@@ -1283,6 +1275,7 @@ impl Batcher {
12831275
return None;
12841276
}
12851277

1278+
info!("Trying to build a new batch...");
12861279
let batch_queue_copy = {
12871280
let batch_state_lock = self.batch_state.lock().await;
12881281
batch_state_lock.batch_queue.clone()

0 commit comments

Comments
 (0)