mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
`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>
70 lines
2.5 KiB
Rust
70 lines
2.5 KiB
Rust
use clap::ArgMatches;
|
|
use clap_utils::{parse_optional, parse_required};
|
|
use environment::Environment;
|
|
use execution_layer::{
|
|
auth::JwtKey,
|
|
test_utils::{
|
|
Config, DEFAULT_JWT_SECRET, DEFAULT_TERMINAL_BLOCK, MockExecutionConfig, MockServer,
|
|
},
|
|
};
|
|
use std::net::Ipv4Addr;
|
|
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
use types::*;
|
|
|
|
pub fn run<E: EthSpec>(mut env: Environment<E>, matches: &ArgMatches) -> Result<(), String> {
|
|
let jwt_path: PathBuf = parse_required(matches, "jwt-output-path")?;
|
|
let listen_addr: Ipv4Addr = parse_required(matches, "listen-address")?;
|
|
let listen_port: u16 = parse_required(matches, "listen-port")?;
|
|
let all_payloads_valid: bool = parse_required(matches, "all-payloads-valid")?;
|
|
let shanghai_time = parse_required(matches, "shanghai-time")?;
|
|
let cancun_time = parse_optional(matches, "cancun-time")?;
|
|
let prague_time = parse_optional(matches, "prague-time")?;
|
|
let osaka_time = parse_optional(matches, "osaka-time")?;
|
|
let amsterdam_time = parse_optional(matches, "amsterdam-time")?;
|
|
|
|
let handle = env.core_context().executor.handle().unwrap();
|
|
let spec = Arc::new(E::default_spec());
|
|
let jwt_key = JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap();
|
|
std::fs::write(jwt_path, hex::encode(DEFAULT_JWT_SECRET)).unwrap();
|
|
|
|
let config = MockExecutionConfig {
|
|
server_config: Config {
|
|
listen_addr,
|
|
listen_port,
|
|
},
|
|
jwt_key,
|
|
terminal_difficulty: spec.terminal_total_difficulty,
|
|
terminal_block: DEFAULT_TERMINAL_BLOCK,
|
|
terminal_block_hash: spec.terminal_block_hash,
|
|
shanghai_time: Some(shanghai_time),
|
|
cancun_time,
|
|
prague_time,
|
|
osaka_time,
|
|
amsterdam_time,
|
|
};
|
|
let kzg = None;
|
|
let server: MockServer<E> = MockServer::new_with_config(&handle, config, kzg);
|
|
|
|
if all_payloads_valid {
|
|
eprintln!(
|
|
"Using --all-payloads-valid=true can be dangerous. \
|
|
Never use this flag when operating validators."
|
|
);
|
|
// Indicate that all payloads are valid.
|
|
server.all_payloads_valid();
|
|
}
|
|
|
|
eprintln!(
|
|
"This tool is for TESTING PURPOSES ONLY. Do not use in production or on mainnet. \
|
|
It cannot perform validator duties. It may cause nodes to follow an invalid chain."
|
|
);
|
|
eprintln!("Server listening on {}:{}", listen_addr, listen_port);
|
|
|
|
let shutdown_reason = env.block_until_shutdown_requested()?;
|
|
|
|
eprintln!("Shutting down: {:?}", shutdown_reason);
|
|
|
|
Ok(())
|
|
}
|