mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 14:24:44 +00:00
Add block ban flag --invalid-block-roots (#7042)
This commit is contained in:
@@ -1621,5 +1621,13 @@ pub fn cli_app() -> Command {
|
||||
.action(ArgAction::Set)
|
||||
.display_order(0)
|
||||
)
|
||||
.arg(
|
||||
Arg::new("invalid-block-roots")
|
||||
.long("invalid-block-roots")
|
||||
.value_name("FILE")
|
||||
.help("Path to a comma separated file containing block roots that should be treated as invalid during block verification.")
|
||||
.action(ArgAction::Set)
|
||||
.hide(true)
|
||||
)
|
||||
.group(ArgGroup::new("enable_http").args(["http", "gui", "staking"]).multiple(true))
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use account_utils::{read_input_from_user, STDIN_INPUTS_FLAG};
|
||||
use beacon_chain::chain_config::{
|
||||
DisallowedReOrgOffsets, ReOrgThreshold, DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR,
|
||||
DEFAULT_RE_ORG_HEAD_THRESHOLD, DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION,
|
||||
DEFAULT_RE_ORG_PARENT_THRESHOLD,
|
||||
DEFAULT_RE_ORG_PARENT_THRESHOLD, INVALID_HOLESKY_BLOCK_ROOT,
|
||||
};
|
||||
use beacon_chain::graffiti_calculator::GraffitiOrigin;
|
||||
use beacon_chain::TrustedSetup;
|
||||
@@ -20,9 +20,10 @@ use lighthouse_network::{multiaddr::Protocol, Enr, Multiaddr, NetworkConfig, Pee
|
||||
use sensitive_url::SensitiveUrl;
|
||||
use slog::{info, warn, Logger};
|
||||
use std::cmp::max;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt::Debug;
|
||||
use std::fs;
|
||||
use std::io::IsTerminal;
|
||||
use std::io::{IsTerminal, Read};
|
||||
use std::net::Ipv6Addr;
|
||||
use std::net::{IpAddr, Ipv4Addr, ToSocketAddrs};
|
||||
use std::num::NonZeroU16;
|
||||
@@ -903,6 +904,40 @@ pub fn get_config<E: EthSpec>(
|
||||
.max_gossip_aggregate_batch_size =
|
||||
clap_utils::parse_required(cli_args, "beacon-processor-aggregate-batch-size")?;
|
||||
|
||||
if let Some(invalid_block_roots_file_path) =
|
||||
clap_utils::parse_optional::<String>(cli_args, "invalid-block-roots")?
|
||||
{
|
||||
let mut file = std::fs::File::open(invalid_block_roots_file_path)
|
||||
.map_err(|e| format!("Failed to open invalid-block-roots file: {}", e))?;
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)
|
||||
.map_err(|e| format!("Failed to read invalid-block-roots file {}", e))?;
|
||||
let invalid_block_roots: HashSet<Hash256> = contents
|
||||
.split(',')
|
||||
.filter_map(
|
||||
|s| match Hash256::from_str(s.strip_prefix("0x").unwrap_or(s).trim()) {
|
||||
Ok(block_root) => Some(block_root),
|
||||
Err(e) => {
|
||||
warn!(
|
||||
log,
|
||||
"Unable to parse invalid block root";
|
||||
"block_root" => s,
|
||||
"error" => ?e,
|
||||
);
|
||||
None
|
||||
}
|
||||
},
|
||||
)
|
||||
.collect();
|
||||
client_config.chain.invalid_block_roots = invalid_block_roots;
|
||||
} else if spec
|
||||
.config_name
|
||||
.as_ref()
|
||||
.is_some_and(|network_name| network_name == "holesky")
|
||||
{
|
||||
client_config.chain.invalid_block_roots = HashSet::from([*INVALID_HOLESKY_BLOCK_ROOT]);
|
||||
}
|
||||
|
||||
Ok(client_config)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user