mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 06:14:38 +00:00
Implement checkpoint sync (#2244)
## Issue Addressed Closes #1891 Closes #1784 ## Proposed Changes Implement checkpoint sync for Lighthouse, enabling it to start from a weak subjectivity checkpoint. ## Additional Info - [x] Return unavailable status for out-of-range blocks requested by peers (#2561) - [x] Implement sync daemon for fetching historical blocks (#2561) - [x] Verify chain hashes (either in `historical_blocks.rs` or the calling module) - [x] Consistency check for initial block + state - [x] Fetch the initial state and block from a beacon node HTTP endpoint - [x] Don't crash fetching beacon states by slot from the API - [x] Background service for state reconstruction, triggered by CLI flag or API call. Considered out of scope for this PR: - Drop the requirement to provide the `--checkpoint-block` (this would require some pretty heavy refactoring of block verification) Co-authored-by: Diva M <divma@protonmail.com>
This commit is contained in:
@@ -13,13 +13,46 @@ pub enum Error {
|
||||
BeaconStateError(BeaconStateError),
|
||||
PartialBeaconStateError,
|
||||
HotColdDBError(HotColdDBError),
|
||||
DBError { message: String },
|
||||
DBError {
|
||||
message: String,
|
||||
},
|
||||
RlpError(String),
|
||||
BlockNotFound(Hash256),
|
||||
NoContinuationData,
|
||||
SplitPointModified(Slot, Slot),
|
||||
ConfigError(StoreConfigError),
|
||||
SchemaMigrationError(String),
|
||||
/// The store's `anchor_info` was mutated concurrently, the latest modification wasn't applied.
|
||||
AnchorInfoConcurrentMutation,
|
||||
/// The block or state is unavailable due to weak subjectivity sync.
|
||||
HistoryUnavailable,
|
||||
/// State reconstruction cannot commence because not all historic blocks are known.
|
||||
MissingHistoricBlocks {
|
||||
oldest_block_slot: Slot,
|
||||
},
|
||||
/// State reconstruction failed because it didn't reach the upper limit slot.
|
||||
///
|
||||
/// This should never happen (it's a logic error).
|
||||
StateReconstructionDidNotComplete,
|
||||
StateReconstructionRootMismatch {
|
||||
slot: Slot,
|
||||
expected: Hash256,
|
||||
computed: Hash256,
|
||||
},
|
||||
}
|
||||
|
||||
pub trait HandleUnavailable<T> {
|
||||
fn handle_unavailable(self) -> std::result::Result<Option<T>, Error>;
|
||||
}
|
||||
|
||||
impl<T> HandleUnavailable<T> for Result<T> {
|
||||
fn handle_unavailable(self) -> std::result::Result<Option<T>, Error> {
|
||||
match self {
|
||||
Ok(x) => Ok(Some(x)),
|
||||
Err(Error::HistoryUnavailable) => Ok(None),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DecodeError> for Error {
|
||||
|
||||
Reference in New Issue
Block a user