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:
Michael Sproul
2021-09-22 00:37:28 +00:00
parent 280e4fe23d
commit 9667dc2f03
71 changed files with 4012 additions and 459 deletions

View File

@@ -16,7 +16,6 @@ mod transition_blocks;
use clap::{App, Arg, ArgMatches, SubCommand};
use clap_utils::parse_path_with_default_in_home_dir;
use environment::EnvironmentBuilder;
use log::LevelFilter;
use parse_ssz::run_parse_ssz;
use std::path::PathBuf;
use std::process;
@@ -25,10 +24,7 @@ use transition_blocks::run_transition_blocks;
use types::{EthSpec, EthSpecId};
fn main() {
simple_logger::SimpleLogger::new()
.with_level(LevelFilter::Info)
.init()
.expect("Logger should be initialised");
env_logger::init();
let matches = App::new("Lighthouse CLI Tool")
.version(lighthouse_version::VERSION)
@@ -110,6 +106,17 @@ fn main() {
.subcommand(
SubCommand::with_name("pretty-ssz")
.about("Parses SSZ-encoded data from a file")
.arg(
Arg::with_name("format")
.short("f")
.long("format")
.value_name("FORMAT")
.takes_value(true)
.required(true)
.default_value("json")
.possible_values(&["json", "yaml"])
.help("Output format to use")
)
.arg(
Arg::with_name("type")
.value_name("TYPE")
@@ -123,7 +130,7 @@ fn main() {
.takes_value(true)
.required(true)
.help("Path to SSZ bytes"),
),
)
)
.subcommand(
SubCommand::with_name("deploy-deposit-contract")