Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1b90859
Force consumers to decide what finality checkpoints they want to read
dapplion Oct 16, 2025
a2c5b4b
Update sync to handle local finality
dapplion Oct 20, 2025
b27e4d3
Hook manual finalization into fork-choice
dapplion Oct 20, 2025
f91a9c2
Set ProtoNode checkpoints to on_chain checkpoints
dapplion Oct 25, 2025
ff431ac
Initialize first node with correct root
dapplion Oct 25, 2025
df7c477
Lint tests
dapplion Oct 29, 2025
1821540
Fix tests
dapplion Oct 29, 2025
511e705
Fix tests
dapplion Nov 7, 2025
6dfee65
Merge remote-tracking branch 'sigp/unstable' into fork-choice-optimis…
dapplion Nov 7, 2025
2b907a6
Fix revert fc tests
dapplion Nov 7, 2025
3372df2
Fix fork-choice tests
dapplion Nov 7, 2025
86508ca
lint
dapplion Nov 7, 2025
3ca4f4b
Add ws non fin test
dapplion Nov 7, 2025
c5507d0
Fix prune test
dapplion Nov 7, 2025
a563944
Complete non fin ws test
dapplion Nov 8, 2025
00a87df
Add CLI tests
dapplion Nov 8, 2025
dec34a4
Sort deps
dapplion Nov 8, 2025
71271ca
Fix tests by removing dodgy skip
michaelsproul Nov 12, 2025
d8536d4
Merge remote-tracking branch 'sigp/unstable' into fork-choice-optimis…
dapplion Nov 12, 2025
309af3b
Fix tests
dapplion Nov 14, 2025
a9e0b19
Extend ws tests
dapplion Nov 14, 2025
066c5b6
lint comment
dapplion Nov 14, 2025
b6ffe8a
Fix pseudo migration tests
dapplion Nov 14, 2025
5c643ee
Merge remote-tracking branch 'sigp/unstable' into fork-choice-optimis…
dapplion Nov 24, 2025
c71fc97
Don't update justified balances on set irreversible checkpoint
dapplion Nov 24, 2025
da83332
Remove unnecessary state_root checks
dapplion Nov 24, 2025
1877d64
Check that irreversible checkpoint is of a known block and well formed
dapplion Nov 24, 2025
586f232
Recompute head after set manual finalization
dapplion Nov 24, 2025
381c8a3
Remove irreversible slot function
dapplion Nov 24, 2025
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
1 change: 1 addition & 0 deletions beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,7 @@ fn verify_attestation_is_finalized_checkpoint_or_descendant<T: BeaconChainTypes>
let attestation_block_root = attestation_data.beacon_block_root;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read the PR body description before the diff :)

let finalized_slot = fork_choice
.finalized_checkpoint()
.local()
.epoch
.start_slot(T::EthSpec::slots_per_epoch());
let split = chain.store.get_split_info();
Expand Down
74 changes: 29 additions & 45 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::light_client_optimistic_update_verification::{
Error as LightClientOptimisticUpdateError, VerifiedLightClientOptimisticUpdate,
};
use crate::light_client_server_cache::LightClientServerCache;
use crate::migrate::{BackgroundMigrator, ManualFinalizationNotification};
use crate::migrate::BackgroundMigrator;
use crate::naive_aggregation_pool::{
AggregatedAttestationMap, Error as NaiveAggregationError, NaiveAggregationPool,
SyncContributionAggregateMap,
Expand Down Expand Up @@ -122,8 +122,8 @@ use std::sync::Arc;
use std::time::Duration;
use store::iter::{BlockRootsIterator, ParentRootBlockIterator, StateRootsIterator};
use store::{
BlobSidecarListFromRoot, DBColumn, DatabaseBlock, Error as DBError, HotColdDB, HotStateSummary,
KeyValueStore, KeyValueStoreOp, StoreItem, StoreOp,
BlobSidecarListFromRoot, DBColumn, DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore,
KeyValueStoreOp, StoreItem, StoreOp,
};
use task_executor::{RayonPoolType, ShutdownReason, TaskExecutor};
use tokio_stream::Stream;
Expand Down Expand Up @@ -549,10 +549,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
block_root: &Hash256,
block_slot: Slot,
) -> Result<bool, Error> {
// Used by the API: finalized if prior to the network finality not the local view
let finalized_slot = self
.canonical_head
.cached_head()
.finalized_checkpoint()
.on_chain()
.epoch
.start_slot(T::EthSpec::slots_per_epoch());
let is_canonical = self
Expand All @@ -579,10 +581,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
state_root: &Hash256,
state_slot: Slot,
) -> Result<FinalizationAndCanonicity, Error> {
// Used by the API: finalized if prior to the network finality not the local view
let finalized_slot = self
.canonical_head
.cached_head()
.finalized_checkpoint()
.on_chain()
.epoch
.start_slot(T::EthSpec::slots_per_epoch());
let slot_is_finalized = state_slot <= finalized_slot;
Expand All @@ -595,6 +599,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
})
}

