|
3 | 3 | //! responsible for handling events from these components and coordinating their actions. |
4 | 4 |
|
5 | 5 | use super::Consensus; |
| 6 | +use crate::poll_nested_stream_with_budget; |
6 | 7 | use alloy_primitives::Signature; |
7 | 8 | use alloy_provider::Provider; |
8 | 9 | use futures::StreamExt; |
@@ -41,6 +42,9 @@ use rollup_node_providers::{L1MessageProvider, L1Provider}; |
41 | 42 | use scroll_db::Database; |
42 | 43 | use scroll_derivation_pipeline::DerivationPipeline; |
43 | 44 |
|
| 45 | +mod budget; |
| 46 | +use budget::L1_NOTIFICATION_CHANNEL_BUDGET; |
| 47 | + |
44 | 48 | mod command; |
45 | 49 | pub use command::RollupManagerCommand; |
46 | 50 |
|
@@ -473,14 +477,19 @@ where |
473 | 477 | } |
474 | 478 | ); |
475 | 479 |
|
| 480 | + let mut maybe_more_l1_rx_events = false; |
476 | 481 | proceed_if!( |
477 | 482 | en_synced, |
478 | | - // Drain all L1 notifications. |
479 | | - while let Some(Poll::Ready(Some(event))) = |
480 | | - this.l1_notification_rx.as_mut().map(|rx| rx.poll_next_unpin(cx)) |
481 | | - { |
482 | | - this.handle_l1_notification((*event).clone()); |
483 | | - } |
| 483 | + maybe_more_l1_rx_events = poll_nested_stream_with_budget!( |
| 484 | + "l1_notification_rx", |
| 485 | + "L1Notification channel", |
| 486 | + L1_NOTIFICATION_CHANNEL_BUDGET, |
| 487 | + this.l1_notification_rx |
| 488 | + .as_mut() |
| 489 | + .map(|rx| rx.poll_next_unpin(cx)) |
| 490 | + .unwrap_or(Poll::Ready(None)), |
| 491 | + |event: Arc<L1Notification>| this.handle_l1_notification((*event).clone()), |
| 492 | + ) |
484 | 493 | ); |
485 | 494 |
|
486 | 495 | // Drain all Indexer events. |
@@ -551,6 +560,10 @@ where |
551 | 560 | this.handle_network_manager_event(event); |
552 | 561 | } |
553 | 562 |
|
| 563 | + if maybe_more_l1_rx_events { |
| 564 | + cx.waker().wake_by_ref(); |
| 565 | + } |
| 566 | + |
554 | 567 | Poll::Pending |
555 | 568 | } |
556 | 569 | } |
|
0 commit comments