Use events API to eager send attestations (#7892)

Co-Authored-By: hopinheimer <knmanas6@gmail.com>

Co-Authored-By: hopinheimer <48147533+hopinheimer@users.noreply.github.com>

Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>

Co-Authored-By: Michael Sproul <michael@sigmaprime.io>

Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>
This commit is contained in:
hopinheimer
2026-02-03 20:40:16 -05:00
committed by GitHub
parent c25a975929
commit bd1966353a
12 changed files with 810 additions and 47 deletions

View File

@@ -9,10 +9,12 @@ use metrics::set_gauge;
use monitoring_api::{MonitoringHttpClient, ProcessType};
use sensitive_url::SensitiveUrl;
use slashing_protection::{SLASHING_PROTECTION_FILENAME, SlashingDatabase};
use tokio::sync::Mutex;
use account_utils::validator_definitions::ValidatorDefinitions;
use beacon_node_fallback::{
BeaconNodeFallback, CandidateBeaconNode, start_fallback_updater_service,
BeaconNodeFallback, CandidateBeaconNode, beacon_head_monitor::HeadEvent,
start_fallback_updater_service,
};
use clap::ArgMatches;
use doppelganger_service::DoppelgangerService;
@@ -70,6 +72,8 @@ pub const AGGREGATION_PRE_COMPUTE_EPOCHS: u64 = 2;
/// Number of slots in advance to compute sync selection proofs when in `distributed` mode.
pub const AGGREGATION_PRE_COMPUTE_SLOTS_DISTRIBUTED: u64 = 1;
const MAX_HEAD_EVENT_QUEUE_LEN: usize = 1_024;
type ValidatorStore<E> = LighthouseValidatorStore<SystemTimeSlotClock, E>;
#[derive(Clone)]
@@ -395,6 +399,17 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
beacon_nodes.set_slot_clock(slot_clock.clone());
proposer_nodes.set_slot_clock(slot_clock.clone());
// Only the beacon_nodes are used for attestation duties and thus biconditionally
// proposer_nodes do not need head_send ref.
let head_monitor_rx = if config.enable_beacon_head_monitor {
let (head_monitor_tx, head_receiver) =
mpsc::channel::<HeadEvent>(MAX_HEAD_EVENT_QUEUE_LEN);
beacon_nodes.set_head_send(Arc::new(head_monitor_tx));
Some(Mutex::new(head_receiver))
} else {
None
};
let beacon_nodes = Arc::new(beacon_nodes);
start_fallback_updater_service::<_, E>(context.executor.clone(), beacon_nodes.clone())?;
@@ -505,15 +520,17 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
let block_service = block_service_builder.build()?;
let attestation_service = AttestationServiceBuilder::new()
let attestation_builder = AttestationServiceBuilder::new()
.duties_service(duties_service.clone())
.slot_clock(slot_clock.clone())
.validator_store(validator_store.clone())
.beacon_nodes(beacon_nodes.clone())
.executor(context.executor.clone())
.head_monitor_rx(head_monitor_rx)
.chain_spec(context.eth2_config.spec.clone())
.disable(config.disable_attesting)
.build()?;
.disable(config.disable_attesting);
let attestation_service = attestation_builder.build()?;
let preparation_service = PreparationServiceBuilder::new()
.slot_clock(slot_clock.clone())