Skip to content

Commit 5e6465a

Browse files
fix: replace biased select with timeout for proof reception to prevent indefinite blocking
1 parent 4f9900f commit 5e6465a

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

forester/src/processor/v2/tx_sender.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -407,22 +407,10 @@ impl<R: Rpc> TxSender<R> {
407407
});
408408
}
409409

410-
// Use biased select to ensure the 1-second sleep branch is checked first.
411-
// This guarantees periodic re-evaluation of sender eligibility even when
412-
// proof_rx.recv() would otherwise block indefinitely waiting for proofs.
413-
// Near epoch boundaries, this prevents getting stuck waiting on proofs
414-
// when the forester's eligibility window is about to end.
415-
let result = tokio::select! {
416-
biased;
417-
_ = tokio::time::sleep(Duration::from_secs(1)) => {
418-
continue;
419-
}
420-
result = proof_rx.recv() => {
421-
match result {
422-
Some(r) => r,
423-
None => break,
424-
}
425-
}
410+
let result = match tokio::time::timeout(Duration::from_secs(1), proof_rx.recv()).await {
411+
Ok(Some(r)) => r,
412+
Ok(None) => break,
413+
Err(_) => continue,
426414
};
427415

428416
let current_slot = self.context.slot_tracker.estimated_current_slot();

0 commit comments

Comments
 (0)