mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Remove CGC from data_availability checker (#7033)
- Part of https://github.com/sigp/lighthouse/issues/6767 Validator custody makes the CGC and set of sampling columns dynamic. Right now this information is stored twice: - in the data availability checker - in the network globals If that state becomes dynamic we must make sure it is in sync updating it twice, or guarding it behind a mutex. However, I noted that we don't really have to keep the CGC inside the data availability checker. All consumers can actually read it from the network globals, and we can update `make_available` to read the expected count of data columns from the block.
This commit is contained in:
@@ -137,7 +137,8 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
|
||||
spawn_build_data_sidecar_task(chain.clone(), block.clone(), unverified_blobs)?;
|
||||
|
||||
// Gossip verify the block and blobs/data columns separately.
|
||||
let gossip_verified_block_result = unverified_block.into_gossip_verified_block(&chain);
|
||||
let gossip_verified_block_result = unverified_block
|
||||
.into_gossip_verified_block(&chain, network_globals.custody_columns_count() as usize);
|
||||
let block_root = block_root.unwrap_or_else(|| {
|
||||
gossip_verified_block_result.as_ref().map_or_else(
|
||||
|_| block.canonical_root(),
|
||||
|
||||
@@ -39,6 +39,9 @@ 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() {
|
||||
@@ -364,9 +367,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);
|
||||
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
assert!(gossip_block_b.is_ok());
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain);
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
assert!(gossip_block_a.is_err());
|
||||
|
||||
/* submit `block_b` which should induce equivocation */
|
||||
@@ -654,10 +657,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);
|
||||
let gossip_block_b = block_b.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
assert!(gossip_block_b.is_ok());
|
||||
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain);
|
||||
let gossip_block_a = block_a.into_gossip_verified_block(&tester.harness.chain, CGC);
|
||||
assert!(gossip_block_a.is_err());
|
||||
|
||||
let channel = tokio::sync::mpsc::unbounded_channel();
|
||||
@@ -1291,9 +1294,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);
|
||||
let gossip_block_b = GossipVerifiedBlock::new(inner_block_b, &tester.harness.chain, CGC);
|
||||
assert!(gossip_block_b.is_ok());
|
||||
let gossip_block_a = GossipVerifiedBlock::new(inner_block_a, &tester.harness.chain);
|
||||
let gossip_block_a = GossipVerifiedBlock::new(inner_block_a, &tester.harness.chain, CGC);
|
||||
assert!(gossip_block_a.is_err());
|
||||
|
||||
let channel = tokio::sync::mpsc::unbounded_channel();
|
||||
@@ -1395,7 +1398,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)
|
||||
.into_gossip_verified_block(&tester.harness.chain, CGC)
|
||||
.unwrap();
|
||||
|
||||
// It should not yet be added to fork choice because blobs have not been seen.
|
||||
@@ -1464,7 +1467,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)
|
||||
.into_gossip_verified_block(&tester.harness.chain, CGC)
|
||||
.unwrap();
|
||||
|
||||
// Simulate some of the blobs being seen on gossip.
|
||||
|
||||
Reference in New Issue
Block a user