pub fn irreversible_slot(&self) -> Slot {
let local_finalized_slot = self
.head()
.finalized_checkpoint()
.local()
.epoch
.start_slot(T::EthSpec::slots_per_epoch());
let split = self.store.get_split_info();
std::cmp::max(local_finalized_slot, split.slot)
}

/// Return a database operation for writing the `PersistedBeaconChain` to disk.
///
/// These days the `PersistedBeaconChain` is only used to store the genesis block root, so it
Expand Down Expand Up @@ -1666,39 +1681,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
self.store_migrator.process_manual_compaction();
}

pub fn manually_finalize_state(
&self,
state_root: Hash256,
checkpoint: Checkpoint,
) -> Result<(), Error> {
let HotStateSummary {
slot,
latest_block_root,
..
} = self
.store
.load_hot_state_summary(&state_root)
.map_err(BeaconChainError::DBError)?
.ok_or(BeaconChainError::MissingHotStateSummary(state_root))?;

if slot != checkpoint.epoch.start_slot(T::EthSpec::slots_per_epoch())
|| latest_block_root != *checkpoint.root
{
return Err(BeaconChainError::InvalidCheckpoint {
state_root,
checkpoint,
});
}

let notif = ManualFinalizationNotification {
state_root: state_root.into(),
checkpoint,
};

self.store_migrator.process_manual_finalization(notif);
Ok(())
}

/// Returns an aggregated `Attestation`, if any, that has a matching `attestation.data`.
///
/// The attestation will be obtained from `self.naive_aggregation_pool`.
Expand Down Expand Up @@ -4088,8 +4070,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// We are doing this to ensure that we detect changes in finalization. It's possible
// that fork choice has already been updated to the finalized checkpoint in the block
// we're importing.
let current_head_finalized_checkpoint =
self.canonical_head.cached_head().finalized_checkpoint();
let current_head_finalized_checkpoint = self
.canonical_head
.cached_head()
.finalied_checkpoint_from_head_state();
// Compare the existing finalized checkpoint with the incoming block's finalized checkpoint.
let new_finalized_checkpoint = state.finalized_checkpoint();

Expand Down Expand Up @@ -5875,16 +5859,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let justified_block = self
.spawn_blocking_handle(
move || {
chain
.canonical_head
.fork_choice_read_lock()
.get_justified_block()
let fork_choice = chain.canonical_head.fork_choice_read_lock();
fork_choice.get_block(&fork_choice.justified_checkpoint().on_chain().root)
},
"invalid_payload_fork_choice_get_justified",
)
.await??;
.await?;

if justified_block.execution_status.is_invalid() {
if let Some(justified_block) = justified_block
&& justified_block.execution_status.is_invalid()
{
crit!(
msg = "ensure you are not connected to a malicious network. This error is not \
recoverable, please reach out to the lighthouse developers for assistance.",
Expand Down Expand Up @@ -6952,7 +6936,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// Check if finalization is advancing.
let current_epoch = current_slot.epoch(T::EthSpec::slots_per_epoch());
let epochs_since_finalization =
current_epoch.saturating_sub(cached_head.finalized_checkpoint().epoch);
current_epoch.saturating_sub(cached_head.finalized_checkpoint().on_chain().epoch);
let finalization_check = epochs_since_finalization.as_usize()
<= self.config.builder_fallback_epochs_since_finalization;

Expand Down
Loading