Skip to content

Commit 80cd8bd

Browse files
Add --disable-attesting flag to validator client (#7046)
Cleaned up and isolated version of the `--disable-attesting` flag for the VC, from the `holesky-rescue` branch: - #7041 I figured we don't need the `--disable-attesting` flag on the BN for now, and it was a much more invasive impl.
1 parent fe0cf9c commit 80cd8bd

File tree

7 files changed

+43
-0
lines changed

7 files changed

+43
-0
lines changed

book/src/help_vc.md

+4
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ Flags:
175175
If this flag is set, Lighthouse will query the Beacon Node for only
176176
block headers during proposals and will sign over headers. Useful for
177177
outsourcing execution payload construction during proposals.
178+
--disable-attesting
179+
Disable the performance of attestation duties (and sync committee
180+
duties). This flag should only be used in emergencies to prioritise
181+
block proposal duties.
178182
--disable-auto-discover
179183
If present, do not attempt to discover new validators in the
180184
validators-dir. Validators will need to be manually added to the

validator_client/src/cli.rs

+9
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ pub struct ValidatorClient {
9797
)]
9898
pub disable_auto_discover: bool,
9999

100+
#[clap(
101+
long,
102+
help = "Disable the performance of attestation duties (and sync committee duties). This \
103+
flag should only be used in emergencies to prioritise block proposal duties.",
104+
display_order = 0,
105+
help_heading = FLAG_HEADER
106+
)]
107+
pub disable_attesting: bool,
108+
100109
#[clap(
101110
long,
102111
help = "If present, the validator client will use longer timeouts for requests \

validator_client/src/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub struct Config {
8585
/// Configuration for the initialized validators
8686
#[serde(flatten)]
8787
pub initialized_validators: InitializedValidatorsConfig,
88+
pub disable_attesting: bool,
8889
}
8990

9091
impl Default for Config {
@@ -126,6 +127,7 @@ impl Default for Config {
126127
validator_registration_batch_size: 500,
127128
distributed: false,
128129
initialized_validators: <_>::default(),
130+
disable_attesting: false,
129131
}
130132
}
131133
}
@@ -379,6 +381,8 @@ impl Config {
379381
true
380382
};
381383

384+
config.disable_attesting = validator_client_config.disable_attesting;
385+
382386
Ok(config)
383387
}
384388
}

validator_client/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
478478
context: duties_context,
479479
enable_high_validator_count_metrics: config.enable_high_validator_count_metrics,
480480
distributed: config.distributed,
481+
disable_attesting: config.disable_attesting,
481482
});
482483

483484
// Update the metrics server.
@@ -507,6 +508,7 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
507508
.validator_store(validator_store.clone())
508509
.beacon_nodes(beacon_nodes.clone())
509510
.runtime_context(context.service_context("attestation".into()))
511+
.disable(config.disable_attesting)
510512
.build()?;
511513

512514
let preparation_service = PreparationServiceBuilder::new()

validator_client/validator_services/src/attestation_service.rs

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct AttestationServiceBuilder<T: SlotClock + 'static, E: EthSpec> {
2121
slot_clock: Option<T>,
2222
beacon_nodes: Option<Arc<BeaconNodeFallback<T, E>>>,
2323
context: Option<RuntimeContext<E>>,
24+
disable: bool,
2425
}
2526

2627
impl<T: SlotClock + 'static, E: EthSpec> AttestationServiceBuilder<T, E> {
@@ -31,6 +32,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationServiceBuilder<T, E> {
3132
slot_clock: None,
3233
beacon_nodes: None,
3334
context: None,
35+
disable: false,
3436
}
3537
}
3638

@@ -59,6 +61,11 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationServiceBuilder<T, E> {
5961
self
6062
}
6163

64+
pub fn disable(mut self, disable: bool) -> Self {
65+
self.disable = disable;
66+
self
67+
}
68+
6269
pub fn build(self) -> Result<AttestationService<T, E>, String> {
6370
Ok(AttestationService {
6471
inner: Arc::new(Inner {
@@ -77,6 +84,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationServiceBuilder<T, E> {
7784
context: self
7885
.context
7986
.ok_or("Cannot build AttestationService without runtime_context")?,
87+
disable: self.disable,
8088
}),
8189
})
8290
}
@@ -89,6 +97,7 @@ pub struct Inner<T, E: EthSpec> {
8997
slot_clock: T,
9098
beacon_nodes: Arc<BeaconNodeFallback<T, E>>,
9199
context: RuntimeContext<E>,
100+
disable: bool,
92101
}
93102

94103
/// Attempts to produce attestations for all known validators 1/3rd of the way through each slot.
@@ -120,6 +129,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
120129
/// Starts the service which periodically produces attestations.
121130
pub fn start_update_service(self, spec: &ChainSpec) -> Result<(), String> {
122131
let log = self.context.log().clone();
132+
if self.disable {
133+
info!(log, "Attestation service disabled");
134+
return Ok(());
135+
}
123136

124137
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
125138
let duration_to_next_slot = self

validator_client/validator_services/src/duties_service.rs

+6
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ pub struct DutiesService<T, E: EthSpec> {
230230
pub enable_high_validator_count_metrics: bool,
231231
/// If this validator is running in distributed mode.
232232
pub distributed: bool,
233+
pub disable_attesting: bool,
233234
}
234235

235236
impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
@@ -403,6 +404,11 @@ pub fn start_update_service<T: SlotClock + 'static, E: EthSpec>(
403404
"duties_service_proposers",
404405
);
405406

407+
// Skip starting attestation duties or sync committee services.
408+
if core_duties_service.disable_attesting {
409+
return;
410+
}
411+
406412
/*
407413
* Spawn the task which keeps track of local attestation duties.
408414
*/

validator_client/validator_services/src/sync_committee_service.rs

+5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ impl<T: SlotClock + 'static, E: EthSpec> SyncCommitteeService<T, E> {
8787

8888
pub fn start_update_service(self, spec: &ChainSpec) -> Result<(), String> {
8989
let log = self.context.log().clone();
90+
if self.duties_service.disable_attesting {
91+
info!(log, "Sync committee service disabled");
92+
return Ok(());
93+
}
94+
9095
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
9196
let duration_to_next_slot = self
9297
.slot_clock

0 commit comments

Comments
 (0)