From 2b93c0eb0d02f381c22c6a8eadd122f98018a061 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Fri, 14 Jul 2023 15:59:15 -0400 Subject: [PATCH] remove spec minimal feature gating in tests (#4468) * remove spec minimal feature gating in tests * do merge transition in overflow cache test --- .github/workflows/test-suite.yml | 8 +++--- .gitignore | 3 +- Makefile | 13 +++++---- beacon_node/Cargo.toml | 1 - beacon_node/beacon_chain/Cargo.toml | 1 - .../overflow_lru_cache.rs | 28 ++++++------------- .../execution_layer/src/test_utils/mod.rs | 4 +-- beacon_node/network/Cargo.toml | 1 - .../network/src/sync/block_lookups/tests.rs | 9 +++--- lighthouse/Cargo.toml | 2 +- 10 files changed, 28 insertions(+), 42 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 0285d63e5..939d548b3 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -119,8 +119,8 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Run operation_pool tests for all known forks run: make test-op-pool - network-minimal-tests: - name: network-minimal-tests + network-tests: + name: network-tests runs-on: ubuntu-latest needs: cargo-fmt steps: @@ -131,8 +131,8 @@ jobs: uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Run network tests for all known forks using the minimal spec - run: make test-network-minimal + - name: Run network tests for all known forks + run: make test-network slasher-tests: name: slasher-tests runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 1e943347d..bbae31454 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ genesis.ssz # IntelliJ /*.iml +.idea + # VSCode /.vscode -.idea diff --git a/Makefile b/Makefile index ad125f324..bd49a9f90 100644 --- a/Makefile +++ b/Makefile @@ -106,12 +106,12 @@ build-release-tarballs: # Runs the full workspace tests in **release**, without downloading any additional # test vectors. test-release: - cargo test --workspace --release --exclude ef_tests --exclude beacon_chain --exclude slasher + cargo test --workspace --release --exclude ef_tests --exclude beacon_chain --exclude slasher --exclude network # Runs the full workspace tests in **debug**, without downloading any additional test # vectors. test-debug: - cargo test --workspace --exclude ef_tests --exclude beacon_chain + cargo test --workspace --exclude ef_tests --exclude beacon_chain --exclude network # Runs cargo-fmt (linter). cargo-fmt: @@ -143,13 +143,14 @@ test-op-pool-%: --features 'beacon_chain/fork_from_env'\ -p operation_pool -test-network-minimal: $(patsubst %,test-network-minimal-%,$(FORKS)) +# Run the tests in the `network` crate for all known forks. +test-network: $(patsubst %,test-network-%,$(FORKS)) -test-network-minimal-%: +test-network-%: env FORK_NAME=$* cargo test --release \ - --features 'fork_from_env,spec-minimal'\ + --features 'fork_from_env' \ -p network - + # Run the tests in the `slasher` crate for all supported database backends. test-slasher: cargo test --release -p slasher --features lmdb diff --git a/beacon_node/Cargo.toml b/beacon_node/Cargo.toml index d3f43fad7..e25fad89a 100644 --- a/beacon_node/Cargo.toml +++ b/beacon_node/Cargo.toml @@ -13,7 +13,6 @@ node_test_rig = { path = "../testing/node_test_rig" } [features] write_ssz_files = ["beacon_chain/write_ssz_files"] # Writes debugging .ssz files to /tmp during block processing. -spec-minimal = ["beacon_chain/spec-minimal"] [dependencies] eth2_config = { path = "../common/eth2_config" } diff --git a/beacon_node/beacon_chain/Cargo.toml b/beacon_node/beacon_chain/Cargo.toml index 77bb514cd..f9c8be20f 100644 --- a/beacon_node/beacon_chain/Cargo.toml +++ b/beacon_node/beacon_chain/Cargo.toml @@ -10,7 +10,6 @@ default = ["participation_metrics"] write_ssz_files = [] # Writes debugging .ssz files to /tmp during block processing. participation_metrics = [] # Exposes validator participation metrics to Prometheus. fork_from_env = [] # Initialise the harness chain spec from the FORK_NAME env variable -spec-minimal = ["kzg/minimal-spec"] [dev-dependencies] maplit = "1.0.2" diff --git a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs index e969c283d..ad00dc32b 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs @@ -849,7 +849,6 @@ impl ssz::Decode for OverflowKey { #[cfg(test)] mod test { use super::*; - #[cfg(feature = "spec-minimal")] use crate::{ blob_verification::{ validate_blob_sidecar_for_gossip, verify_kzg_for_blob, GossipVerifiedBlob, @@ -859,31 +858,20 @@ mod test { eth1_finalization_cache::Eth1FinalizationData, test_utils::{BaseHarnessType, BeaconChainHarness, DiskHarnessType}, }; - #[cfg(feature = "spec-minimal")] + use execution_layer::test_utils::DEFAULT_TERMINAL_BLOCK; use fork_choice::PayloadVerificationStatus; - #[cfg(feature = "spec-minimal")] use logging::test_logger; - #[cfg(feature = "spec-minimal")] use slog::{info, Logger}; - #[cfg(feature = "spec-minimal")] use state_processing::ConsensusContext; - #[cfg(feature = "spec-minimal")] use std::collections::{BTreeMap, HashMap, VecDeque}; - #[cfg(feature = "spec-minimal")] use std::ops::AddAssign; - #[cfg(feature = "spec-minimal")] use store::{HotColdDB, ItemStore, LevelDB, StoreConfig}; - #[cfg(feature = "spec-minimal")] use tempfile::{tempdir, TempDir}; - #[cfg(feature = "spec-minimal")] use types::beacon_state::ssz_tagged_beacon_state; - #[cfg(feature = "spec-minimal")] use types::{ChainSpec, ExecPayload, MinimalEthSpec}; - #[cfg(feature = "spec-minimal")] const LOW_VALIDATOR_COUNT: usize = 32; - #[cfg(feature = "spec-minimal")] fn get_store_with_spec( db_path: &TempDir, spec: ChainSpec, @@ -906,7 +894,6 @@ mod test { } // get a beacon chain harness advanced to just before deneb fork - #[cfg(feature = "spec-minimal")] async fn get_deneb_chain( log: Logger, db_path: &TempDir, @@ -994,7 +981,6 @@ mod test { } #[tokio::test] - #[cfg(feature = "spec-minimal")] async fn ssz_tagged_beacon_state_encode_decode_equality() { type E = MinimalEthSpec; let altair_fork_epoch = Epoch::new(1); @@ -1011,6 +997,13 @@ mod test { spec.bellatrix_fork_epoch = Some(bellatrix_fork_epoch); spec.capella_fork_epoch = Some(capella_fork_epoch); spec.deneb_fork_epoch = Some(deneb_fork_epoch); + let genesis_block = execution_layer::test_utils::generate_genesis_block( + spec.terminal_total_difficulty, + DEFAULT_TERMINAL_BLOCK, + ) + .unwrap(); + spec.terminal_block_hash = genesis_block.block_hash; + spec.terminal_block_hash_activation_epoch = bellatrix_fork_epoch; let harness = BeaconChainHarness::builder(E::default()) .spec(spec) @@ -1069,7 +1062,6 @@ mod test { assert_eq!(state, decoded, "Encoded and decoded states should be equal"); } - #[cfg(feature = "spec-minimal")] async fn availability_pending_block( harness: &BeaconChainHarness>, log: Logger, @@ -1166,7 +1158,6 @@ mod test { } #[tokio::test] - #[cfg(feature = "spec-minimal")] async fn overflow_cache_test_insert_components() { type E = MinimalEthSpec; type T = DiskHarnessType; @@ -1287,7 +1278,6 @@ mod test { } #[tokio::test] - #[cfg(feature = "spec-minimal")] async fn overflow_cache_test_overflow() { type E = MinimalEthSpec; type T = DiskHarnessType; @@ -1447,7 +1437,6 @@ mod test { } #[tokio::test] - #[cfg(feature = "spec-minimal")] async fn overflow_cache_test_maintenance() { type E = MinimalEthSpec; type T = DiskHarnessType; @@ -1599,7 +1588,6 @@ mod test { } #[tokio::test] - #[cfg(feature = "spec-minimal")] async fn overflow_cache_test_persist_recover() { type E = MinimalEthSpec; type T = DiskHarnessType; diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index 98a385c6c..7940cf9f7 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -25,8 +25,8 @@ use warp::{http::StatusCode, Filter, Rejection}; use crate::EngineCapabilities; pub use execution_block_generator::{ - generate_genesis_header, generate_pow_block, generate_random_blobs, Block, - ExecutionBlockGenerator, + generate_genesis_block, generate_genesis_header, generate_pow_block, generate_random_blobs, + Block, ExecutionBlockGenerator, }; pub use hook::Hook; pub use mock_builder::{Context as MockBuilderContext, MockBuilder, Operation, TestingBuilder}; diff --git a/beacon_node/network/Cargo.toml b/beacon_node/network/Cargo.toml index 3420e6468..fb0f7281d 100644 --- a/beacon_node/network/Cargo.toml +++ b/beacon_node/network/Cargo.toml @@ -49,5 +49,4 @@ operation_pool = { path = "../operation_pool" } execution_layer = { path = "../execution_layer" } [features] -spec-minimal = ["beacon_chain/spec-minimal"] fork_from_env = ["beacon_chain/fork_from_env"] diff --git a/beacon_node/network/src/sync/block_lookups/tests.rs b/beacon_node/network/src/sync/block_lookups/tests.rs index ea6fee0af..a061a98d3 100644 --- a/beacon_node/network/src/sync/block_lookups/tests.rs +++ b/beacon_node/network/src/sync/block_lookups/tests.rs @@ -1,4 +1,3 @@ -#![cfg(feature = "spec-minimal")] use std::sync::Arc; use crate::service::RequestId; @@ -117,7 +116,7 @@ impl TestRig { }; let (bundle, transactions) = execution_layer::test_utils::generate_random_blobs::( num_blobs, - &self.harness.chain.kzg.as_ref().unwrap(), + self.harness.chain.kzg.as_ref().unwrap(), ) .unwrap(); @@ -148,8 +147,8 @@ impl TestRig { block_parent_root: block.parent_root(), proposer_index: block.message().proposer_index(), blob: blob.clone(), - kzg_commitment: kzg_commitment.clone(), - kzg_proof: kzg_proof.clone(), + kzg_commitment, + kzg_proof, }); } } @@ -1393,7 +1392,7 @@ mod deneb_only { fn blobs_response_was_valid(mut self) -> Self { self.rig.expect_empty_network(); - if self.blobs.len() > 0 { + if !self.blobs.is_empty() { self.rig.expect_block_process(ResponseType::Blob); } self diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index ae79972e9..bbde006ef 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -17,7 +17,7 @@ modern = ["bls/supranational-force-adx"] # Uses the slower Milagro BLS library, which is written in native Rust. milagro = ["bls/milagro"] # Support minimal spec (used for testing only). -spec-minimal = ["beacon_node/spec-minimal"] +spec-minimal = [] # Support Gnosis spec and Gnosis Beacon Chain. gnosis = [] # Support slasher MDBX backend.