Skip to content

Commit

Permalink
Fix build.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed Dec 24, 2024
1 parent b5a5ee8 commit b449b85
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 42 deletions.
10 changes: 3 additions & 7 deletions beacon_node/http_api/src/publish_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,8 @@ fn build_gossip_verified_data_columns<T: BeaconChainTypes>(
let gossip_verified_data_columns = data_column_sidecars
.into_iter()
.map(|data_column_sidecar| {
let column_index = data_column_sidecar.index as usize;
let subnet =
DataColumnSubnetId::from_column_index::<T::EthSpec>(column_index, &chain.spec);
let column_index = data_column_sidecar.index;
let subnet = DataColumnSubnetId::from_column_index(column_index, &chain.spec);
let gossip_verified_column =
GossipVerifiedDataColumn::new(data_column_sidecar, subnet.into(), chain);

Expand Down Expand Up @@ -520,10 +519,7 @@ fn publish_column_sidecars<T: BeaconChainTypes>(
let pubsub_messages = data_column_sidecars
.into_iter()
.map(|data_col| {
let subnet = DataColumnSubnetId::from_column_index::<T::EthSpec>(
data_col.index as usize,
&chain.spec,
);
let subnet = DataColumnSubnetId::from_column_index(data_col.index, &chain.spec);
PubsubMessage::DataColumnSidecar(Box::new((subnet, data_col)))
})
.collect::<Vec<_>>();
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/network/src/sync/network_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use std::sync::Arc;
use std::time::Duration;
use tokio::sync::mpsc;
use types::blob_sidecar::FixedBlobSidecarList;
use types::data_column_custody_group::{compute_columns_for_custody_group, CustodyIndex};
use types::{
BlobSidecar, ColumnIndex, DataColumnSidecar, DataColumnSidecarList, EthSpec, Hash256,
SignedBeaconBlock, Slot,
Expand Down Expand Up @@ -448,7 +447,8 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {

let info = RangeBlockComponentsRequest::new(
expected_blobs,
expects_columns,
// TODO[JC]: Fix types
expects_columns.map(|c| c.into_iter().collect()),
num_of_column_req,
requested_peers,
);
Expand Down
2 changes: 1 addition & 1 deletion testing/ef_tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TESTS_TAG := v1.5.0-alpha.8
TESTS_TAG := v1.5.0-alpha.10
TESTS = general minimal mainnet
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))

Expand Down
8 changes: 4 additions & 4 deletions testing/ef_tests/src/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,26 @@ pub use transition::TransitionTest;
/// to return `true` for the feature in order for the feature test vector to be tested.
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum FeatureName {
Eip7594,
Fulu,
}

impl FeatureName {
pub fn list_all() -> Vec<FeatureName> {
vec![FeatureName::Eip7594]
vec![FeatureName::Fulu]
}

/// `ForkName` to use when running the feature tests.
pub fn fork_name(&self) -> ForkName {
match self {
FeatureName::Eip7594 => ForkName::Deneb,
FeatureName::Fulu => ForkName::Electra,
}
}
}

impl Display for FeatureName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
FeatureName::Eip7594 => f.write_str("eip7594"),
FeatureName::Fulu => f.write_str("fulu"),
}
}
}
Expand Down
25 changes: 13 additions & 12 deletions testing/ef_tests/src/cases/get_custody_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ use super::*;
use alloy_primitives::U256;
use serde::Deserialize;
use std::marker::PhantomData;
use types::DataColumnSubnetId;
use types::data_column_custody_group::{compute_columns_for_custody_group, get_custody_groups};

#[derive(Debug, Clone, Deserialize)]
#[serde(bound = "E: EthSpec", deny_unknown_fields)]
pub struct GetCustodyColumns<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 columns.
pub result: Vec<u64>,
#[serde(skip)]
_phantom: PhantomData<E>,
Expand All @@ -26,28 +29,26 @@ impl<E: EthSpec> Case for GetCustodyColumns<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> {
let spec = E::default_spec();
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 computed_groups = get_custody_groups(raw_node_id, self.custody_group_count, &spec);
let computed_columns = computed_groups
.into_iter()
.flat_map(|custody_group| compute_columns_for_custody_group(custody_group, &spec))
.collect::<Vec<_>>();

let expected = &self.result;
if computed == *expected {
if computed_columns == *expected {
Ok(())
} else {
Err(Error::NotEqual(format!(
"Got {computed:?}\nExpected {expected:?}"
"Got {computed_columns:?}\nExpected {expected:?}"
)))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
12 changes: 8 additions & 4 deletions testing/ef_tests/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ pub trait Handler {
}
}

// Run feature tests for future forks that are not yet added to `ForkName`.
// This runs tests in the directory named by the feature instead of the fork name.
// e.g. consensus-spec-tests/tests/general/[feature_name]/[runner_name]
// e.g. consensus-spec-tests/tests/general/peerdas/ssz_static
for feature_name in FeatureName::list_all() {
if self.is_enabled_for_feature(feature_name) {
self.run_for_feature(feature_name);
Expand Down Expand Up @@ -354,7 +358,7 @@ where
// SszStaticHandler::<AttestationBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra().run();
// SszStaticHandler::<AttestationElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only().run();
// ```
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
&& self.supported_forks.contains(&feature_name.fork_name())
}
}
Expand All @@ -378,7 +382,7 @@ where
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
}
}

Expand All @@ -403,7 +407,7 @@ where
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
}
}

