Use new simulator from unstable

This commit is contained in:
Mac L
2024-04-26 13:07:22 +10:00
parent 4c5dd6716f
commit 85443e8b19
6 changed files with 1 additions and 134 deletions

View File

@@ -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::{

View File

@@ -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};

View File

@@ -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)"),
),
)

View File

@@ -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<E: EthSpec>(
LocalNetworkParams {
eth1_block_time,
total_validator_count,
deposit_amount,
node_count,
proposer_nodes,
post_merge_sim,
}: LocalNetworkParams,
context: RuntimeContext<E>,
) -> Result<(LocalNetwork<E>, 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::<E>(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))
}

View File

@@ -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];

View File

@@ -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)