Skip to content

Commit 94ccd76

Browse files
authored
Add documentation for VC API /lighthouse/beacon/health (#6653)
Changes the endpoint to get fallback health information from `/lighthouse/ui/fallback_health` to `/lighthouse/beacon/health`. This more accurately describes that the endpoint is related to the connected beacon nodes and also matched the `/lighthouse/beacon/update` endpoint being added in #6551. Adds documentation for both fallback health and the endpoint to the Lighthouse book.
1 parent 34a6c3a commit 94ccd76

File tree

3 files changed

+75
-8
lines changed

3 files changed

+75
-8
lines changed

book/src/advanced_redundancy.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ There are a few interesting properties about the list of `--beacon-nodes`:
3939
earlier in the list.
4040
- *Synced is preferred*: the validator client prefers a synced beacon node over
4141
one that is still syncing.
42-
- *Failure is sticky*: if a beacon node fails, it will be flagged as offline
43-
and won't be retried again for the rest of the slot (12 seconds). This helps prevent the impact
44-
of time-outs and other lengthy errors.
4542

4643
> Note: When supplying multiple beacon nodes the `http://localhost:5052` address must be explicitly
4744
> provided (if it is desired). It will only be used as default if no `--beacon-nodes` flag is
@@ -76,6 +73,22 @@ Prior to v3.2.0 fallback beacon nodes also required the `--subscribe-all-subnets
7673
now broadcast subscriptions to all connected beacon nodes by default. This broadcast behaviour
7774
can be disabled using the `--broadcast none` flag for `lighthouse vc`.
7875

76+
### Fallback Health
77+
78+
Since v6.0.0, the validator client will be more aggressive in switching to a fallback node. To do this,
79+
it uses the concept of "Health". Every slot, the validator client checks each connected beacon node
80+
to determine which node is the "Healthiest". In general, the validator client will prefer nodes
81+
which are synced, have synced execution layers and which are not currently optimistically
82+
syncing.
83+
84+
Sync distance is separated out into 4 tiers: "Synced", "Small", "Medium", "Large". Nodes are then
85+
sorted into tiers based onto sync distance and execution layer status. You can use the
86+
`--beacon-nodes-sync-tolerances` to change how many slots wide each tier is. In the case where
87+
multiple nodes fall into the same tier, user order is used to tie-break.
88+
89+
To see health information for each connected node, you can use the
90+
[`/lighthouse/beacon/health` API endpoint](./api_vc_endpoints.md#get-lighthousebeaconhealth).
91+
7992
### Broadcast modes
8093

8194
Since v4.6.0, the Lighthouse VC can be configured to broadcast messages to all configured beacon

book/src/api_vc_endpoints.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
| [`POST /lighthouse/validators/mnemonic`](#post-lighthousevalidatorsmnemonic) | Create a new validator from an existing mnemonic. |
1919
| [`POST /lighthouse/validators/web3signer`](#post-lighthousevalidatorsweb3signer) | Add web3signer validators. |
2020
| [`GET /lighthouse/logs`](#get-lighthouselogs) | Get logs |
21+
| [`GET /lighthouse/beacon/health`](#get-lighthousebeaconhealth) | Get health information for each connected beacon node. |
2122

2223
The query to Lighthouse API endpoints requires authorization, see [Authorization Header](./api_vc_auth_header.md).
2324

@@ -816,3 +817,56 @@ logs emitted are INFO level or higher.
816817
}
817818
}
818819
```
820+
821+
## `GET /lighthouse/beacon/health`
822+
823+
Provides information about the sync status and execution layer health of each connected beacon node.
824+
For more information about how to interpret the beacon node health, see [Fallback Health](./advanced_redundancy.md#fallback-health).
825+
826+
### HTTP Specification
827+
828+
| Property | Specification |
829+
|-------------------|--------------------------------------------|
830+
| Path | `/lighthouse/beacon/health` |
831+
| Method | GET |
832+
| Required Headers | [`Authorization`](./api_vc_auth_header.md) |
833+
| Typical Responses | 200, 400 |
834+
835+
Command:
836+
837+
```bash
838+
DATADIR=/var/lib/lighthouse
839+
curl -X GET http://localhost:5062/lighthouse/beacon/health \
840+
-H "Authorization: Bearer $(cat ${DATADIR}/validators/api-token.txt)" | jq
841+
```
842+
843+
### Example Response Body
844+
845+
```json
846+
{
847+
"data": {
848+
"beacon_nodes": [
849+
{
850+
"index": 0,
851+
"endpoint": "http://localhost:5052",
852+
"health": {
853+
"user_index": 0,
854+
"head": 10500000,
855+
"optimistic_status": "No",
856+
"execution_status": "Healthy",
857+
"health_tier": {
858+
"tier": 1,
859+
"sync_distance": 0,
860+
"distance_tier": "Synced"
861+
}
862+
}
863+
},
864+
{
865+
"index": 1,
866+
"endpoint": "http://fallbacks-r.us",
867+
"health": "Offline"
868+
}
869+
]
870+
}
871+
}
872+
```

validator_client/http_api/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,10 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
418418
},
419419
);
420420

421-
// GET lighthouse/ui/fallback_health
422-
let get_lighthouse_ui_fallback_health = warp::path("lighthouse")
423-
.and(warp::path("ui"))
424-
.and(warp::path("fallback_health"))
421+
// GET lighthouse/beacon/health
422+
let get_lighthouse_beacon_health = warp::path("lighthouse")
423+
.and(warp::path("beacon"))
424+
.and(warp::path("health"))
425425
.and(warp::path::end())
426426
.and(block_service_filter.clone())
427427
.then(|block_filter: BlockService<T, E>| async move {
@@ -1294,7 +1294,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
12941294
.or(get_lighthouse_validators_pubkey)
12951295
.or(get_lighthouse_ui_health)
12961296
.or(get_lighthouse_ui_graffiti)
1297-
.or(get_lighthouse_ui_fallback_health)
1297+
.or(get_lighthouse_beacon_health)
12981298
.or(get_fee_recipient)
12991299
.or(get_gas_limit)
13001300
.or(get_graffiti)

0 commit comments

Comments
 (0)