Remove reprocess channel (#7437)

Partially https://github.com/sigp/lighthouse/issues/6291


  This PR removes the reprocess event channel from being externally exposed. All work events are now sent through the single `BeaconProcessorSend` channel. I've introduced a new `Work::Reprocess` enum variant which we then use to schedule jobs for reprocess. I've also created a new scheduler module which will eventually house the different scheduler impls.

This is all needed as an initial step to generalize the beacon processor

A "full" implementation for the generalized beacon processor can be found here
https://github.com/sigp/lighthouse/pull/6448

I'm going to try to break up the full implementation into smaller PR's so it can actually be reviewed
This commit is contained in:
Eitan Seri-Levi
2025-06-20 05:52:16 +03:00
committed by GitHub
parent dd98534158
commit f67084a571
17 changed files with 186 additions and 152 deletions

View File

@@ -30,6 +30,7 @@ impl Priority {
}
/// Spawns tasks on the `BeaconProcessor` or directly on the tokio executor.
#[derive(Clone)]
pub struct TaskSpawner<E: EthSpec> {
/// Used to send tasks to the `BeaconProcessor`. The tokio executor will be
/// used if this is `None`.
@@ -155,6 +156,32 @@ impl<E: EthSpec> TaskSpawner<E> {
.and_then(|x| x)
}
}
pub fn try_send(&self, work_event: WorkEvent<E>) -> Result<(), warp::Rejection> {
if let Some(beacon_processor_send) = &self.beacon_processor_send {
let error_message = match beacon_processor_send.try_send(work_event) {
Ok(()) => None,
Err(TrySendError::Full(_)) => {
Some("The task was dropped. The server is overloaded.")
}
Err(TrySendError::Closed(_)) => {
Some("The task was dropped. The server is shutting down.")
}
};
if let Some(error_message) = error_message {
return Err(warp_utils::reject::custom_server_error(
error_message.to_string(),
));
};
Ok(())
} else {
Err(warp_utils::reject::custom_server_error(
"The beacon processor is unavailable".to_string(),
))
}
}
}
/// Send a task to the beacon processor and await execution.