mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 11:41:28 +00:00
Fix Syncing Simulator (#2049)
## Issue Addressed NA ## Proposed Changes Fixes problems with slot times below 1 second which got revealed by running the syncing simulator with the default speedup time.
This commit is contained in:
parent
da1c5fe69d
commit
3fcc517993
10
.github/workflows/test-suite.yml
vendored
10
.github/workflows/test-suite.yml
vendored
@ -146,6 +146,16 @@ jobs:
|
||||
run: sudo npm install -g ganache-cli
|
||||
- name: Run the beacon chain sim without an eth1 connection
|
||||
run: cargo run --release --bin simulator no-eth1-sim
|
||||
syncing-simulator-ubuntu:
|
||||
name: syncing-simulator-ubuntu
|
||||
runs-on: ubuntu-latest
|
||||
needs: cargo-fmt
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install ganache-cli
|
||||
run: sudo npm install -g ganache-cli
|
||||
- name: Run the syncing simulator
|
||||
run: cargo run --release --bin simulator syncing-sim
|
||||
check-benchmarks:
|
||||
name: check-benchmarks
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -56,7 +56,7 @@ impl<TSpec: EthSpec> PeerScoreSettings<TSpec> {
|
||||
epoch: slot * TSpec::slots_per_epoch() as u32,
|
||||
beacon_attestation_subnet_weight,
|
||||
max_positive_score,
|
||||
decay_interval: slot,
|
||||
decay_interval: max(Duration::from_secs(1), slot),
|
||||
decay_to_zero: 0.01,
|
||||
mesh_n: gs_config.mesh_n(),
|
||||
max_committees_per_slot: chain_spec.max_committees_per_slot,
|
||||
|
@ -9,6 +9,7 @@ use node_test_rig::{
|
||||
ClientGenesis, ValidatorFiles,
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use std::cmp::max;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::time::Duration;
|
||||
use types::{Epoch, EthSpec, MainnetEthSpec};
|
||||
@ -57,6 +58,8 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let total_validator_count = validators_per_node * node_count;
|
||||
|
||||
spec.milliseconds_per_slot /= speed_up_factor;
|
||||
//currently lighthouse only supports slot lengths that are multiples of seconds
|
||||
spec.milliseconds_per_slot = max(1000, spec.milliseconds_per_slot / 1000 * 1000);
|
||||
spec.eth1_follow_distance = 16;
|
||||
spec.genesis_delay = eth1_block_time.as_secs() * spec.eth1_follow_distance * 2;
|
||||
spec.min_genesis_time = 0;
|
||||
|
@ -6,6 +6,7 @@ use node_test_rig::{
|
||||
ClientGenesis, ValidatorFiles,
|
||||
};
|
||||
use rayon::prelude::*;
|
||||
use std::cmp::max;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
use tokio::time::{sleep_until, Instant};
|
||||
@ -55,6 +56,8 @@ pub fn run_no_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let total_validator_count = validators_per_node * node_count;
|
||||
|
||||
spec.milliseconds_per_slot /= speed_up_factor;
|
||||
//currently lighthouse only supports slot lengths that are multiples of seconds
|
||||
spec.milliseconds_per_slot = max(1000, spec.milliseconds_per_slot / 1000 * 1000);
|
||||
spec.eth1_follow_distance = 16;
|
||||
spec.genesis_delay = eth1_block_time.as_secs() * spec.eth1_follow_distance * 2;
|
||||
spec.min_genesis_time = 0;
|
||||
|
@ -2,11 +2,11 @@ use crate::checks::{epoch_delay, verify_all_finalized_at};
|
||||
use crate::local_network::LocalNetwork;
|
||||
use clap::ArgMatches;
|
||||
use futures::prelude::*;
|
||||
use node_test_rig::ClientConfig;
|
||||
use node_test_rig::{
|
||||
environment::EnvironmentBuilder, testing_client_config, ClientGenesis, ValidatorConfig,
|
||||
ValidatorFiles,
|
||||
environment::EnvironmentBuilder, testing_client_config, ClientGenesis, ValidatorFiles,
|
||||
};
|
||||
use node_test_rig::{testing_validator_config, ClientConfig};
|
||||
use std::cmp::max;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
use types::{Epoch, EthSpec};
|
||||
@ -54,6 +54,8 @@ fn syncing_sim(
|
||||
let eth1_block_time = Duration::from_millis(15_000 / speed_up_factor);
|
||||
|
||||
spec.milliseconds_per_slot /= speed_up_factor;
|
||||
//currently lighthouse only supports slot lengths that are multiples of seconds
|
||||
spec.milliseconds_per_slot = max(1000, spec.milliseconds_per_slot / 1000 * 1000);
|
||||
spec.eth1_follow_distance = 16;
|
||||
spec.genesis_delay = eth1_block_time.as_secs() * spec.eth1_follow_distance * 2;
|
||||
spec.min_genesis_time = 0;
|
||||
@ -92,7 +94,7 @@ fn syncing_sim(
|
||||
* Add a validator client which handles all validators from the genesis state.
|
||||
*/
|
||||
network
|
||||
.add_validator_client(ValidatorConfig::default(), 0, validator_files)
|
||||
.add_validator_client(testing_validator_config(), 0, validator_files)
|
||||
.await?;
|
||||
|
||||
// Check all syncing strategies one after other.
|
||||
@ -129,7 +131,14 @@ fn syncing_sim(
|
||||
Ok::<(), String>(())
|
||||
};
|
||||
|
||||
env.runtime().block_on(main_future)
|
||||
env.runtime()
|
||||
.block_on(tokio_compat_02::FutureExt::compat(main_future))
|
||||
.unwrap();
|
||||
|
||||
env.fire_signal();
|
||||
env.shutdown_on_idle();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn pick_strategy<E: EthSpec>(
|
||||
|
Loading…
Reference in New Issue
Block a user