lighthouse/beacon_node
Mac L 3642efe76a Cache validator balances and allow them to be served over the HTTP API (#3863)
## Issue Addressed

#3804

## Proposed Changes

- Add `total_balance` to the validator monitor and adjust the number of historical epochs which are cached. 
- Allow certain values in the cache to be served out via the HTTP API without requiring a state read.

## Usage
```
curl -X POST "http://localhost:5052/lighthouse/ui/validator_info" -d '{"indices": [0]}' -H "Content-Type: application/json" | jq
```

```
{
  "data": {
    "validators": {
      "0": {
        "info": [
          {
            "epoch": 172981,
            "total_balance": 36566388519
          },
         ...
          {
            "epoch": 172990,
            "total_balance": 36566496513
          }
        ]
      },
      "1": {
        "info": [
          {
            "epoch": 172981,
            "total_balance": 36355797968
          },
          ...
          {
            "epoch": 172990,
            "total_balance": 36355905962
          }
        ]
      }
    }
  }
}
```

## Additional Info

This requires no historical states to operate which mean it will still function on the freshly checkpoint synced node, however because of this, the values will populate each epoch (up to a maximum of 10 entries).

Another benefit of this method, is that we can easily cache any other values which would normally require a state read and serve them via the same endpoint. However, we would need be cautious about not overly increasing block processing time by caching values from complex computations.

This also caches some of the validator metrics directly, rather than pulling them from the Prometheus metrics when the API is called. This means when the validator count exceeds the individual monitor threshold, the cached values will still be available.

Co-authored-by: Paul Hauner <paul@paulhauner.com>
2023-02-21 20:54:55 +00:00
..
beacon_chain Cache validator balances and allow them to be served over the HTTP API (#3863) 2023-02-21 20:54:55 +00:00
builder_client Verify execution block hashes during finalized sync (#3794) 2023-01-09 03:11:59 +00:00
client Improve validator monitor experience for high validator counts (#3728) 2023-01-09 08:18:55 +00:00
eth1 Clippy lints for rust 1.66 (#3810) 2022-12-16 04:04:00 +00:00
execution_layer Reduce some EE and builder related ERRO logs to WARN (#3966) 2023-02-12 23:14:08 +00:00
genesis Super small improvement: Remove unnecessary mut (#3736) 2022-11-21 03:15:54 +00:00
http_api Cache validator balances and allow them to be served over the HTTP API (#3863) 2023-02-21 20:54:55 +00:00
http_metrics Support IPv6 in BN and VC HTTP APIs (#3104) 2022-03-24 00:04:49 +00:00
lighthouse_network Enforce a timeout on peer disconnect (#3757) 2023-02-14 03:25:42 +00:00
network blacklist tests in windows (#3961) 2023-02-16 23:34:30 +00:00
operation_pool Implement block_rewards API (per-validator reward) (#3907) 2023-02-07 08:33:23 +00:00
src Self rate limiting dev flag (#3928) 2023-02-08 02:18:53 +00:00
store Fix regression in DB write atomicity (#3931) 2023-02-13 03:32:01 +00:00
tests Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
timer Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
Cargo.toml Release v3.4.0 (#3862) 2023-01-11 03:27:08 +00:00