mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 02:33:48 +00:00
Manual finalization endpoint (#7059)
* Load block roots from fork choice where possible to avoid loading state from disk when serving block by range requests. * Check if the start slot is newer than finalization (`start_slot >= finalized_slot`), and use fork choice in that case. * force finalization endpoint * cleanup * Remove ds store * Don't import blocks that conflict with the split * Disconnect and ban peer if we get blocks conflicting manual checkpoint * immediately commit state to cold db * revert * Fix descent from split check * Add safety check to checkpoint when doing manual finalization. --------- Co-authored-by: Jimmy Chen <jchen.tc@gmail.com> Co-authored-by: Michael Sproul <michael@sigmaprime.io> Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
@@ -42,7 +42,7 @@ use crate::light_client_optimistic_update_verification::{
|
||||
Error as LightClientOptimisticUpdateError, VerifiedLightClientOptimisticUpdate,
|
||||
};
|
||||
use crate::light_client_server_cache::LightClientServerCache;
|
||||
use crate::migrate::BackgroundMigrator;
|
||||
use crate::migrate::{BackgroundMigrator, ManualFinalizationNotification};
|
||||
use crate::naive_aggregation_pool::{
|
||||
AggregatedAttestationMap, Error as NaiveAggregationError, NaiveAggregationPool,
|
||||
SyncContributionAggregateMap,
|
||||
@@ -118,8 +118,8 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use store::iter::{BlockRootsIterator, ParentRootBlockIterator, StateRootsIterator};
|
||||
use store::{
|
||||
BlobSidecarListFromRoot, DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore,
|
||||
KeyValueStoreOp, StoreItem, StoreOp,
|
||||
BlobSidecarListFromRoot, DatabaseBlock, Error as DBError, HotColdDB, HotStateSummary,
|
||||
KeyValueStore, KeyValueStoreOp, StoreItem, StoreOp,
|
||||
};
|
||||
use task_executor::{ShutdownReason, TaskExecutor};
|
||||
use tokio::sync::oneshot;
|
||||
@@ -1707,6 +1707,41 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
head_tracker: self.head_tracker.clone(),
|
||||
genesis_block_root: self.genesis_block_root,
|
||||
};
|
||||
|
||||
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`.
|
||||
|
||||
Reference in New Issue
Block a user