Add merge support to simulator (#3292)

## Issue Addressed

N/A

## Proposed Changes

Make simulator merge compatible. Adds a `--post_merge` flag to the eth1 simulator that enables a ttd and simulates the merge transition. Uses the `MockServer` in the execution layer test utils to simulate a dummy execution node.

Adds the merge transition simulation to CI.
This commit is contained in:
Pawan Dhananjay
2022-07-18 23:15:40 +00:00
parent da7b7a0f60
commit f9b9658711
17 changed files with 389 additions and 69 deletions

View File

@@ -13,3 +13,4 @@ eth2 = { path = "../../common/eth2" }
validator_client = { path = "../../validator_client" }
validator_dir = { path = "../../common/validator_dir", features = ["insecure_keys"] }
sensitive_url = { path = "../../common/sensitive_url" }
execution_layer = { path = "../../beacon_node/execution_layer" }

View File

@@ -17,6 +17,9 @@ use validator_dir::insecure_keys::build_deterministic_validator_dirs;
pub use beacon_node::{ClientConfig, ClientGenesis, ProductionClient};
pub use environment;
pub use eth2;
pub use execution_layer::test_utils::{
Config as MockServerConfig, MockExecutionConfig, MockServer,
};
pub use validator_client::Config as ValidatorConfig;
/// The global timeout for HTTP requests to the beacon node.
@@ -211,3 +214,29 @@ impl<E: EthSpec> LocalValidatorClient<E> {
})
}
}
/// Provides an execution engine api server that is running in the current process on a given tokio executor (it
/// is _local_ to this process).
///
/// Intended for use in testing and simulation. Not for production.
pub struct LocalExecutionNode<E: EthSpec> {
pub server: MockServer<E>,
pub datadir: TempDir,
}
impl<E: EthSpec> LocalExecutionNode<E> {
pub fn new(context: RuntimeContext<E>, config: MockExecutionConfig) -> Self {
let datadir = TempBuilder::new()
.prefix("lighthouse_node_test_rig_el")
.tempdir()
.expect("should create temp directory for client datadir");
let jwt_file_path = datadir.path().join("jwt.hex");
if let Err(e) = std::fs::write(&jwt_file_path, config.jwt_key.hex_string()) {
panic!("Failed to write jwt file {}", e);
}
Self {
server: MockServer::new_with_config(&context.executor.handle().unwrap(), config),
datadir,
}
}
}