mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-26 01:03:40 +00:00
Reduce number of blobs used in tests to speed up CI (#8194)
`beacon-chain-tests` is now regularly taking 1h+ on CI since Fulu fork was added.
This PR attemtpts to reduce the test time by bringing down the number of blobs generated in tests - instead of generating 0..max_blobs, the generator now generates 0..1 blobs by default, and this can be modified by setting `harness.execution_block_generator.set_min_blob_count(n)`.
Note: The blobs are pre-generated and doesn't require too much CPU to generate however processing a larger number of them on the beacon chain does take a lot of time.
This PR also include a few other small improvements
- Our slowest test (`chain_segment_varying_chunk_size`) runs 3x faster in Fulu just by reusing chain segments
- Avoid re-running fork specific tests on all forks
- Fix a bunch of tests that depends on the harness's existing random blob generation, which is fragile
beacon chain test time on test machine is **~2x** faster:
### `unstable`
```
Summary [ 751.586s] 291 tests run: 291 passed (13 slow), 0 skipped
```
### this branch
```
Summary [ 373.792s] 291 tests run: 291 passed (2 slow), 0 skipped
```
The next set of tests to optimise is the ones that use [`get_chain_segment`](77a9af96de/beacon_node/beacon_chain/tests/block_verification.rs (L45)), as it by default build 320 blocks with supernode - an easy optimisation would be to build these blocks with cgc = 8 for tests that only require fullnodes.
Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
Co-Authored-By: Jimmy Chen <jimmy@sigmaprime.io>
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
use beacon_chain::blob_verification::GossipVerifiedBlob;
|
||||
use beacon_chain::data_column_verification::GossipVerifiedDataColumn;
|
||||
use beacon_chain::test_utils::{BeaconChainHarness, generate_data_column_sidecars_from_block};
|
||||
use beacon_chain::test_utils::{
|
||||
BeaconChainHarness, fork_name_from_env, generate_data_column_sidecars_from_block, test_spec,
|
||||
};
|
||||
use eth2::types::{EventKind, SseBlobSidecar, SseDataColumnSidecar};
|
||||
use rand::SeedableRng;
|
||||
use rand::rngs::StdRng;
|
||||
use std::sync::Arc;
|
||||
use types::blob_sidecar::FixedBlobSidecarList;
|
||||
use types::test_utils::TestRandom;
|
||||
use types::{BlobSidecar, DataColumnSidecar, EthSpec, ForkName, MinimalEthSpec, Slot};
|
||||
use types::{BlobSidecar, DataColumnSidecar, EthSpec, MinimalEthSpec, Slot};
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
|
||||
/// Verifies that a blob event is emitted when a gossip verified blob is received via gossip or the publish block API.
|
||||
#[tokio::test]
|
||||
async fn blob_sidecar_event_on_process_gossip_blob() {
|
||||
let spec = Arc::new(ForkName::Deneb.make_genesis_spec(E::default_spec()));
|
||||
if fork_name_from_env().is_some_and(|f| !f.deneb_enabled() || f.fulu_enabled()) {
|
||||
return;
|
||||
};
|
||||
|
||||
let spec = Arc::new(test_spec::<E>());
|
||||
let harness = BeaconChainHarness::builder(E::default())
|
||||
.spec(spec)
|
||||
.deterministic_keypairs(8)
|
||||
@@ -48,7 +54,11 @@ async fn blob_sidecar_event_on_process_gossip_blob() {
|
||||
/// Verifies that a data column event is emitted when a gossip verified data column is received via gossip or the publish block API.
|
||||
#[tokio::test]
|
||||
async fn data_column_sidecar_event_on_process_gossip_data_column() {
|
||||
let spec = Arc::new(ForkName::Fulu.make_genesis_spec(E::default_spec()));
|
||||
if fork_name_from_env().is_some_and(|f| !f.fulu_enabled()) {
|
||||
return;
|
||||
};
|
||||
|
||||
let spec = Arc::new(test_spec::<E>());
|
||||
let harness = BeaconChainHarness::builder(E::default())
|
||||
.spec(spec)
|
||||
.deterministic_keypairs(8)
|
||||
@@ -93,7 +103,11 @@ async fn data_column_sidecar_event_on_process_gossip_data_column() {
|
||||
/// Verifies that a blob event is emitted when blobs are received via RPC.
|
||||
#[tokio::test]
|
||||
async fn blob_sidecar_event_on_process_rpc_blobs() {
|
||||
let spec = Arc::new(ForkName::Deneb.make_genesis_spec(E::default_spec()));
|
||||
if fork_name_from_env().is_some_and(|f| !f.deneb_enabled() || f.fulu_enabled()) {
|
||||
return;
|
||||
};
|
||||
|
||||
let spec = Arc::new(test_spec::<E>());
|
||||
let harness = BeaconChainHarness::builder(E::default())
|
||||
.spec(spec)
|
||||
.deterministic_keypairs(8)
|
||||
@@ -112,7 +126,7 @@ async fn blob_sidecar_event_on_process_rpc_blobs() {
|
||||
let slot = head_state.slot() + 1;
|
||||
let ((signed_block, opt_blobs), _) = harness.make_block(head_state, slot).await;
|
||||
let (kzg_proofs, blobs) = opt_blobs.unwrap();
|
||||
assert!(blobs.len() > 2);
|
||||
assert_eq!(blobs.len(), 2);
|
||||
|
||||
let blob_1 =
|
||||
Arc::new(BlobSidecar::new(0, blobs[0].clone(), &signed_block, kzg_proofs[0]).unwrap());
|
||||
@@ -144,7 +158,11 @@ async fn blob_sidecar_event_on_process_rpc_blobs() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn data_column_sidecar_event_on_process_rpc_columns() {
|
||||
let spec = Arc::new(ForkName::Fulu.make_genesis_spec(E::default_spec()));
|
||||
if fork_name_from_env().is_some_and(|f| !f.fulu_enabled()) {
|
||||
return;
|
||||
};
|
||||
|
||||
let spec = Arc::new(test_spec::<E>());
|
||||
let harness = BeaconChainHarness::builder(E::default())
|
||||
.spec(spec.clone())
|
||||
.deterministic_keypairs(8)
|
||||
|
||||
Reference in New Issue
Block a user