## 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>
34 lines
1.0 KiB
Rust
34 lines
1.0 KiB
Rust
use beacon_chain::store::{metadata::CURRENT_SCHEMA_VERSION, AnchorInfo};
|
|
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
|
use eth2::lighthouse::DatabaseInfo;
|
|
use std::sync::Arc;
|
|
use types::SignedBeaconBlock;
|
|
|
|
pub fn info<T: BeaconChainTypes>(
|
|
chain: Arc<BeaconChain<T>>,
|
|
) -> Result<DatabaseInfo, warp::Rejection> {
|
|
let store = &chain.store;
|
|
let split = store.get_split_info();
|
|
let anchor = store.get_anchor_info();
|
|
|
|
Ok(DatabaseInfo {
|
|
schema_version: CURRENT_SCHEMA_VERSION.as_u64(),
|
|
split,
|
|
anchor,
|
|
})
|
|
}
|
|
|
|
pub fn historical_blocks<T: BeaconChainTypes>(
|
|
chain: Arc<BeaconChain<T>>,
|
|
blocks: Vec<SignedBeaconBlock<T::EthSpec>>,
|
|
) -> Result<AnchorInfo, warp::Rejection> {
|
|
chain
|
|
.import_historical_block_batch(&blocks)
|
|
.map_err(warp_utils::reject::beacon_chain_error)?;
|
|
|
|
let anchor = chain.store.get_anchor_info().ok_or_else(|| {
|
|
warp_utils::reject::custom_bad_request("node is not checkpoint synced".to_string())
|
|
})?;
|
|
Ok(anchor)
|
|
}
|