Implement basic validator custody framework (no backfill) (#7578)

Resolves #6767


  This PR implements a basic version of validator custody.
- It introduces a new `CustodyContext` object which contains info regarding number of validators attached to a node and  the custody count they contribute to the cgc.
- The `CustodyContext` is added in the da_checker and has methods for returning the current cgc and the number of columns to sample at head. Note that the logic for returning the cgc existed previously in the network globals.
- To estimate the number of validators attached, we use the `beacon_committee_subscriptions` endpoint. This might overestimate the number of validators actually publishing attestations from the node in the case of multi BN setups. We could also potentially use the `publish_attestations` endpoint to get a more conservative estimate at a later point.
- Anytime there's a change in the `custody_group_count` due to addition/removal of validators, the custody context should send an event on a broadcast channnel. The only subscriber for the channel exists in the network service which simply subscribes to more subnets. There can be additional subscribers in sync that will start a backfill once the cgc changes.

TODO

- [ ] **NOT REQUIRED:** Currently, the logic only handles an increase in validator count and does not handle a decrease. We should ideally unsubscribe from subnets when the cgc has decreased.
- [ ] **NOT REQUIRED:** Add a service in the `CustodyContext` that emits an event once `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS ` passes after updating the current cgc. This event should be picked up by a subscriber which updates the enr and metadata.
- [x] Add more tests
This commit is contained in:
Pawan Dhananjay
2025-06-11 11:10:06 -07:00
committed by GitHub
parent 076a1c3fae
commit 5f208bb858
38 changed files with 928 additions and 350 deletions

View File

@@ -780,7 +780,7 @@ pub fn update_sync_metrics<E: EthSpec>(network_globals: &Arc<NetworkGlobals<E>>)
let all_column_subnets =
(0..network_globals.spec.data_column_sidecar_subnet_count).map(DataColumnSubnetId::new);
let custody_column_subnets = network_globals.sampling_subnets.iter();
let custody_column_subnets = network_globals.sampling_subnets();
// Iterate all subnet values to set to zero the empty entries in peers_per_column_subnet
for subnet in all_column_subnets {
@@ -794,7 +794,7 @@ pub fn update_sync_metrics<E: EthSpec>(network_globals: &Arc<NetworkGlobals<E>>)
// Registering this metric is a duplicate for supernodes but helpful for fullnodes. This way
// operators can monitor the health of only the subnets of their interest without complex
// Grafana queries.
for subnet in custody_column_subnets {
for subnet in custody_column_subnets.iter() {
set_gauge_entry(
&PEERS_PER_CUSTODY_COLUMN_SUBNET,
&[&format!("{subnet}")],