diff --git a/lighthouse/tests/validator_client.rs b/lighthouse/tests/validator_client.rs index 062b7e7786a..4420a980616 100644 --- a/lighthouse/tests/validator_client.rs +++ b/lighthouse/tests/validator_client.rs @@ -427,6 +427,21 @@ fn no_doppelganger_protection_flag() { .run() .with_config(|config| assert!(!config.enable_doppelganger_protection)); } +#[test] +fn produce_block_v3_flag() { + CommandLineTest::new() + .flag("produce-block-v3", None) + .run() + .with_config(|config| assert!(config.produce_block_v3)); +} + +#[test] +fn no_produce_block_v3_flag() { + CommandLineTest::new() + .run() + .with_config(|config| assert!(!config.produce_block_v3)); +} + #[test] fn block_delay_ms() { CommandLineTest::new() diff --git a/validator_client/src/block_service.rs b/validator_client/src/block_service.rs index d4afb911330..a05fe3a480c 100644 --- a/validator_client/src/block_service.rs +++ b/validator_client/src/block_service.rs @@ -334,18 +334,8 @@ impl BlockService { ) } - let deneb_fork_activated = self - .context - .eth2_config - .spec - .altair_fork_epoch - .and_then(|fork_epoch| { - let current_epoch = self.slot_clock.now()?.epoch(E::slots_per_epoch()); - Some(current_epoch >= fork_epoch) - }) - .unwrap_or(false); - - if deneb_fork_activated { + // TODO: activate automatically at Deneb + if !self.validator_store.produce_block_v3() { for validator_pubkey in proposers { let service = self.clone(); let log = log.clone(); @@ -457,6 +447,7 @@ impl BlockService { Ok(()) } + #[allow(clippy::too_many_arguments)] async fn handle_block_response>( &self, log: &Logger, diff --git a/validator_client/src/cli.rs b/validator_client/src/cli.rs index 0af92a9e39a..4aa0eb6f987 100644 --- a/validator_client/src/cli.rs +++ b/validator_client/src/cli.rs @@ -153,6 +153,14 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .value_name("FEE-RECIPIENT") .takes_value(true) ) + .arg( + Arg::with_name("produce-block-v3") + .long("produce-block-v3") + .help("Enable block production via the block v3 endpoint for this validator client. \ + This should only be enabled when paired with a beacon node \ + that has this endpoint implemented.") + .takes_value(false) + ) /* REST API related arguments */ .arg( Arg::with_name("http") diff --git a/validator_client/src/config.rs b/validator_client/src/config.rs index 7c662db9371..a90bc21fcf0 100644 --- a/validator_client/src/config.rs +++ b/validator_client/src/config.rs @@ -79,6 +79,8 @@ pub struct Config { pub enable_latency_measurement_service: bool, /// Defines the number of validators per `validator/register_validator` request sent to the BN. pub validator_registration_batch_size: usize, + /// Enables block production via the block v3 endpoint. This configuration option can be removed post deneb. + pub produce_block_v3: bool, } impl Default for Config { @@ -120,6 +122,7 @@ impl Default for Config { disable_run_on_all: false, enable_latency_measurement_service: true, validator_registration_batch_size: 500, + produce_block_v3: false, } } } @@ -361,6 +364,10 @@ impl Config { config.builder_proposals = true; } + if cli_args.is_present("produce-block-v3") { + config.produce_block_v3 = true; + } + config.gas_limit = cli_args .value_of("gas-limit") .map(|gas_limit| { diff --git a/validator_client/src/validator_store.rs b/validator_client/src/validator_store.rs index 365f7f73474..703b6901b3c 100644 --- a/validator_client/src/validator_store.rs +++ b/validator_client/src/validator_store.rs @@ -97,6 +97,7 @@ pub struct ValidatorStore { fee_recipient_process: Option
, gas_limit: Option, builder_proposals: bool, + produce_block_v3: bool, task_executor: TaskExecutor, _phantom: PhantomData, } @@ -128,6 +129,7 @@ impl ValidatorStore { fee_recipient_process: config.fee_recipient, gas_limit: config.gas_limit, builder_proposals: config.builder_proposals, + produce_block_v3: config.produce_block_v3, task_executor, _phantom: PhantomData, } @@ -336,6 +338,10 @@ impl ValidatorStore { self.spec.fork_at_epoch(epoch) } + pub fn produce_block_v3(&self) -> bool { + self.produce_block_v3 + } + /// Returns a `SigningMethod` for `validator_pubkey` *only if* that validator is considered safe /// by doppelganger protection. fn doppelganger_checked_signing_method(