mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
BN Fallback v2 (#2080)
## Issue Addressed - Resolves #1883 ## Proposed Changes This follows on from @blacktemplar's work in #2018. - Allows the VC to connect to multiple BN for redundancy. - Update the simulator so some nodes always need to rely on their fallback. - Adds some extra deprecation warnings for `--eth1-endpoint` - Pass `SignatureBytes` as a reference instead of by value. ## Additional Info NA Co-authored-by: blacktemplar <blacktemplar@a1.net>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::local_network::INVALID_ADDRESS;
|
||||
use crate::{checks, LocalNetwork, E};
|
||||
use clap::ArgMatches;
|
||||
use eth1::http::Eth1Id;
|
||||
@@ -128,8 +129,12 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
/*
|
||||
* One by one, add beacon nodes to the network.
|
||||
*/
|
||||
for _ in 0..node_count - 1 {
|
||||
network.add_beacon_node(beacon_config.clone()).await?;
|
||||
for i in 0..node_count - 1 {
|
||||
let mut config = beacon_config.clone();
|
||||
if i % 2 == 0 {
|
||||
config.eth1.endpoints.insert(0, INVALID_ADDRESS.to_string());
|
||||
}
|
||||
network.add_beacon_node(config).await?;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -137,7 +142,7 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
*/
|
||||
for (i, files) in validator_files.into_iter().enumerate() {
|
||||
network
|
||||
.add_validator_client(testing_validator_config(), i, files)
|
||||
.add_validator_client(testing_validator_config(), i, files, i % 2 == 0)
|
||||
.await?;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::sync::Arc;
|
||||
use types::{Epoch, EthSpec};
|
||||
|
||||
const BOOTNODE_PORT: u16 = 42424;
|
||||
pub const INVALID_ADDRESS: &str = "http://127.0.0.1:42423";
|
||||
|
||||
/// Helper struct to reduce `Arc` usage.
|
||||
pub struct Inner<E: EthSpec> {
|
||||
@@ -118,6 +119,7 @@ impl<E: EthSpec> LocalNetwork<E> {
|
||||
mut validator_config: ValidatorConfig,
|
||||
beacon_node: usize,
|
||||
validator_files: ValidatorFiles,
|
||||
invalid_first_beacon_node: bool, //to test beacon node fallbacks
|
||||
) -> Result<(), String> {
|
||||
let index = self.validator_clients.read().len();
|
||||
let context = self.context.service_context(format!("validator_{}", index));
|
||||
@@ -133,8 +135,12 @@ impl<E: EthSpec> LocalNetwork<E> {
|
||||
.expect("Must have http started")
|
||||
};
|
||||
|
||||
validator_config.beacon_node =
|
||||
format!("http://{}:{}", socket_addr.ip(), socket_addr.port());
|
||||
let beacon_node = format!("http://{}:{}", socket_addr.ip(), socket_addr.port());
|
||||
validator_config.beacon_nodes = if invalid_first_beacon_node {
|
||||
vec![INVALID_ADDRESS.to_string(), beacon_node]
|
||||
} else {
|
||||
vec![beacon_node]
|
||||
};
|
||||
let validator_client = LocalValidatorClient::production_with_insecure_keypairs(
|
||||
context,
|
||||
validator_config,
|
||||
|
||||
@@ -103,7 +103,7 @@ pub fn run_no_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let add_validators_fut = async {
|
||||
for (i, files) in validator_files.into_iter().enumerate() {
|
||||
network
|
||||
.add_validator_client(testing_validator_config(), i, files)
|
||||
.add_validator_client(testing_validator_config(), i, files, i % 2 == 0)
|
||||
.await?;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ fn syncing_sim(
|
||||
* Add a validator client which handles all validators from the genesis state.
|
||||
*/
|
||||
network
|
||||
.add_validator_client(testing_validator_config(), 0, validator_files)
|
||||
.add_validator_client(testing_validator_config(), 0, validator_files, true)
|
||||
.await?;
|
||||
|
||||
// Check all syncing strategies one after other.
|
||||
|
||||
Reference in New Issue
Block a user