Expand Down Expand Up @@ -988,7 +992,7 @@ impl<E: EthSpec + TypeName> Handler for KzgInclusionMerkleProofValidityHandler<E
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Eip7594
feature_name == FeatureName::Fulu
}
}

Expand Down
18 changes: 9 additions & 9 deletions testing/ef_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,17 +627,17 @@ mod ssz_static {
#[test]
fn data_column_sidecar() {
SszStaticHandler::<DataColumnSidecar<MinimalEthSpec>, MinimalEthSpec>::deneb_only()
.run_for_feature(FeatureName::Eip7594);
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnSidecar<MainnetEthSpec>, MainnetEthSpec>::deneb_only()
.run_for_feature(FeatureName::Eip7594);
.run_for_feature(FeatureName::Fulu);
}

#[test]
fn data_column_identifier() {
SszStaticHandler::<DataColumnIdentifier, MinimalEthSpec>::deneb_only()
.run_for_feature(FeatureName::Eip7594);
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnIdentifier, MainnetEthSpec>::deneb_only()
.run_for_feature(FeatureName::Eip7594);
.run_for_feature(FeatureName::Fulu);
}

#[test]
Expand Down Expand Up @@ -902,19 +902,19 @@ fn kzg_verify_kzg_proof() {
#[test]
fn kzg_compute_cells_and_proofs() {
KZGComputeCellsAndKZGProofHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Eip7594);
.run_for_feature(FeatureName::Fulu);
}

#[test]
fn kzg_verify_cell_proof_batch() {
KZGVerifyCellKZGProofBatchHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Eip7594);
.run_for_feature(FeatureName::Fulu);
}

#[test]
fn kzg_recover_cells_and_proofs() {
KZGRecoverCellsAndKZGProofHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Eip7594);
.run_for_feature(FeatureName::Fulu);
}

#[test]
Expand Down Expand Up @@ -949,6 +949,6 @@ fn rewards() {

#[test]
fn get_custody_columns() {
GetCustodyColumnsHandler::<MainnetEthSpec>::default().run_for_feature(FeatureName::Eip7594);
GetCustodyColumnsHandler::<MinimalEthSpec>::default().run_for_feature(FeatureName::Eip7594);
GetCustodyColumnsHandler::<MainnetEthSpec>::default().run_for_feature(FeatureName::Fulu);
GetCustodyColumnsHandler::<MinimalEthSpec>::default().run_for_feature(FeatureName::Fulu);
}

0 comments on commit b449b85

Please sign in to comment.