Skip to content

Commit b037de8

Browse files
committed
add errors
1 parent 72cfeb2 commit b037de8

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

batcher/aligned-batcher/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ impl Batcher {
10621062
let new_entry_priority = BatchQueueEntryPriority::new(max_fee, nonce);
10631063

10641064
if batch_queue_len + 1 > self.max_batch_proof_qty {
1065+
info!("Batch queue is full. Trying to remove an entry...");
10651066
let (lowest_priority_entry, lowest_priority_entry_priority) =
10661067
get_lowest_priority_entry(&batch_state_lock.batch_queue).unwrap();
10671068

@@ -1071,16 +1072,28 @@ impl Batcher {
10711072
.remove(&lowest_priority_entry)
10721073
.is_none()
10731074
{
1074-
//err
1075+
// If this happens, we have a bug in our code
1076+
error!("Some proofs were not found in the queue. This should not happen.");
1077+
std::mem::drop(batch_state_lock);
1078+
return Err(BatcherError::QueueRemoveError(
1079+
"Some proofs were not found in the queue".into(),
1080+
));
10751081
}
1082+
info!("Removed entry from batch queue.");
10761083

1077-
// todo send msg to the removed entry ws
1084+
send_message(
1085+
lowest_priority_entry.messaging_sink.unwrap(),
1086+
SubmitProofResponseMessage::AddToBatchError,
1087+
)
1088+
.await;
10781089

10791090
batch_state_lock
10801091
.batch_queue
10811092
.push(new_entry, new_entry_priority);
10821093
} else {
1083-
// can't accept the new proof
1094+
error!("Queue is full and fee isn't enough");
1095+
std::mem::drop(batch_state_lock);
1096+
return Err(BatcherError::BatchQueueIsFull);
10841097
}
10851098
} else {
10861099
batch_state_lock

batcher/aligned-batcher/src/types/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub enum BatcherError {
5858
WsSinkEmpty,
5959
AddressNotFoundInUserStates(Address),
6060
QueueRemoveError(String),
61+
BatchQueueIsFull,
6162
}
6263

6364
impl From<tungstenite::Error> for BatcherError {
@@ -139,6 +140,9 @@ impl fmt::Debug for BatcherError {
139140
BatcherError::QueueRemoveError(e) => {
140141
write!(f, "Error while removing entry from queue: {}", e)
141142
}
143+
BatcherError::BatchQueueIsFull => {
144+
write!(f, "Error adding proof, queue is full")
145+
}
142146
}
143147
}
144148
}

0 commit comments

Comments
 (0)