Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge queue: embarking release-v7.0.0 (80cd8bd) and [#7047 + #7050] together #7077

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/bellatrix_readiness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
return BellatrixReadiness::NotSynced;
}
let params = MergeConfig::from_chainspec(&self.spec);
let current_difficulty = el.get_current_difficulty().await.ok();
let current_difficulty = el.get_current_difficulty().await.ok().flatten();
BellatrixReadiness::Ready {
config: params,
current_difficulty,
Expand Down
9 changes: 8 additions & 1 deletion beacon_node/execution_layer/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,18 @@ pub struct ExecutionBlock {
pub block_number: u64,

pub parent_hash: ExecutionBlockHash,
pub total_difficulty: Uint256,
pub total_difficulty: Option<Uint256>,
#[serde(with = "serde_utils::u64_hex_be")]
pub timestamp: u64,
}

impl ExecutionBlock {
pub fn terminal_total_difficulty_reached(&self, terminal_total_difficulty: Uint256) -> bool {
self.total_difficulty
.is_none_or(|td| td >= terminal_total_difficulty)
}
}

#[superstruct(
variants(V1, V2, V3),
variant_attributes(derive(Clone, Debug, Eq, Hash, PartialEq),),
Expand Down
16 changes: 10 additions & 6 deletions beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ impl<E: EthSpec> ExecutionLayer<E> {
}

/// Get the current difficulty of the PoW chain.
pub async fn get_current_difficulty(&self) -> Result<Uint256, ApiError> {
pub async fn get_current_difficulty(&self) -> Result<Option<Uint256>, ApiError> {
let block = self
.engine()
.api
Expand Down Expand Up @@ -1680,7 +1680,8 @@ impl<E: EthSpec> ExecutionLayer<E> {
self.execution_blocks().await.put(block.block_hash, block);

loop {
let block_reached_ttd = block.total_difficulty >= spec.terminal_total_difficulty;
let block_reached_ttd =
block.terminal_total_difficulty_reached(spec.terminal_total_difficulty);
if block_reached_ttd {
if block.parent_hash == ExecutionBlockHash::zero() {
return Ok(Some(block));
Expand All @@ -1689,7 +1690,8 @@ impl<E: EthSpec> ExecutionLayer<E> {
.get_pow_block(engine, block.parent_hash)
.await?
.ok_or(ApiError::ExecutionBlockNotFound(block.parent_hash))?;
let parent_reached_ttd = parent.total_difficulty >= spec.terminal_total_difficulty;
let parent_reached_ttd =
parent.terminal_total_difficulty_reached(spec.terminal_total_difficulty);

if block_reached_ttd && !parent_reached_ttd {
return Ok(Some(block));
Expand Down Expand Up @@ -1765,9 +1767,11 @@ impl<E: EthSpec> ExecutionLayer<E> {
parent: ExecutionBlock,
spec: &ChainSpec,
) -> bool {
let is_total_difficulty_reached = block.total_difficulty >= spec.terminal_total_difficulty;
let is_parent_total_difficulty_valid =
parent.total_difficulty < spec.terminal_total_difficulty;
let is_total_difficulty_reached =
block.terminal_total_difficulty_reached(spec.terminal_total_difficulty);
let is_parent_total_difficulty_valid = parent
.total_difficulty
.is_some_and(|td| td < spec.terminal_total_difficulty);
is_total_difficulty_reached && is_parent_total_difficulty_valid
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ impl<E: EthSpec> Block<E> {
block_hash: block.block_hash,
block_number: block.block_number,
parent_hash: block.parent_hash,
total_difficulty: block.total_difficulty,
total_difficulty: Some(block.total_difficulty),
timestamp: block.timestamp,
},
Block::PoS(payload) => ExecutionBlock {
block_hash: payload.block_hash(),
block_number: payload.block_number(),
parent_hash: payload.parent_hash(),
total_difficulty,
total_difficulty: Some(total_difficulty),
timestamp: payload.timestamp(),
},
}
Expand Down
7 changes: 7 additions & 0 deletions book/src/help_vc.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ Flags:
contain sensitive information about your validator and so this flag
should be used with caution. For Windows users, the log file
permissions will be inherited from the parent folder.
--long-timeouts-multiplier <LONG_TIMEOUTS_MULTIPLIER>
If present, the validator client will use a multiplier for the timeout
when making requests to the beacon node. This only takes effect when
the `--use-long-timeouts` flag is present. The timeouts will be the
slot duration multiplied by this value. This flag is generally not
recommended, longer timeouts can cause missed duties when fallbacks
are used. [default: 1]
--metrics
Enable the Prometheus metrics HTTP server. Disabled by default.
--prefer-builder-proposals
Expand Down
16 changes: 16 additions & 0 deletions lighthouse/tests/validator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ fn use_long_timeouts_flag() {
.with_config(|config| assert!(config.use_long_timeouts));
}

#[test]
fn long_timeouts_multiplier_flag_default() {
CommandLineTest::new()
.run()
.with_config(|config| assert_eq!(config.long_timeouts_multiplier, 1));
}

#[test]
fn long_timeouts_multiplier_flag() {
CommandLineTest::new()
.flag("use-long-timeouts", None)
.flag("long-timeouts-multiplier", Some("10"))
.run()
.with_config(|config| assert_eq!(config.long_timeouts_multiplier, 10));
}

#[test]
fn beacon_nodes_tls_certs_flag() {
let dir = TempDir::new().expect("Unable to create temporary directory");
Expand Down
14 changes: 14 additions & 0 deletions validator_client/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ pub struct ValidatorClient {
)]
pub use_long_timeouts: bool,

#[clap(
long,
requires = "use_long_timeouts",
default_value_t = 1,
help = "If present, the validator client will use a multiplier for the timeout \
when making requests to the beacon node. This only takes effect when \
the `--use-long-timeouts` flag is present. The timeouts will be the slot \
duration multiplied by this value. This flag is generally not recommended, \
longer timeouts can cause missed duties when fallbacks are used.",
display_order = 0,
help_heading = FLAG_HEADER,
)]
pub long_timeouts_multiplier: u32,

#[clap(
long,
value_name = "CERTIFICATE-FILES",
Expand Down
4 changes: 4 additions & 0 deletions validator_client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub struct Config {
pub init_slashing_protection: bool,
/// If true, use longer timeouts for requests made to the beacon node.
pub use_long_timeouts: bool,
/// Multiplier to use for long timeouts.
pub long_timeouts_multiplier: u32,
/// Graffiti to be inserted everytime we create a block.
pub graffiti: Option<Graffiti>,
/// Graffiti file to load per validator graffitis.
Expand Down Expand Up @@ -112,6 +114,7 @@ impl Default for Config {
disable_auto_discover: false,
init_slashing_protection: false,
use_long_timeouts: false,
long_timeouts_multiplier: 1,
graffiti: None,
graffiti_file: None,
http_api: <_>::default(),
Expand Down Expand Up @@ -196,6 +199,7 @@ impl Config {
config.disable_auto_discover = validator_client_config.disable_auto_discover;
config.init_slashing_protection = validator_client_config.init_slashing_protection;
config.use_long_timeouts = validator_client_config.use_long_timeouts;
config.long_timeouts_multiplier = validator_client_config.long_timeouts_multiplier;

if let Some(graffiti_file_path) = validator_client_config.graffiti_file.as_ref() {
let mut graffiti_file = GraffitiFile::new(graffiti_file_path.into());
Expand Down
2 changes: 1 addition & 1 deletion validator_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
get_validator_block: slot_duration / HTTP_GET_VALIDATOR_BLOCK_TIMEOUT_QUOTIENT,
}
} else {
Timeouts::set_all(slot_duration)
Timeouts::set_all(slot_duration.saturating_mul(config.long_timeouts_multiplier))
};

Ok(BeaconNodeHttpClient::from_components(
Expand Down