mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
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:
@@ -39,9 +39,6 @@ type E = MainnetEthSpec;
|
||||
*
|
||||
*/
|
||||
|
||||
// Default custody group count for tests
|
||||
const CGC: usize = 8;
|
||||
|
||||
/// This test checks that a block that is **invalid** from a gossip perspective gets rejected when using `broadcast_validation=gossip`.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
pub async fn gossip_invalid() {
|
||||
@@ -367,9 +364,9 @@ pub async fn consensus_partial_pass_only_consensus() {
|
||||
);
|
||||
assert_ne!(block_a.state_root(), block_b.state_root());
|
||||
|
||||
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain);
|
||||
assert!(gossip_block_b.is_ok());
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain);
|
||||
assert!(gossip_block_a.is_err());
|
||||
|
||||
/* submit `block_b` which should induce equivocation */
|
||||
@@ -657,10 +654,10 @@ pub async fn equivocation_consensus_late_equivocation() {
|
||||
);
|
||||
assert_ne!(block_a.state_root(), block_b.state_root());
|
||||
|
||||
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain);
|
||||
assert!(gossip_block_b.is_ok());
|
||||
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain);
|
||||
assert!(gossip_block_a.is_err());
|
||||
|
||||
let channel = tokio::sync::mpsc::unbounded_channel();
|
||||
@@ -1294,9 +1291,9 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
|
||||
ProvenancedBlock::Builder(b, _, _) => b,
|
||||
};
|
||||
|
||||
let gossip_block_b = GossipVerifiedBlock::new(inner_block_b, &tester.harness.chain, CGC);
|
||||
let gossip_block_b = GossipVerifiedBlock::new(inner_block_b, &tester.harness.chain);
|
||||
assert!(gossip_block_b.is_ok());
|
||||
let gossip_block_a = GossipVerifiedBlock::new(inner_block_a, &tester.harness.chain, CGC);
|
||||
let gossip_block_a = GossipVerifiedBlock::new(inner_block_a, &tester.harness.chain);
|
||||
assert!(gossip_block_a.is_err());
|
||||
|
||||
let channel = tokio::sync::mpsc::unbounded_channel();
|
||||
@@ -1398,7 +1395,7 @@ pub async fn block_seen_on_gossip_without_blobs() {
|
||||
// Simulate the block being seen on gossip.
|
||||
block
|
||||
.clone()
|
||||
.into_gossip_verified_block(&tester.harness.chain, CGC)
|
||||
.into_gossip_verified_block(&tester.harness.chain)
|
||||
.unwrap();
|
||||
|
||||
// It should not yet be added to fork choice because blobs have not been seen.
|
||||
@@ -1467,7 +1464,7 @@ pub async fn block_seen_on_gossip_with_some_blobs() {
|
||||
// Simulate the block being seen on gossip.
|
||||
block
|
||||
.clone()
|
||||
.into_gossip_verified_block(&tester.harness.chain, CGC)
|
||||
.into_gossip_verified_block(&tester.harness.chain)
|
||||
.unwrap();
|
||||
|
||||
// Simulate some of the blobs being seen on gossip.
|
||||
@@ -1786,6 +1783,5 @@ fn get_custody_columns(tester: &InteractiveTester<E>) -> HashSet<ColumnIndex> {
|
||||
.network_globals
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.sampling_columns
|
||||
.clone()
|
||||
.sampling_columns()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user