mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
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:
@@ -476,6 +476,17 @@ pub struct ValidatorClient {
|
||||
)]
|
||||
pub beacon_nodes_sync_tolerances: Vec<u64>,
|
||||
|
||||
#[clap(
|
||||
long,
|
||||
help = "Disable the beacon head monitor which tries to attest as soon as any of the \
|
||||
configured beacon nodes sends a head event. Leaving the service enabled is \
|
||||
recommended, but disabling it can lead to reduced bandwidth and more predictable \
|
||||
usage of the primary beacon node (rather than the fastest BN).",
|
||||
display_order = 0,
|
||||
help_heading = FLAG_HEADER
|
||||
)]
|
||||
pub disable_beacon_head_monitor: bool,
|
||||
|
||||
#[clap(
|
||||
long,
|
||||
help = "Disable Lighthouse's slashing protection for all web3signer keys. This can \
|
||||
|
||||
@@ -82,6 +82,8 @@ pub struct Config {
|
||||
pub broadcast_topics: Vec<ApiTopic>,
|
||||
/// Enables a service which attempts to measure latency between the VC and BNs.
|
||||
pub enable_latency_measurement_service: bool,
|
||||
/// Enables the beacon head monitor that reacts to head updates from connected beacon nodes.
|
||||
pub enable_beacon_head_monitor: bool,
|
||||
/// Defines the number of validators per `validator/register_validator` request sent to the BN.
|
||||
pub validator_registration_batch_size: usize,
|
||||
/// Whether we are running with distributed network support.
|
||||
@@ -132,6 +134,7 @@ impl Default for Config {
|
||||
builder_registration_timestamp_override: None,
|
||||
broadcast_topics: vec![ApiTopic::Subscriptions],
|
||||
enable_latency_measurement_service: true,
|
||||
enable_beacon_head_monitor: true,
|
||||
validator_registration_batch_size: 500,
|
||||
distributed: false,
|
||||
initialized_validators: <_>::default(),
|
||||
@@ -377,6 +380,7 @@ impl Config {
|
||||
config.validator_store.builder_boost_factor = validator_client_config.builder_boost_factor;
|
||||
config.enable_latency_measurement_service =
|
||||
!validator_client_config.disable_latency_measurement_service;
|
||||
config.enable_beacon_head_monitor = !validator_client_config.disable_beacon_head_monitor;
|
||||
|
||||
config.validator_registration_batch_size =
|
||||
validator_client_config.validator_registration_batch_size;
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user