Expand eth1 block cache, add more logs (#1938)

## Issue Addressed

NA

## Proposed Changes

- Caches later blocks than is required by `ETH1_FOLLOW_DISTANCE`.
- Adds logging to `warn` if the eth1 cache is insufficiently primed.
- Use `max_by_key` instead of `max_by` in `BeaconChain::Eth1Chain` since it's simpler.
- Rename `voting_period_start_timestamp` to `voting_target_timestamp` for accuracy.

## Additional Info

The reason for eating into the `ETH1_FOLLOW_DISTANCE` and caching blocks that are closer to the head is due to possibility for `SECONDS_PER_ETH1_BLOCK` to be incorrect (as is the case for the Pyrmont testnet on Goerli).

If `SECONDS_PER_ETH1_BLOCK` is too short, we'll skip back too far from the head and skip over blocks that would be valid [`is_candidate_block`](https://github.com/ethereum/eth2.0-specs/blob/v1.0.0/specs/phase0/validator.md#eth1-data) blocks. This was the case on the Pyrmont testnet and resulted in Lighthouse choosing blocks that were about 30 minutes older than is ideal.
This commit is contained in:
Paul Hauner
2020-11-21 00:26:15 +00:00
parent 3b405f10ea
commit 48f73b21e6
6 changed files with 114 additions and 19 deletions

View File

@@ -192,9 +192,7 @@ health of the Eth1 node that the beacon node is connected to.
number and timestamp of the latest block we have in our block cache.
- For correct Eth1 voting this timestamp should be later than the
`voting_period_start_timestamp`.
- `voting_period_start_timestamp`: the start of the period where block
producers must include votes for blocks in the Eth1 chain. Provided for
reference.
- `voting_target_timestamp`: The latest timestamp allowed for an eth1 block in this voting period.
- `eth1_node_sync_status_percentage` (float): An estimate of how far the head of the
Eth1 node is from the head of the Eth1 chain.
- `100.0` indicates a fully synced Eth1 node.
@@ -222,7 +220,7 @@ curl -X GET "http://localhost:5052/lighthouse/eth1/syncing" -H "accept: applica
"head_block_timestamp": 1603249317,
"latest_cached_block_number": 3610758,
"latest_cached_block_timestamp": 1603233597,
"voting_period_start_timestamp": 1603228632,
"voting_target_timestamp": 1603228632,
"eth1_node_sync_status_percentage": 100,
"lighthouse_is_cached_and_ready": true
}