mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Unify execution layer endpoints (#3214)
## Issue Addressed Resolves #3069 ## Proposed Changes Unify the `eth1-endpoints` and `execution-endpoints` flags in a backwards compatible way as described in https://github.com/sigp/lighthouse/issues/3069#issuecomment-1134219221 Users have 2 options: 1. Use multiple non auth execution endpoints for deposit processing pre-merge 2. Use a single jwt authenticated execution endpoint for both execution layer and deposit processing post merge Related https://github.com/sigp/lighthouse/issues/3118 To enable jwt authenticated deposit processing, this PR removes the calls to `net_version` as the `net` namespace is not exposed in the auth server in execution clients. Moving away from using `networkId` is a good step in my opinion as it doesn't provide us with any added guarantees over `chainId`. See https://github.com/ethereum/consensus-specs/issues/2163 and https://github.com/sigp/lighthouse/issues/2115 Co-authored-by: Paul Hauner <paul@paulhauner.com>
This commit is contained in:
@@ -16,17 +16,11 @@ pub struct GanacheInstance {
|
||||
pub port: u16,
|
||||
child: Child,
|
||||
pub web3: Web3<Http>,
|
||||
network_id: u64,
|
||||
chain_id: u64,
|
||||
}
|
||||
|
||||
impl GanacheInstance {
|
||||
fn new_from_child(
|
||||
mut child: Child,
|
||||
port: u16,
|
||||
network_id: u64,
|
||||
chain_id: u64,
|
||||
) -> Result<Self, String> {
|
||||
fn new_from_child(mut child: Child, port: u16, chain_id: u64) -> Result<Self, String> {
|
||||
let stdout = child
|
||||
.stdout
|
||||
.ok_or("Unable to get stdout for ganache child process")?;
|
||||
@@ -64,14 +58,13 @@ impl GanacheInstance {
|
||||
port,
|
||||
child,
|
||||
web3,
|
||||
network_id,
|
||||
chain_id,
|
||||
})
|
||||
}
|
||||
|
||||
/// Start a new `ganache` process, waiting until it indicates that it is ready to accept
|
||||
/// RPC connections.
|
||||
pub fn new(network_id: u64, chain_id: u64) -> Result<Self, String> {
|
||||
pub fn new(chain_id: u64) -> Result<Self, String> {
|
||||
let port = unused_tcp_port()?;
|
||||
let binary = match cfg!(windows) {
|
||||
true => "ganache.cmd",
|
||||
@@ -89,8 +82,6 @@ impl GanacheInstance {
|
||||
.arg(format!("{}", port))
|
||||
.arg("--mnemonic")
|
||||
.arg("\"vast thought differ pull jewel broom cook wrist tribe word before omit\"")
|
||||
.arg("--networkId")
|
||||
.arg(format!("{}", network_id))
|
||||
.arg("--chain.chainId")
|
||||
.arg(format!("{}", chain_id))
|
||||
.spawn()
|
||||
@@ -102,7 +93,7 @@ impl GanacheInstance {
|
||||
)
|
||||
})?;
|
||||
|
||||
Self::new_from_child(child, port, network_id, chain_id)
|
||||
Self::new_from_child(child, port, chain_id)
|
||||
}
|
||||
|
||||
pub fn fork(&self) -> Result<Self, String> {
|
||||
@@ -128,7 +119,7 @@ impl GanacheInstance {
|
||||
)
|
||||
})?;
|
||||
|
||||
Self::new_from_child(child, port, self.network_id, self.chain_id)
|
||||
Self::new_from_child(child, port, self.chain_id)
|
||||
}
|
||||
|
||||
/// Returns the endpoint that this instance is listening on.
|
||||
@@ -136,11 +127,6 @@ impl GanacheInstance {
|
||||
endpoint(self.port)
|
||||
}
|
||||
|
||||
/// Returns the network id of the ganache instance
|
||||
pub fn network_id(&self) -> u64 {
|
||||
self.network_id
|
||||
}
|
||||
|
||||
/// Returns the chain id of the ganache instance
|
||||
pub fn chain_id(&self) -> u64 {
|
||||
self.chain_id
|
||||
|
||||
@@ -30,8 +30,8 @@ pub struct GanacheEth1Instance {
|
||||
}
|
||||
|
||||
impl GanacheEth1Instance {
|
||||
pub async fn new(network_id: u64, chain_id: u64) -> Result<Self, String> {
|
||||
let ganache = GanacheInstance::new(network_id, chain_id)?;
|
||||
pub async fn new(chain_id: u64) -> Result<Self, String> {
|
||||
let ganache = GanacheInstance::new(chain_id)?;
|
||||
DepositContract::deploy(ganache.web3.clone(), 0, None)
|
||||
.await
|
||||
.map(|deposit_contract| Self {
|
||||
|
||||
@@ -9,6 +9,7 @@ edition = "2021"
|
||||
[dependencies]
|
||||
node_test_rig = { path = "../node_test_rig" }
|
||||
eth1 = {path = "../../beacon_node/eth1"}
|
||||
execution_layer = {path = "../../beacon_node/execution_layer"}
|
||||
types = { path = "../../consensus/types" }
|
||||
parking_lot = "0.12.0"
|
||||
futures = "0.3.7"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use crate::local_network::INVALID_ADDRESS;
|
||||
use crate::{checks, LocalNetwork, E};
|
||||
use clap::ArgMatches;
|
||||
use eth1::http::Eth1Id;
|
||||
use eth1::{DEFAULT_CHAIN_ID, DEFAULT_NETWORK_ID};
|
||||
use eth1::{Eth1Endpoint, DEFAULT_CHAIN_ID};
|
||||
use eth1_test_rig::GanacheEth1Instance;
|
||||
|
||||
use execution_layer::http::deposit_methods::Eth1Id;
|
||||
use futures::prelude::*;
|
||||
use node_test_rig::{
|
||||
environment::{EnvironmentBuilder, LoggerConfig},
|
||||
@@ -92,10 +93,8 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
* Deploy the deposit contract, spawn tasks to keep creating new blocks and deposit
|
||||
* validators.
|
||||
*/
|
||||
let ganache_eth1_instance =
|
||||
GanacheEth1Instance::new(DEFAULT_NETWORK_ID.into(), DEFAULT_CHAIN_ID.into()).await?;
|
||||
let ganache_eth1_instance = GanacheEth1Instance::new(DEFAULT_CHAIN_ID.into()).await?;
|
||||
let deposit_contract = ganache_eth1_instance.deposit_contract;
|
||||
let network_id = ganache_eth1_instance.ganache.network_id();
|
||||
let chain_id = ganache_eth1_instance.ganache.chain_id();
|
||||
let ganache = ganache_eth1_instance.ganache;
|
||||
let eth1_endpoint = SensitiveUrl::parse(ganache.endpoint().as_str())
|
||||
@@ -124,7 +123,7 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let mut beacon_config = testing_client_config();
|
||||
|
||||
beacon_config.genesis = ClientGenesis::DepositContract;
|
||||
beacon_config.eth1.endpoints = vec![eth1_endpoint];
|
||||
beacon_config.eth1.endpoints = Eth1Endpoint::NoAuth(vec![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;
|
||||
@@ -133,7 +132,6 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
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.network_id = Eth1Id::from(network_id);
|
||||
beacon_config.eth1.chain_id = Eth1Id::from(chain_id);
|
||||
beacon_config.network.target_peers = node_count - 1;
|
||||
|
||||
@@ -150,10 +148,13 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
for i in 0..node_count - 1 {
|
||||
let mut config = beacon_config.clone();
|
||||
if i % 2 == 0 {
|
||||
config.eth1.endpoints.insert(
|
||||
0,
|
||||
SensitiveUrl::parse(INVALID_ADDRESS).expect("Unable to parse invalid address"),
|
||||
);
|
||||
if let Eth1Endpoint::NoAuth(endpoints) = &mut config.eth1.endpoints {
|
||||
endpoints.insert(
|
||||
0,
|
||||
SensitiveUrl::parse(INVALID_ADDRESS)
|
||||
.expect("Unable to parse invalid address"),
|
||||
)
|
||||
}
|
||||
}
|
||||
network.add_beacon_node(config).await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user