Skip to content

Commit c04df5c

Browse files
authored
Merge of #4867
2 parents 7c23625 + 14050bb commit c04df5c

File tree

8 files changed

+173
-127
lines changed

8 files changed

+173
-127
lines changed

book/src/help_vc.md

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ FLAGS:
2626
but is only safe if slashing protection is enabled on the remote signer and is implemented correctly. DO NOT
2727
ENABLE THIS FLAG UNLESS YOU ARE CERTAIN THAT SLASHING PROTECTION IS ENABLED ON THE REMOTE SIGNER. YOU WILL
2828
GET SLASHED IF YOU USE THIS FLAG WITHOUT ENABLING WEB3SIGNER'S SLASHING PROTECTION.
29+
--distributed
30+
Enables functionality required for running the validator in a distributed validator cluster.
31+
2932
--enable-doppelganger-protection
3033
If this flag is set, Lighthouse will delay startup for three epochs and monitor for messages on the network
3134
by any of the validators managed by this client. This will result in three (possibly four) epochs worth of

validator_client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ path = "src/lib.rs"
1010

1111
[dev-dependencies]
1212
tokio = { workspace = true }
13+
itertools = { workspace = true }
1314

1415
[dependencies]
1516
tree_hash = { workspace = true }
@@ -51,7 +52,6 @@ ring = { workspace = true }
5152
rand = { workspace = true, features = ["small_rng"] }
5253
lighthouse_metrics = { workspace = true }
5354
lazy_static = { workspace = true }
54-
itertools = { workspace = true }
5555
monitoring_api = { workspace = true }
5656
sensitive_url = { workspace = true }
5757
task_executor = { workspace = true }

validator_client/src/cli.rs

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
145145
future.")
146146
.takes_value(false)
147147
)
148+
.arg(
149+
Arg::with_name("distributed")
150+
.long("distributed")
151+
.help("Enables functionality required for running the validator in a distributed validator cluster.")
152+
.takes_value(false)
153+
)
148154
/* REST API related arguments */
149155
.arg(
150156
Arg::with_name("http")

validator_client/src/config.rs

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ pub struct Config {
8484
pub builder_boost_factor: Option<u64>,
8585
/// If true, Lighthouse will prefer builder proposals, if available.
8686
pub prefer_builder_proposals: bool,
87+
/// Whether we are running with distributed network support.
88+
pub distributed: bool,
8789
pub web3_signer_keep_alive_timeout: Option<Duration>,
8890
pub web3_signer_max_idle_connections: Option<usize>,
8991
}
@@ -130,6 +132,7 @@ impl Default for Config {
130132
produce_block_v3: false,
131133
builder_boost_factor: None,
132134
prefer_builder_proposals: false,
135+
distributed: false,
133136
web3_signer_keep_alive_timeout: Some(Duration::from_secs(90)),
134137
web3_signer_max_idle_connections: None,
135138
}
@@ -233,6 +236,10 @@ impl Config {
233236
config.beacon_nodes_tls_certs = Some(tls_certs.split(',').map(PathBuf::from).collect());
234237
}
235238

239+
if cli_args.is_present("distributed") {
240+
config.distributed = true;
241+
}
242+
236243
if cli_args.is_present("disable-run-on-all") {
237244
warn!(
238245
log,

validator_client/src/duties_service.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! The `DutiesService` is also responsible for sending events to the `BlockService` which trigger
77
//! block production.
88
9-
mod sync;
9+
pub mod sync;
1010

1111
use crate::beacon_node_fallback::{ApiTopic, BeaconNodeFallback, OfflineOnFailure, RequireSynced};
1212
use crate::http_metrics::metrics::{get_int_gauge, set_int_gauge, ATTESTATION_DUTY};
@@ -42,6 +42,9 @@ const HISTORICAL_DUTIES_EPOCHS: u64 = 2;
4242
/// At start-up selection proofs will be computed with less lookahead out of necessity.
4343
const SELECTION_PROOF_SLOT_LOOKAHEAD: u64 = 8;
4444

45+
/// The attestation selection proof lookahead for those running with the --distributed flag.
46+
const SELECTION_PROOF_SLOT_LOOKAHEAD_DVT: u64 = 1;
47+
4548
/// Fraction of a slot at which selection proof signing should happen (2 means half way).
4649
const SELECTION_PROOF_SCHEDULE_DENOM: u32 = 2;
4750

@@ -211,16 +214,21 @@ pub struct DutiesService<T, E: EthSpec> {
211214
/// proposals for any validators which are not registered locally.
212215
pub proposers: RwLock<ProposerMap>,
213216
/// Map from validator index to sync committee duties.
214-
pub sync_duties: SyncDutiesMap,
217+
pub sync_duties: SyncDutiesMap<E>,
215218
/// Provides the canonical list of locally-managed validators.
216219
pub validator_store: Arc<ValidatorStore<T, E>>,
217220
/// Tracks the current slot.
218221
pub slot_clock: T,
219222
/// Provides HTTP access to remote beacon nodes.
220223
pub beacon_nodes: Arc<BeaconNodeFallback<T, E>>,
221-
pub enable_high_validator_count_metrics: bool,
224+
/// The runtime for spawning tasks.
222225
pub context: RuntimeContext<E>,
226+
/// The current chain spec.
223227
pub spec: ChainSpec,
228+
//// Whether we permit large validator counts in the metrics.
229+
pub enable_high_validator_count_metrics: bool,
230+
/// If this validator is running in distributed mode.
231+
pub distributed: bool,
224232
}
225233

226234
impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
@@ -997,7 +1005,13 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
9971005
continue;
9981006
};
9991007

1000-
let lookahead_slot = current_slot + SELECTION_PROOF_SLOT_LOOKAHEAD;
1008+
let selection_lookahead = if duties_service.distributed {
1009+
SELECTION_PROOF_SLOT_LOOKAHEAD_DVT
1010+
} else {
1011+
SELECTION_PROOF_SLOT_LOOKAHEAD
1012+
};
1013+
1014+
let lookahead_slot = current_slot + selection_lookahead;
10011015

10021016
let mut relevant_duties = duties_by_slot.split_off(&lookahead_slot);
10031017
std::mem::swap(&mut relevant_duties, &mut duties_by_slot);

0 commit comments

Comments
 (0)