Return eth1-related data via the API (#1797)

## Issue Addressed

- Related to #1691

## Proposed Changes

Adds the following API endpoints:

- `GET lighthouse/eth1/syncing`: status about how synced we are with Eth1.
- `GET lighthouse/eth1/block_cache`: all locally cached eth1 blocks.
- `GET lighthouse/eth1/deposit_cache`: all locally cached eth1 deposits.

Additionally:

- Moves some types from the `beacon_node/eth1` to the `common/eth2` crate, so they can be used in the API without duplication.
- Allow `update_deposit_cache` and `update_block_cache` to take an optional head block number to avoid duplicate requests.

## Additional Info

TBC
This commit is contained in:
Paul Hauner
2020-11-02 00:37:30 +00:00
parent 6c0c050fbb
commit 7afbaa807e
18 changed files with 638 additions and 101 deletions

View File

@@ -114,7 +114,7 @@ impl Eth1GenesisService {
loop {
let update_result = eth1_service
.update_deposit_cache()
.update_deposit_cache(None)
.await
.map_err(|e| format!("{:?}", e));
@@ -156,7 +156,7 @@ impl Eth1GenesisService {
}
// Download new eth1 blocks into the cache.
let blocks_imported = match eth1_service.update_block_cache().await {
let blocks_imported = match eth1_service.update_block_cache(None).await {
Ok(outcome) => {
debug!(
log,