merge unstable

This commit is contained in:
Eitan Seri-Levi
2025-03-26 12:42:55 -06:00
391 changed files with 12855 additions and 29793 deletions

View File

@@ -1,7 +1,7 @@
pub use eth2::types::{EventKind, SseBlock, SseFinalizedCheckpoint, SseHead};
use slog::{trace, Logger};
use tokio::sync::broadcast;
use tokio::sync::broadcast::{error::SendError, Receiver, Sender};
use tracing::trace;
use types::EthSpec;
const DEFAULT_CHANNEL_CAPACITY: usize = 16;
@@ -26,18 +26,14 @@ pub struct ServerSentEventHandler<E: EthSpec> {
bls_to_execution_change_tx: Sender<EventKind<E>>,
block_gossip_tx: Sender<EventKind<E>>,
inclusion_list_tx: Sender<EventKind<E>>,
log: Logger,
}
impl<E: EthSpec> ServerSentEventHandler<E> {
pub fn new(log: Logger, capacity_multiplier: usize) -> Self {
Self::new_with_capacity(
log,
capacity_multiplier.saturating_mul(DEFAULT_CHANNEL_CAPACITY),
)
pub fn new(capacity_multiplier: usize) -> Self {
Self::new_with_capacity(capacity_multiplier.saturating_mul(DEFAULT_CHANNEL_CAPACITY))
}
pub fn new_with_capacity(log: Logger, capacity: usize) -> Self {
pub fn new_with_capacity(capacity: usize) -> Self {
let (attestation_tx, _) = broadcast::channel(capacity);
let (single_attestation_tx, _) = broadcast::channel(capacity);
let (block_tx, _) = broadcast::channel(capacity);
@@ -78,17 +74,15 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
bls_to_execution_change_tx,
block_gossip_tx,
inclusion_list_tx,
log,
}
}
pub fn register(&self, kind: EventKind<E>) {
let log_count = |name, count| {
trace!(
self.log,
"Registering server-sent event";
"kind" => name,
"receiver_count" => count
kind = name,
receiver_count = count,
"Registering server-sent event"
);
};
let result = match &kind {
@@ -170,7 +164,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
.map(|count| log_count("inclusion list", count)),
};
if let Err(SendError(event)) = result {
trace!(self.log, "No receivers registered to listen for event"; "event" => ?event);
trace!(?event, "No receivers registered to listen for event");
}
}