lighthouse/beacon_node
Mac L 4c510f8f6b Add BlockTimesCache to allow additional block delay metrics (#2546)
## Issue Addressed

Closes #2528

## Proposed Changes

- Add `BlockTimesCache` to provide block timing information to `BeaconChain`. This allows additional metrics to be calculated for blocks that are set as head too late.
- Thread the `seen_timestamp` of blocks received from RPC responses (except blocks from syncing) through to the sync manager, similar to what is done for blocks from gossip.

## Additional Info

This provides the following additional metrics:
- `BEACON_BLOCK_OBSERVED_SLOT_START_DELAY_TIME`
  - The delay between the start of the slot and when the block was first observed.
- `BEACON_BLOCK_IMPORTED_OBSERVED_DELAY_TIME`
   - The delay between when the block was first observed and when the block was imported.
- `BEACON_BLOCK_HEAD_IMPORTED_DELAY_TIME`
  - The delay between when the block was imported and when the block was set as head.

The metric `BEACON_BLOCK_IMPORTED_SLOT_START_DELAY_TIME` was removed.

A log is produced when a block is set as head too late, e.g.:
```
Aug 27 03:46:39.006 DEBG Delayed head block                      set_as_head_delay: Some(21.731066ms), imported_delay: Some(119.929934ms), observed_delay: Some(3.864596988s), block_delay: 4.006257988s, slot: 1931331, proposer_index: 24294, block_root: 0x937602c89d3143afa89088a44bdf4b4d0d760dad082abacb229495c048648a9e, service: beacon
```
2021-09-30 04:31:41 +00:00
..
beacon_chain Add BlockTimesCache to allow additional block delay metrics (#2546) 2021-09-30 04:31:41 +00:00
client Implement SSZ union type (#2579) 2021-09-25 05:58:36 +00:00
eth1 Implement SSZ union type (#2579) 2021-09-25 05:58:36 +00:00
eth2_libp2p Add interop metrics (#2645) 2021-09-29 23:44:24 +00:00
genesis Implement SSZ union type (#2579) 2021-09-25 05:58:36 +00:00
http_api Add BlockTimesCache to allow additional block delay metrics (#2546) 2021-09-30 04:31:41 +00:00
http_metrics Upgrade dependencies (#2513) 2021-08-17 01:00:24 +00:00
network Add BlockTimesCache to allow additional block delay metrics (#2546) 2021-09-30 04:31:41 +00:00
operation_pool Implement SSZ union type (#2579) 2021-09-25 05:58:36 +00:00
src Implement checkpoint sync (#2244) 2021-09-22 00:37:28 +00:00
store Implement SSZ union type (#2579) 2021-09-25 05:58:36 +00:00
tests Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
timer Upgrade dependencies (#2513) 2021-08-17 01:00:24 +00:00
websocket_server Server sent events (#1920) 2020-12-04 00:18:58 +00:00
Cargo.toml Implement SSZ union type (#2579) 2021-09-25 05:58:36 +00:00