Resolve merge conflicts

This commit is contained in:
Eitan Seri-Levi
2026-01-02 08:52:14 -06:00
918 changed files with 49304 additions and 37273 deletions

View File

@@ -1,14 +1,19 @@
use crate::metrics;
use beacon_chain::{
bellatrix_readiness::{BellatrixReadiness, GenesisExecutionPayloadStatus, MergeConfig},
capella_readiness::CapellaReadiness,
deneb_readiness::DenebReadiness,
eip7805_readiness::Eip7805Readiness,
electra_readiness::ElectraReadiness,
fulu_readiness::FuluReadiness,
BeaconChain, BeaconChainTypes, ExecutionStatus,
bellatrix_readiness::{
BellatrixReadiness, GenesisExecutionPayloadStatus, MergeConfig, SECONDS_IN_A_WEEK,
},
};
use lighthouse_network::{types::SyncState, NetworkGlobals};
use execution_layer::{
EngineCapabilities,
http::{
ENGINE_FORKCHOICE_UPDATED_V2, ENGINE_FORKCHOICE_UPDATED_V3, ENGINE_GET_PAYLOAD_V2,
ENGINE_GET_PAYLOAD_V3, ENGINE_GET_PAYLOAD_V4, ENGINE_GET_PAYLOAD_V5, ENGINE_NEW_PAYLOAD_V2,
ENGINE_NEW_PAYLOAD_V3, ENGINE_NEW_PAYLOAD_V4,
},
};
use lighthouse_network::{NetworkGlobals, types::SyncState};
use logging::crit;
use slot_clock::SlotClock;
use std::sync::Arc;
@@ -31,6 +36,9 @@ const SPEEDO_OBSERVATIONS: usize = 4;
/// The number of slots between logs that give detail about backfill process.
const BACKFILL_LOG_INTERVAL: u64 = 5;
pub const FORK_READINESS_PREPARATION_SECONDS: u64 = SECONDS_IN_A_WEEK * 2;
pub const ENGINE_CAPABILITIES_REFRESH_INTERVAL: u64 = 300;
/// Spawns a notifier service which periodically logs information about the node.
pub fn spawn_notifier<T: BeaconChainTypes>(
executor: task_executor::TaskExecutor,
@@ -49,6 +57,9 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
// Store info if we are required to do a backfill sync.
let original_oldest_block_slot = beacon_chain.store.get_anchor_info().oldest_block_slot;
// Use this info during custody backfill sync.
let mut original_earliest_data_column_slot = None;
let interval_future = async move {
// Perform pre-genesis logging.
loop {
@@ -61,9 +72,8 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
wait_time = estimated_time_pretty(Some(next_slot.as_secs() as f64)),
"Waiting for genesis"
);
eth1_logging(&beacon_chain);
bellatrix_readiness_logging(Slot::new(0), &beacon_chain).await;
capella_readiness_logging(Slot::new(0), &beacon_chain).await;
post_bellatrix_readiness_logging(Slot::new(0), &beacon_chain).await;
genesis_execution_payload_logging(&beacon_chain).await;
sleep(slot_duration).await;
}
@@ -73,6 +83,7 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
// Perform post-genesis logging.
let mut last_backfill_log_slot = None;
let mut last_custody_backfill_log_slot = None;
loop {
// Run the notifier half way through each slot.
@@ -105,6 +116,18 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
let mut speedo = speedo.lock().await;
speedo.clear();
}
(_, SyncState::CustodyBackFillSyncing { .. }) => {
// We have transitioned to a custody backfill sync. Reset the speedo.
let mut speedo = speedo.lock().await;
last_custody_backfill_log_slot = None;
speedo.clear();
}
(SyncState::CustodyBackFillSyncing { .. }, _) => {
// We have transitioned from a custody backfill sync, reset the speedo
let mut speedo = speedo.lock().await;
last_custody_backfill_log_slot = None;
speedo.clear();
}
(_, _) => {}
}
current_sync_state = sync_state;
@@ -147,6 +170,38 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
Instant::now(),
);
}
SyncState::CustodyBackFillSyncing { .. } => {
match beacon_chain.store.get_data_column_custody_info() {
Ok(data_column_custody_info) => {
if let Some(earliest_data_column_slot) = data_column_custody_info
.and_then(|info| info.earliest_data_column_slot)
&& let Some(da_boundary) = beacon_chain.get_column_da_boundary()
{
sync_distance = earliest_data_column_slot.saturating_sub(
da_boundary.start_slot(T::EthSpec::slots_per_epoch()),
);
// We keep track of our starting point for custody backfill sync
// so we can measure our speed of progress.
if original_earliest_data_column_slot.is_none() {
original_earliest_data_column_slot =
Some(earliest_data_column_slot)
}
if let Some(original_earliest_data_column_slot) =
original_earliest_data_column_slot
{
speedo.observe(
original_earliest_data_column_slot
.saturating_sub(earliest_data_column_slot),
Instant::now(),
);
}
}
}
Err(e) => error!(error=?e, "Unable to get data column custody info"),
}
}
SyncState::SyncingFinalized { .. }
| SyncState::SyncingHead { .. }
| SyncState::SyncTransition => {
@@ -183,6 +238,8 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
// Log if we are backfilling.
let is_backfilling = matches!(current_sync_state, SyncState::BackFillSyncing { .. });
let is_custody_backfilling =
matches!(current_sync_state, SyncState::CustodyBackFillSyncing { .. });
if is_backfilling
&& last_backfill_log_slot
.is_none_or(|slot| slot + BACKFILL_LOG_INTERVAL <= current_slot)
@@ -227,6 +284,51 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
info!("Historical block download complete");
}
if is_custody_backfilling
&& last_custody_backfill_log_slot
.is_none_or(|slot| slot + BACKFILL_LOG_INTERVAL <= current_slot)
{
last_custody_backfill_log_slot = Some(current_slot);
let distance = format!(
"{} slots ({})",
sync_distance.as_u64(),
slot_distance_pretty(sync_distance, slot_duration)
);
let speed = speedo.slots_per_second();
let display_speed = speed.is_some_and(|speed| speed != 0.0);
let est_time_in_secs = if let (Some(da_boundary_epoch), Some(original_slot)) = (
beacon_chain.get_column_da_boundary(),
original_earliest_data_column_slot,
) {
let target = original_slot.saturating_sub(
da_boundary_epoch.start_slot(T::EthSpec::slots_per_epoch()),
);
speedo.estimated_time_till_slot(target)
} else {
None
};
if display_speed {
info!(
distance,
speed = sync_speed_pretty(speed),
est_time = estimated_time_pretty(est_time_in_secs),
"Downloading historical data columns"
);
} else {
info!(
distance,
est_time = estimated_time_pretty(est_time_in_secs),
"Downloading historical data columns"
);
}
} else if !is_custody_backfilling && last_custody_backfill_log_slot.is_some() {
last_custody_backfill_log_slot = None;
original_earliest_data_column_slot = None;
info!("Historical data column download complete");
}
// Log if we are syncing
if current_sync_state.is_syncing() {
metrics::set_gauge(&metrics::IS_SYNCED, 0);
@@ -267,8 +369,12 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
let block_hash = match beacon_chain.canonical_head.head_execution_status() {
Ok(ExecutionStatus::Irrelevant(_)) => "n/a".to_string(),
Ok(ExecutionStatus::Valid(hash)) => format!("{} (verified)", hash),
Ok(ExecutionStatus::Valid(hash)) => {
metrics::set_gauge(&metrics::IS_OPTIMISTIC_SYNC, 0);
format!("{} (verified)", hash)
}
Ok(ExecutionStatus::Optimistic(hash)) => {
metrics::set_gauge(&metrics::IS_OPTIMISTIC_SYNC, 1);
warn!(
info = "chain not fully verified, \
block and attestation production disabled until execution engine syncs",
@@ -310,13 +416,8 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
);
}
eth1_logging(&beacon_chain);
bellatrix_readiness_logging(current_slot, &beacon_chain).await;
capella_readiness_logging(current_slot, &beacon_chain).await;
deneb_readiness_logging(current_slot, &beacon_chain).await;
electra_readiness_logging(current_slot, &beacon_chain).await;
eip7805_readiness_logging(current_slot, &beacon_chain).await;
fulu_readiness_logging(current_slot, &beacon_chain).await;
post_bellatrix_readiness_logging(current_slot, &beacon_chain).await;
}
};
@@ -350,18 +451,6 @@ async fn bellatrix_readiness_logging<T: BeaconChainTypes>(
return;
}
if merge_completed && !has_execution_layer {
// Logging of the EE being offline is handled in the other readiness logging functions.
if !beacon_chain.is_time_to_prepare_for_capella(current_slot) {
error!(
info = "you need an execution engine to validate blocks, see: \
https://lighthouse-book.sigmaprime.io/archived_merge_migration.html",
"Execution endpoint required"
);
}
return;
}
match beacon_chain.check_bellatrix_readiness(current_slot).await {
BellatrixReadiness::Ready {
config,
@@ -410,265 +499,156 @@ async fn bellatrix_readiness_logging<T: BeaconChainTypes>(
}
/// Provides some helpful logging to users to indicate if their node is ready for Capella
async fn capella_readiness_logging<T: BeaconChainTypes>(
async fn post_bellatrix_readiness_logging<T: BeaconChainTypes>(
current_slot: Slot,
beacon_chain: &BeaconChain<T>,
) {
let capella_completed = beacon_chain
if let Some(fork) = find_next_fork_to_prepare(current_slot, beacon_chain) {
let readiness = if let Some(el) = beacon_chain.execution_layer.as_ref() {
match el
.get_engine_capabilities(Some(Duration::from_secs(
ENGINE_CAPABILITIES_REFRESH_INTERVAL,
)))
.await
{
Err(e) => Err(format!("Exchange capabilities failed: {e:?}")),
Ok(capabilities) => {
let missing_methods = methods_required_for_fork(fork, capabilities);
if missing_methods.is_empty() {
Ok(())
} else {
Err(format!("Missing required methods: {missing_methods:?}"))
}
}
}
} else {
Err("No execution endpoint".to_string())
};
if let Err(readiness) = readiness {
warn!(
info = %readiness,
"Not ready for {}", fork
);
} else {
info!(
info = "ensure the execution endpoint is updated to the latest release",
"Ready for {}", fork
)
}
}
}
fn find_next_fork_to_prepare<T: BeaconChainTypes>(
current_slot: Slot,
beacon_chain: &BeaconChain<T>,
) -> Option<ForkName> {
let head_fork = beacon_chain
.canonical_head
.cached_head()
.snapshot
.beacon_state
.fork_name_unchecked()
.capella_enabled();
.fork_name_unchecked();
let has_execution_layer = beacon_chain.execution_layer.is_some();
if capella_completed && has_execution_layer
|| !beacon_chain.is_time_to_prepare_for_capella(current_slot)
// Iterate forks from latest to oldest
for (fork, fork_epoch) in ForkName::list_all_fork_epochs(&beacon_chain.spec)
.iter()
.rev()
{
return;
// This readiness only handles capella and post fork
if *fork <= ForkName::Bellatrix {
break;
}
// head state has already activated this fork
if head_fork >= *fork {
break;
}
// Find the first fork that is scheduled and close to happen
if let Some(fork_epoch) = fork_epoch {
let fork_slot = fork_epoch.start_slot(T::EthSpec::slots_per_epoch());
let preparation_slots =
FORK_READINESS_PREPARATION_SECONDS / beacon_chain.spec.seconds_per_slot;
let in_fork_preparation_period = current_slot + preparation_slots > fork_slot;
if in_fork_preparation_period {
return Some(*fork);
}
}
}
if capella_completed && !has_execution_layer {
// Logging of the EE being offline is handled in the other readiness logging functions.
if !beacon_chain.is_time_to_prepare_for_deneb(current_slot) {
error!(
info = "you need a Capella enabled execution engine to validate blocks, see: \
https://lighthouse-book.sigmaprime.io/archived_merge_migration.html",
"Execution endpoint required"
None
}
fn methods_required_for_fork(
fork: ForkName,
capabilities: EngineCapabilities,
) -> Vec<&'static str> {
let mut missing_methods = vec![];
match fork {
ForkName::Base | ForkName::Altair | ForkName::Bellatrix => {
warn!(
fork = %fork,
"Invalid methods_required_for_fork call"
);
}
return;
}
match beacon_chain.check_capella_readiness().await {
CapellaReadiness::Ready => {
info!(
info = "ensure the execution endpoint is updated to the latest Capella/Shanghai release",
"Ready for Capella"
)
ForkName::Capella => {
if !capabilities.get_payload_v2 {
missing_methods.push(ENGINE_GET_PAYLOAD_V2);
}
if !capabilities.forkchoice_updated_v2 {
missing_methods.push(ENGINE_FORKCHOICE_UPDATED_V2);
}
if !capabilities.new_payload_v2 {
missing_methods.push(ENGINE_NEW_PAYLOAD_V2);
}
}
readiness @ CapellaReadiness::ExchangeCapabilitiesFailed { error: _ } => {
error!(
hint = "the execution endpoint may be offline",
info = %readiness,
"Not ready for Capella"
)
ForkName::Deneb => {
if !capabilities.get_payload_v3 {
missing_methods.push(ENGINE_GET_PAYLOAD_V3);
}
if !capabilities.forkchoice_updated_v3 {
missing_methods.push(ENGINE_FORKCHOICE_UPDATED_V3);
}
if !capabilities.new_payload_v3 {
missing_methods.push(ENGINE_NEW_PAYLOAD_V3);
}
}
readiness => warn!(
hint = "try updating the execution endpoint",
info = %readiness,
"Not ready for Capella"
),
}
}
/// Provides some helpful logging to users to indicate if their node is ready for Deneb
async fn deneb_readiness_logging<T: BeaconChainTypes>(
current_slot: Slot,
beacon_chain: &BeaconChain<T>,
) {
let deneb_completed = beacon_chain
.canonical_head
.cached_head()
.snapshot
.beacon_state
.fork_name_unchecked()
.deneb_enabled();
let has_execution_layer = beacon_chain.execution_layer.is_some();
if deneb_completed && has_execution_layer
|| !beacon_chain.is_time_to_prepare_for_deneb(current_slot)
{
return;
}
if deneb_completed && !has_execution_layer {
error!(
info = "you need a Deneb enabled execution engine to validate blocks.",
"Execution endpoint required"
);
return;
}
match beacon_chain.check_deneb_readiness().await {
DenebReadiness::Ready => {
info!(
info =
"ensure the execution endpoint is updated to the latest Deneb/Cancun release",
"Ready for Deneb"
)
ForkName::Electra => {
if !capabilities.get_payload_v4 {
missing_methods.push(ENGINE_GET_PAYLOAD_V4);
}
if !capabilities.new_payload_v4 {
missing_methods.push(ENGINE_NEW_PAYLOAD_V4);
}
}
readiness @ DenebReadiness::ExchangeCapabilitiesFailed { error: _ } => {
error!(
hint = "the execution endpoint may be offline",
info = %readiness,
"Not ready for Deneb"
)
ForkName::Fulu => {
if !capabilities.get_payload_v5 {
missing_methods.push(ENGINE_GET_PAYLOAD_V5);
}
if !capabilities.new_payload_v4 {
missing_methods.push(ENGINE_NEW_PAYLOAD_V4);
}
}
readiness => warn!(
hint = "try updating the execution endpoint",
info = %readiness,
"Not ready for Deneb"
),
}
}
/// Provides some helpful logging to users to indicate if their node is ready for Electra.
async fn electra_readiness_logging<T: BeaconChainTypes>(
current_slot: Slot,
beacon_chain: &BeaconChain<T>,
) {
let electra_completed = beacon_chain
.canonical_head
.cached_head()
.snapshot
.beacon_state
.fork_name_unchecked()
.electra_enabled();
let has_execution_layer = beacon_chain.execution_layer.is_some();
if electra_completed && has_execution_layer
|| !beacon_chain.is_time_to_prepare_for_electra(current_slot)
{
return;
}
if electra_completed && !has_execution_layer {
// When adding a new fork, add a check for the next fork readiness here.
error!(
info = "you need a Electra enabled execution engine to validate blocks.",
"Execution endpoint required"
);
return;
}
match beacon_chain.check_electra_readiness().await {
ElectraReadiness::Ready => {
info!(
info =
"ensure the execution endpoint is updated to the latest Electra/Prague release",
"Ready for Electra"
)
// TODO(EIP7805) check capabilities
ForkName::Eip7805 => {
if !capabilities.get_payload_v5 {
missing_methods.push(ENGINE_GET_PAYLOAD_V5);
}
if !capabilities.new_payload_v4 {
missing_methods.push(ENGINE_NEW_PAYLOAD_V4);
}
}
readiness @ ElectraReadiness::ExchangeCapabilitiesFailed { error: _ } => {
error!(
hint = "the execution endpoint may be offline",
info = %readiness,
"Not ready for Electra"
)
ForkName::Gloas => {
if !capabilities.get_payload_v5 {
missing_methods.push(ENGINE_GET_PAYLOAD_V5);
}
if !capabilities.new_payload_v4 {
missing_methods.push(ENGINE_NEW_PAYLOAD_V4);
}
}
readiness => warn!(
hint = "try updating the execution endpoint",
info = %readiness,
"Not ready for Electra"
),
}
}
/// Provides some helpful logging to users to indicate if their node is ready for Eip7805.
async fn eip7805_readiness_logging<T: BeaconChainTypes>(
current_slot: Slot,
beacon_chain: &BeaconChain<T>,
) {
let eip7805_completed = beacon_chain
.canonical_head
.cached_head()
.snapshot
.beacon_state
.fork_name_unchecked()
.eip7805_enabled();
let has_execution_layer = beacon_chain.execution_layer.is_some();
if eip7805_completed && has_execution_layer
|| !beacon_chain.is_time_to_prepare_for_electra(current_slot)
{
return;
}
if eip7805_completed && !has_execution_layer {
// When adding a new fork, add a check for the next fork readiness here.
error!(
info = "you need a Eip7805 enabled execution engine to validate blocks.",
"Execution endpoint required"
);
return;
}
match beacon_chain.check_eip7805_readiness().await {
Eip7805Readiness::Ready => {
info!(
info = "ensure the execution endpoint is updated to the latest eip7805 release",
"Ready for Eip7805"
)
}
readiness @ Eip7805Readiness::ExchangeCapabilitiesFailed { error: _ } => {
error!(
hint = "the execution endpoint may be offline",
info = %readiness,
"Not ready for Eip7805Readiness"
)
}
readiness => warn!(
hint = "try updating the execution endpoint",
info = %readiness,
"Not ready for Eip7805Readiness"
),
}
}
/// Provides some helpful logging to users to indicate if their node is ready for Fulu.
async fn fulu_readiness_logging<T: BeaconChainTypes>(
current_slot: Slot,
beacon_chain: &BeaconChain<T>,
) {
let fulu_completed = beacon_chain
.canonical_head
.cached_head()
.snapshot
.beacon_state
.fork_name_unchecked()
.fulu_enabled();
let has_execution_layer = beacon_chain.execution_layer.is_some();
if fulu_completed && has_execution_layer
|| !beacon_chain.is_time_to_prepare_for_fulu(current_slot)
{
return;
}
if fulu_completed && !has_execution_layer {
error!(
info = "you need a Fulu enabled execution engine to validate blocks.",
"Execution endpoint required"
);
return;
}
match beacon_chain.check_fulu_readiness().await {
FuluReadiness::Ready => {
info!(
info = "ensure the execution endpoint is updated to the latest Fulu release",
"Ready for Fulu"
)
}
readiness @ FuluReadiness::ExchangeCapabilitiesFailed { error: _ } => {
error!(
hint = "the execution endpoint may be offline",
info = %readiness,
"Not ready for Fulu"
)
}
readiness => warn!(
hint = "try updating the execution endpoint",
info = %readiness,
"Not ready for Fulu"
),
}
missing_methods
}
async fn genesis_execution_payload_logging<T: BeaconChainTypes>(beacon_chain: &BeaconChain<T>) {
@@ -731,53 +711,6 @@ async fn genesis_execution_payload_logging<T: BeaconChainTypes>(beacon_chain: &B
}
}
fn eth1_logging<T: BeaconChainTypes>(beacon_chain: &BeaconChain<T>) {
let current_slot_opt = beacon_chain.slot().ok();
// Perform some logging about the eth1 chain
if let Some(eth1_chain) = beacon_chain.eth1_chain.as_ref() {
// No need to do logging if using the dummy backend.
if eth1_chain.is_dummy_backend() {
return;
}
if let Some(status) = eth1_chain.sync_status(
beacon_chain.genesis_time,
current_slot_opt,
&beacon_chain.spec,
) {
debug!(
eth1_head_block = status.head_block_number,
latest_cached_block_number = status.latest_cached_block_number,
latest_cached_timestamp = status.latest_cached_block_timestamp,
voting_target_timestamp = status.voting_target_timestamp,
ready = status.lighthouse_is_cached_and_ready,
"Eth1 cache sync status"
);
if !status.lighthouse_is_cached_and_ready {
let voting_target_timestamp = status.voting_target_timestamp;
let distance = status
.latest_cached_block_timestamp
.map(|latest| {
voting_target_timestamp.saturating_sub(latest)
/ beacon_chain.spec.seconds_per_eth1_block
})
.map(|distance| distance.to_string())
.unwrap_or_else(|| "initializing deposits".to_string());
warn!(
est_blocks_remaining = distance,
"Syncing deposit contract block cache"
);
}
} else {
error!("Unable to determine deposit contract sync status");
}
}
}
/// Returns the peer count, returning something helpful if it's `usize::MAX` (effectively a
/// `None` value).
fn peer_count_pretty(peer_count: usize) -> String {