mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +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:
@@ -822,6 +822,14 @@ pub async fn blinded_gossip_invalid() {
|
||||
|
||||
tester.harness.advance_slot();
|
||||
|
||||
// Ensure there's at least one blob in the block, so we don't run into failures when the
|
||||
// block generator logic changes, as different errors could be returned:
|
||||
// * Invalidity of blocks: `NotFinalizedDescendant`
|
||||
// * Invalidity of blobs: `ParentUnknown`
|
||||
tester
|
||||
.harness
|
||||
.execution_block_generator()
|
||||
.set_min_blob_count(1);
|
||||
let (blinded_block, _) = tester
|
||||
.harness
|
||||
.make_blinded_block_with_modifier(chain_state_before, slot, |b| {
|
||||
@@ -837,21 +845,20 @@ pub async fn blinded_gossip_invalid() {
|
||||
assert!(response.is_err());
|
||||
|
||||
let error_response: eth2::Error = response.err().unwrap();
|
||||
assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST));
|
||||
|
||||
let pre_finalized_block_root = Hash256::zero();
|
||||
/* mandated by Beacon API spec */
|
||||
if tester.harness.spec.is_fulu_scheduled() {
|
||||
// XXX: this should be a 400 but is a 500 due to the mock-builder being janky
|
||||
assert_eq!(
|
||||
error_response.status(),
|
||||
Some(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
);
|
||||
let expected_error_msg = if tester.harness.spec.is_fulu_scheduled() {
|
||||
format!(
|
||||
"BAD_REQUEST: NotFinalizedDescendant {{ block_parent_root: {pre_finalized_block_root:?} }}"
|
||||
)
|
||||
} else {
|
||||
assert_eq!(error_response.status(), Some(StatusCode::BAD_REQUEST));
|
||||
assert_server_message_error(
|
||||
error_response,
|
||||
format!("BAD_REQUEST: ParentUnknown {{ parent_root: {pre_finalized_block_root:?} }}"),
|
||||
);
|
||||
}
|
||||
// Since Deneb, the invalidity of the blobs will be detected prior to the invalidity of the
|
||||
// block.
|
||||
format!("BAD_REQUEST: ParentUnknown {{ parent_root: {pre_finalized_block_root:?} }}")
|
||||
};
|
||||
|
||||
assert_server_message_error(error_response, expected_error_msg);
|
||||
}
|
||||
|
||||
/// Process a blinded block that is invalid, but valid on gossip.
|
||||
@@ -1647,6 +1654,10 @@ pub async fn block_seen_on_gossip_with_some_blobs_or_columns() {
|
||||
)
|
||||
.await;
|
||||
tester.harness.advance_slot();
|
||||
tester
|
||||
.harness
|
||||
.execution_block_generator()
|
||||
.set_min_blob_count(2);
|
||||
|
||||
let slot_a = Slot::new(num_initial);
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
@@ -178,6 +178,9 @@ impl ApiTester {
|
||||
"precondition: current slot is one after head"
|
||||
);
|
||||
|
||||
// Set a min blob count for the next block for get_blobs testing
|
||||
harness.execution_block_generator().set_min_blob_count(2);
|
||||
|
||||
let (next_block, _next_state) = harness
|
||||
.make_block(head.beacon_state.clone(), harness.chain.slot().unwrap())
|
||||
.await;
|
||||
@@ -1869,7 +1872,7 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
pub async fn test_get_blob_sidecars(self, use_indices: bool) -> Self {
|
||||
let block_id = BlockId(CoreBlockId::Finalized);
|
||||
let block_id = BlockId(CoreBlockId::Head);
|
||||
let (block_root, _, _) = block_id.root(&self.chain).unwrap();
|
||||
let (block, _, _) = block_id.full_block(&self.chain).await.unwrap();
|
||||
let num_blobs = block.num_expected_blobs();
|
||||
@@ -1902,7 +1905,7 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
pub async fn test_get_blobs(self, versioned_hashes: bool) -> Self {
|
||||
let block_id = BlockId(CoreBlockId::Finalized);
|
||||
let block_id = BlockId(CoreBlockId::Head);
|
||||
let (block_root, _, _) = block_id.root(&self.chain).unwrap();
|
||||
let (block, _, _) = block_id.full_block(&self.chain).await.unwrap();
|
||||
let num_blobs = block.num_expected_blobs();
|
||||
@@ -1940,7 +1943,7 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
pub async fn test_get_blobs_post_fulu_full_node(self, versioned_hashes: bool) -> Self {
|
||||
let block_id = BlockId(CoreBlockId::Finalized);
|
||||
let block_id = BlockId(CoreBlockId::Head);
|
||||
let (block_root, _, _) = block_id.root(&self.chain).unwrap();
|
||||
let (block, _, _) = block_id.full_block(&self.chain).await.unwrap();
|
||||
|
||||
@@ -7867,6 +7870,8 @@ async fn get_blobs_post_fulu_supernode() {
|
||||
config.spec.fulu_fork_epoch = Some(Epoch::new(0));
|
||||
|
||||
ApiTester::new_from_config(config)
|
||||
.await
|
||||
.test_post_beacon_blocks_valid()
|
||||
.await
|
||||
// We can call the same get_blobs function in this test
|
||||
// because the function will call get_blobs_by_versioned_hashes which handles peerDAS post-Fulu
|
||||
@@ -7887,6 +7892,8 @@ async fn get_blobs_post_fulu_full_node() {
|
||||
config.spec.fulu_fork_epoch = Some(Epoch::new(0));
|
||||
|
||||
ApiTester::new_from_config(config)
|
||||
.await
|
||||
.test_post_beacon_blocks_valid()
|
||||
.await
|
||||
.test_get_blobs_post_fulu_full_node(false)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user