From 85443e8b1900a08376fb3670473b2918e7e92bba Mon Sep 17 00:00:00 2001 From: Mac L Date: Fri, 26 Apr 2024 13:07:22 +1000 Subject: [PATCH] Use new simulator from unstable --- testing/simulator/src/basic_sim.rs | 1 - testing/simulator/src/checks.rs | 1 - testing/simulator/src/cli.rs | 16 ----- testing/simulator/src/common.rs | 100 -------------------------- testing/simulator/src/fallback_sim.rs | 2 +- testing/simulator/src/main.rs | 15 ---- 6 files changed, 1 insertion(+), 134 deletions(-) delete mode 100644 testing/simulator/src/common.rs diff --git a/testing/simulator/src/basic_sim.rs b/testing/simulator/src/basic_sim.rs index 8ac3270b27..755bb71b43 100644 --- a/testing/simulator/src/basic_sim.rs +++ b/testing/simulator/src/basic_sim.rs @@ -3,7 +3,6 @@ use crate::local_network::TERMINAL_BLOCK; use crate::{checks, LocalNetwork}; use clap::ArgMatches; -use crate::common::{create_local_network, LocalNetworkParams}; use crate::retry::with_retry; use futures::prelude::*; use node_test_rig::{ diff --git a/testing/simulator/src/checks.rs b/testing/simulator/src/checks.rs index fde0975595..03cc17fab3 100644 --- a/testing/simulator/src/checks.rs +++ b/testing/simulator/src/checks.rs @@ -1,5 +1,4 @@ use crate::local_network::LocalNetwork; -use crate::ACCEPTABLE_FALLBACK_ATTESTATION_HIT_PERCENTAGE; use node_test_rig::eth2::types::{BlockId, FinalityCheckpointsData, StateId}; use std::time::Duration; use types::{Epoch, EthSpec, ExecPayload, ExecutionBlockHash, Slot, Unsigned}; diff --git a/testing/simulator/src/cli.rs b/testing/simulator/src/cli.rs index 0584f15137..00af7e560c 100644 --- a/testing/simulator/src/cli.rs +++ b/testing/simulator/src/cli.rs @@ -120,22 +120,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .short("c") .long("continue_after_checks") .takes_value(false) - .help("Number of validators per client"), - ) - .arg( - Arg::with_name("speed_up_factor") - .short("s") - .long("speed_up_factor") - .takes_value(true) - .default_value("3") - .help("Speed up factor. Please use a divisor of 12."), - ) - .arg( - Arg::with_name("continue_after_checks") - .short("c") - .long("continue_after_checks") - .takes_value(false) - .help("Continue after checks (default false)") .help("Continue after checks (default false)"), ), ) diff --git a/testing/simulator/src/common.rs b/testing/simulator/src/common.rs deleted file mode 100644 index 318356f47e..0000000000 --- a/testing/simulator/src/common.rs +++ /dev/null @@ -1,100 +0,0 @@ -use crate::local_network::EXECUTION_PORT; -use crate::LocalNetwork; -use eth1::{Eth1Endpoint, DEFAULT_CHAIN_ID}; -use eth1_test_rig::AnvilEth1Instance; - -use execution_layer::http::deposit_methods::Eth1Id; -use node_test_rig::environment::RuntimeContext; -use node_test_rig::{testing_client_config, ClientConfig, ClientGenesis}; -use sensitive_url::SensitiveUrl; -use std::net::Ipv4Addr; -use std::time::Duration; -use types::EthSpec; - -pub struct LocalNetworkParams { - pub eth1_block_time: Duration, - pub total_validator_count: usize, - pub deposit_amount: u64, - pub node_count: usize, - pub proposer_nodes: usize, - pub post_merge_sim: bool, -} - -pub async fn create_local_network( - LocalNetworkParams { - eth1_block_time, - total_validator_count, - deposit_amount, - node_count, - proposer_nodes, - post_merge_sim, - }: LocalNetworkParams, - context: RuntimeContext, -) -> Result<(LocalNetwork, ClientConfig), String> { - /* - * Deploy the deposit contract, spawn tasks to keep creating new blocks and deposit - * validators. - */ - let anvil_eth1_instance = AnvilEth1Instance::new(DEFAULT_CHAIN_ID.into()).await?; - let deposit_contract = anvil_eth1_instance.deposit_contract; - let chain_id = anvil_eth1_instance.anvil.chain_id(); - let anvil = anvil_eth1_instance.anvil; - let eth1_endpoint = - SensitiveUrl::parse(anvil.endpoint().as_str()).expect("Unable to parse anvil endpoint."); - let deposit_contract_address = deposit_contract.address(); - - // Start a timer that produces eth1 blocks on an interval. - tokio::spawn(async move { - let mut interval = tokio::time::interval(eth1_block_time); - loop { - interval.tick().await; - let _ = anvil.evm_mine().await; - } - }); - - // Submit deposits to the deposit contract. - tokio::spawn(async move { - for i in 0..total_validator_count { - println!("Submitting deposit for validator {}...", i); - let _ = deposit_contract - .deposit_deterministic_async::(i, deposit_amount) - .await; - } - }); - - let mut beacon_config = testing_client_config(); - - beacon_config.genesis = ClientGenesis::DepositContract; - beacon_config.eth1.endpoint = Eth1Endpoint::NoAuth(eth1_endpoint); - beacon_config.eth1.deposit_contract_address = deposit_contract_address; - beacon_config.eth1.deposit_contract_deploy_block = 0; - beacon_config.eth1.lowest_cached_block_number = 0; - beacon_config.eth1.follow_distance = 1; - beacon_config.eth1.node_far_behind_seconds = 20; - beacon_config.dummy_eth1_backend = false; - beacon_config.sync_eth1_chain = true; - beacon_config.eth1.auto_update_interval_millis = eth1_block_time.as_millis() as u64; - beacon_config.eth1.chain_id = Eth1Id::from(chain_id); - beacon_config.network.target_peers = node_count + proposer_nodes - 1; - - beacon_config.network.enr_address = (Some(Ipv4Addr::LOCALHOST), None); - beacon_config.network.enable_light_client_server = true; - beacon_config.chain.enable_light_client_server = true; - beacon_config.http_api.enable_light_client_server = true; - - if post_merge_sim { - let el_config = execution_layer::Config { - execution_endpoints: vec![SensitiveUrl::parse(&format!( - "http://localhost:{}", - EXECUTION_PORT - )) - .unwrap()], - ..Default::default() - }; - - beacon_config.execution_layer = Some(el_config); - } - - let network = LocalNetwork::new(context, beacon_config.clone()).await?; - Ok((network, beacon_config)) -} diff --git a/testing/simulator/src/fallback_sim.rs b/testing/simulator/src/fallback_sim.rs index c9deeba04d..01f7c8418e 100644 --- a/testing/simulator/src/fallback_sim.rs +++ b/testing/simulator/src/fallback_sim.rs @@ -28,7 +28,7 @@ const DENEB_FORK_EPOCH: u64 = 2; // This has potential to block CI so it should be set conservatively enough that spurious failures // don't become very common, but not so conservatively that regressions to the fallback mechanism // cannot be detected. -const ACCEPTABLE_FALLBACK_ATTESTATION_HIT_PERCENTAGE: f64 = 85.0; +const ACCEPTABLE_FALLBACK_ATTESTATION_HIT_PERCENTAGE: f64 = 95.0; const SUGGESTED_FEE_RECIPIENT: [u8; 20] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]; diff --git a/testing/simulator/src/main.rs b/testing/simulator/src/main.rs index 53f3de916c..d1a2d0dc67 100644 --- a/testing/simulator/src/main.rs +++ b/testing/simulator/src/main.rs @@ -26,14 +26,6 @@ use env_logger::{Builder, Env}; use local_network::LocalNetwork; use types::MinimalEthSpec; -// Since simulator tests are non-deterministic and there is a non-zero chance of missed -// attestations, define an acceptable network-wide attestation performance. -// -// This has potential to block CI so it should be set conservatively enough that spurious failures -// don't become very common, but not so conservatively that regressions to the fallback mechanism -// cannot be detected. -pub(crate) const ACCEPTABLE_FALLBACK_ATTESTATION_HIT_PERCENTAGE: f64 = 95.0; - pub type E = MinimalEthSpec; fn main() { @@ -56,13 +48,6 @@ fn main() { std::process::exit(1) } }, - ("fallback-sim", Some(matches)) => match fallback_sim::run_fallback_sim(matches) { - Ok(()) => println!("Simulation exited successfully"), - Err(e) => { - eprintln!("Simulation exited with an error: {}", e); - std::process::exit(1) - } - }, _ => { eprintln!("Invalid subcommand. Use --help to see available options"); std::process::exit(1)