Implement PeerDAS subnet decoupling (aka custody groups) (#6736)

* Implement PeerDAS subnet decoupling (aka custody groups).

* Merge branch 'unstable' into decouple-subnets

* Refactor feature testing for spec tests (#6737)

Squashed commit of the following:

commit 898d05ee17
Merge: ffbd25e2b 7e0cddef3
Author: Jimmy Chen <jchen.tc@gmail.com>
Date:   Tue Dec 24 14:41:19 2024 +1100

    Merge branch 'unstable' into refactor-ef-tests-features

commit ffbd25e2be
Author: Jimmy Chen <jchen.tc@gmail.com>
Date:   Tue Dec 24 14:40:38 2024 +1100

    Fix `SszStatic` tests for PeerDAS: exclude eip7594 test vectors when testing Electra types.

commit aa593cf35c
Author: Jimmy Chen <jchen.tc@gmail.com>
Date:   Fri Dec 20 12:08:54 2024 +1100

    Refactor spec testing for features and simplify usage.

* Fix build.

* Add input validation and improve arithmetic handling when calculating custody groups.

* Address review comments re code style consistency.

* Merge branch 'unstable' into decouple-subnets

# Conflicts:
#	beacon_node/beacon_chain/src/kzg_utils.rs
#	beacon_node/beacon_chain/src/observed_data_sidecars.rs
#	beacon_node/lighthouse_network/src/discovery/subnet_predicate.rs
#	common/eth2_network_config/built_in_network_configs/chiado/config.yaml
#	common/eth2_network_config/built_in_network_configs/gnosis/config.yaml
#	common/eth2_network_config/built_in_network_configs/holesky/config.yaml
#	common/eth2_network_config/built_in_network_configs/mainnet/config.yaml
#	common/eth2_network_config/built_in_network_configs/sepolia/config.yaml
#	consensus/types/src/chain_spec.rs

* Update consensus/types/src/chain_spec.rs

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>

* Merge remote-tracking branch 'origin/unstable' into decouple-subnets

* Update error handling.

* Address review comment.

* Merge remote-tracking branch 'origin/unstable' into decouple-subnets

# Conflicts:
#	consensus/types/src/chain_spec.rs

* Update PeerDAS spec tests to `1.5.0-beta.0` and fix failing unit tests.

* Merge remote-tracking branch 'origin/unstable' into decouple-subnets

# Conflicts:
#	beacon_node/lighthouse_network/src/peer_manager/mod.rs
This commit is contained in:
Jimmy Chen
2025-01-15 18:40:26 +11:00
committed by GitHub
parent dd7591f712
commit e98209d118
39 changed files with 552 additions and 430 deletions

View File

@@ -0,0 +1,47 @@
use super::*;
use serde::Deserialize;
use std::marker::PhantomData;
use types::data_column_custody_group::{compute_columns_for_custody_group, CustodyIndex};
#[derive(Debug, Clone, Deserialize)]
#[serde(bound = "E: EthSpec", deny_unknown_fields)]
pub struct ComputeColumnsForCustodyGroups<E: EthSpec> {
/// The custody group index.
pub custody_group: CustodyIndex,
/// The list of resulting custody columns.
pub result: Vec<u64>,
#[serde(skip)]
_phantom: PhantomData<E>,
}
impl<E: EthSpec> LoadCase for ComputeColumnsForCustodyGroups<E> {
fn load_from_dir(path: &Path, _fork_name: ForkName) -> Result<Self, Error> {
decode::yaml_decode_file(path.join("meta.yaml").as_path())
}
}
impl<E: EthSpec> Case for ComputeColumnsForCustodyGroups<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
let spec = E::default_spec();
let computed_columns = compute_columns_for_custody_group(self.custody_group, &spec)
.expect("should compute custody columns from group")
.collect::<Vec<_>>();
let expected = &self.result;
if computed_columns == *expected {
Ok(())
} else {
Err(Error::NotEqual(format!(
"Got {computed_columns:?}\nExpected {expected:?}"
)))
}
}
}

View File

@@ -2,31 +2,34 @@ use super::*;
use alloy_primitives::U256;
use serde::Deserialize;
use std::marker::PhantomData;
use types::DataColumnSubnetId;
use types::data_column_custody_group::get_custody_groups;
#[derive(Debug, Clone, Deserialize)]
#[serde(bound = "E: EthSpec", deny_unknown_fields)]
pub struct GetCustodyColumns<E: EthSpec> {
pub struct GetCustodyGroups<E: EthSpec> {
/// The NodeID input.
pub node_id: String,
pub custody_subnet_count: u64,
/// The count of custody groups.
pub custody_group_count: u64,
/// The list of resulting custody groups.
pub result: Vec<u64>,
#[serde(skip)]
_phantom: PhantomData<E>,
}
impl<E: EthSpec> LoadCase for GetCustodyColumns<E> {
impl<E: EthSpec> LoadCase for GetCustodyGroups<E> {
fn load_from_dir(path: &Path, _fork_name: ForkName) -> Result<Self, Error> {
decode::yaml_decode_file(path.join("meta.yaml").as_path())
}
}
impl<E: EthSpec> Case for GetCustodyColumns<E> {
impl<E: EthSpec> Case for GetCustodyGroups<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
@@ -34,13 +37,10 @@ impl<E: EthSpec> Case for GetCustodyColumns<E> {
let node_id = U256::from_str_radix(&self.node_id, 10)
.map_err(|e| Error::FailedToParseTest(format!("{e:?}")))?;
let raw_node_id = node_id.to_be_bytes::<32>();
let computed = DataColumnSubnetId::compute_custody_columns::<E>(
raw_node_id,
self.custody_subnet_count,
&spec,
)
.expect("should compute custody columns")
.collect::<Vec<_>>();
let mut computed = get_custody_groups(raw_node_id, self.custody_group_count, &spec)
.map(|set| set.into_iter().collect::<Vec<_>>())
.expect("should compute custody groups");
computed.sort();
let expected = &self.result;
if computed == *expected {

View File

@@ -31,7 +31,7 @@ impl<E: EthSpec> Case for KZGComputeCellsAndKZGProofs<E> {
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

View File

@@ -32,7 +32,7 @@ impl<E: EthSpec> Case for KZGRecoverCellsAndKZGProofs<E> {
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

View File

@@ -34,7 +34,7 @@ impl<E: EthSpec> Case for KZGVerifyCellKZGProofBatch<E> {
}
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
}
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {