mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
[package]
|
||||
name = "lighthouse"
|
||||
version = "2.2.1"
|
||||
version = "3.1.0"
|
||||
authors = ["Sigma Prime <contact@sigmaprime.io>"]
|
||||
edition = "2021"
|
||||
autotests = false
|
||||
rust-version = "1.58"
|
||||
rust-version = "1.62"
|
||||
|
||||
[features]
|
||||
default = ["malloc_utils/jemalloc"]
|
||||
default = ["slasher-mdbx", "malloc_utils/jemalloc"]
|
||||
# Writes debugging .ssz files to /tmp during block processing.
|
||||
write_ssz_files = ["beacon_node/write_ssz_files"]
|
||||
# Compiles the BLS crypto code so that the binary is portable across machines.
|
||||
@@ -20,6 +20,10 @@ milagro = ["bls/milagro"]
|
||||
spec-minimal = []
|
||||
# Support Gnosis spec and Gnosis Beacon Chain.
|
||||
gnosis = []
|
||||
# Support slasher MDBX backend.
|
||||
slasher-mdbx = ["slasher/mdbx"]
|
||||
# Support slasher LMDB backend.
|
||||
slasher-lmdb = ["slasher/lmdb"]
|
||||
|
||||
[dependencies]
|
||||
beacon_node = { "path" = "../beacon_node" }
|
||||
@@ -50,6 +54,7 @@ directory = { path = "../common/directory" }
|
||||
unused_port = { path = "../common/unused_port" }
|
||||
store = { path = "../beacon_node/store" }
|
||||
database_manager = { path = "../database_manager" }
|
||||
slasher = { path = "../slasher" }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.1.0"
|
||||
@@ -57,6 +62,7 @@ validator_dir = { path = "../common/validator_dir" }
|
||||
slashing_protection = { path = "../validator_client/slashing_protection" }
|
||||
lighthouse_network = { path = "../beacon_node/lighthouse_network" }
|
||||
sensitive_url = { path = "../common/sensitive_url" }
|
||||
eth1 = { path = "../beacon_node/eth1" }
|
||||
|
||||
[[test]]
|
||||
name = "lighthouse_tests"
|
||||
|
||||
@@ -47,6 +47,7 @@ pub struct LoggerConfig<'a> {
|
||||
pub debug_level: &'a str,
|
||||
pub logfile_debug_level: &'a str,
|
||||
pub log_format: Option<&'a str>,
|
||||
pub log_color: bool,
|
||||
pub max_log_size: u64,
|
||||
pub max_log_number: usize,
|
||||
pub compression: bool,
|
||||
@@ -139,7 +140,13 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
|
||||
_ => return Err("Logging format provided is not supported".to_string()),
|
||||
}
|
||||
} else {
|
||||
let stdout_decorator = slog_term::TermDecorator::new().build();
|
||||
let stdout_decorator_builder = slog_term::TermDecorator::new();
|
||||
let stdout_decorator = if config.log_color {
|
||||
stdout_decorator_builder.force_color()
|
||||
} else {
|
||||
stdout_decorator_builder
|
||||
}
|
||||
.build();
|
||||
let stdout_decorator =
|
||||
logging::AlignedTermDecorator::new(stdout_decorator, logging::MAX_MESSAGE_WIDTH);
|
||||
let stdout_drain = slog_term::FullFormat::new(stdout_decorator).build().fuse();
|
||||
|
||||
@@ -138,6 +138,13 @@ fn main() {
|
||||
.takes_value(true)
|
||||
.global(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("log-color")
|
||||
.long("log-color")
|
||||
.alias("log-colour")
|
||||
.help("Force outputting colors when emitting logs to the terminal.")
|
||||
.global(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("debug-level")
|
||||
.long("debug-level")
|
||||
@@ -227,7 +234,7 @@ fn main() {
|
||||
Accepts a 256-bit decimal integer (not a hex value). \
|
||||
This flag should only be used if the user has a clear understanding that \
|
||||
the broad Ethereum community has elected to override the terminal difficulty. \
|
||||
Incorrect use of this flag will cause your node to experience a consensus
|
||||
Incorrect use of this flag will cause your node to experience a consensus \
|
||||
failure. Be extremely careful with this flag.")
|
||||
.takes_value(true)
|
||||
.global(true)
|
||||
@@ -239,7 +246,7 @@ fn main() {
|
||||
.help("Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH parameter. \
|
||||
This flag should only be used if the user has a clear understanding that \
|
||||
the broad Ethereum community has elected to override the terminal PoW block. \
|
||||
Incorrect use of this flag will cause your node to experience a consensus
|
||||
Incorrect use of this flag will cause your node to experience a consensus \
|
||||
failure. Be extremely careful with this flag.")
|
||||
.requires("terminal-block-hash-epoch-override")
|
||||
.takes_value(true)
|
||||
@@ -252,7 +259,7 @@ fn main() {
|
||||
.help("Used to coordinate manual overrides to the TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH \
|
||||
parameter. This flag should only be used if the user has a clear understanding \
|
||||
that the broad Ethereum community has elected to override the terminal PoW block. \
|
||||
Incorrect use of this flag will cause your node to experience a consensus
|
||||
Incorrect use of this flag will cause your node to experience a consensus \
|
||||
failure. Be extremely careful with this flag.")
|
||||
.requires("terminal-block-hash-override")
|
||||
.takes_value(true)
|
||||
@@ -372,6 +379,8 @@ fn run<E: EthSpec>(
|
||||
|
||||
let log_format = matches.value_of("log-format");
|
||||
|
||||
let log_color = matches.is_present("log-color");
|
||||
|
||||
let logfile_debug_level = matches
|
||||
.value_of("logfile-debug-level")
|
||||
.ok_or("Expected --logfile-debug-level flag")?;
|
||||
@@ -424,6 +433,7 @@ fn run<E: EthSpec>(
|
||||
debug_level,
|
||||
logfile_debug_level,
|
||||
log_format,
|
||||
log_color,
|
||||
max_log_size: logfile_max_size * 1_024 * 1_024,
|
||||
max_log_number: logfile_max_number,
|
||||
compression: logfile_compress,
|
||||
|
||||
@@ -494,6 +494,8 @@ fn validator_import_launchpad() {
|
||||
description: "".into(),
|
||||
graffiti: None,
|
||||
suggested_fee_recipient: None,
|
||||
gas_limit: None,
|
||||
builder_proposals: None,
|
||||
voting_public_key: keystore.public_key().unwrap(),
|
||||
signing_definition: SigningDefinition::LocalKeystore {
|
||||
voting_keystore_path,
|
||||
@@ -614,6 +616,8 @@ fn validator_import_launchpad_no_password_then_add_password() {
|
||||
description: "".into(),
|
||||
graffiti: None,
|
||||
suggested_fee_recipient: None,
|
||||
gas_limit: None,
|
||||
builder_proposals: None,
|
||||
voting_public_key: keystore.public_key().unwrap(),
|
||||
signing_definition: SigningDefinition::LocalKeystore {
|
||||
voting_keystore_path,
|
||||
@@ -638,6 +642,8 @@ fn validator_import_launchpad_no_password_then_add_password() {
|
||||
description: "".into(),
|
||||
graffiti: None,
|
||||
suggested_fee_recipient: None,
|
||||
gas_limit: None,
|
||||
builder_proposals: None,
|
||||
voting_public_key: keystore.public_key().unwrap(),
|
||||
signing_definition: SigningDefinition::LocalKeystore {
|
||||
voting_keystore_path: dst_keystore_dir.join(KEYSTORE_NAME),
|
||||
@@ -738,6 +744,8 @@ fn validator_import_launchpad_password_file() {
|
||||
voting_public_key: keystore.public_key().unwrap(),
|
||||
graffiti: None,
|
||||
suggested_fee_recipient: None,
|
||||
gas_limit: None,
|
||||
builder_proposals: None,
|
||||
signing_definition: SigningDefinition::LocalKeystore {
|
||||
voting_keystore_path,
|
||||
voting_keystore_password_path: None,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use beacon_node::ClientConfig as Config;
|
||||
use beacon_node::{beacon_chain::CountUnrealizedFull, ClientConfig as Config};
|
||||
|
||||
use crate::exec::{CommandLineTestExec, CompletedTest};
|
||||
use eth1::Eth1Endpoint;
|
||||
use lighthouse_network::PeerId;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
@@ -10,7 +11,7 @@ use std::process::Command;
|
||||
use std::str::FromStr;
|
||||
use std::string::ToString;
|
||||
use tempfile::TempDir;
|
||||
use types::{Address, Checkpoint, Epoch, ExecutionBlockHash, Hash256, MainnetEthSpec};
|
||||
use types::{Address, Checkpoint, Epoch, ExecutionBlockHash, ForkName, Hash256, MainnetEthSpec};
|
||||
use unused_port::{unused_tcp_port, unused_udp_port};
|
||||
|
||||
const DEFAULT_ETH1_ENDPOINT: &str = "http://localhost:8545/";
|
||||
@@ -66,7 +67,10 @@ fn staking_flag() {
|
||||
.with_config(|config| {
|
||||
assert!(config.http_api.enabled);
|
||||
assert!(config.sync_eth1_chain);
|
||||
assert_eq!(config.eth1.endpoints[0].to_string(), DEFAULT_ETH1_ENDPOINT);
|
||||
assert_eq!(
|
||||
config.eth1.endpoints.get_endpoints()[0].to_string(),
|
||||
DEFAULT_ETH1_ENDPOINT
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -128,6 +132,106 @@ fn fork_choice_before_proposal_timeout_zero() {
|
||||
.with_config(|config| assert_eq!(config.chain.fork_choice_before_proposal_timeout_ms, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paranoid_block_proposal_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(!config.chain.paranoid_block_proposal));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paranoid_block_proposal_on() {
|
||||
CommandLineTest::new()
|
||||
.flag("paranoid-block-proposal", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.chain.paranoid_block_proposal));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.chain.count_unrealized));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_no_arg() {
|
||||
CommandLineTest::new()
|
||||
.flag("count-unrealized", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.chain.count_unrealized));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_false() {
|
||||
CommandLineTest::new()
|
||||
.flag("count-unrealized", Some("false"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(!config.chain.count_unrealized));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_true() {
|
||||
CommandLineTest::new()
|
||||
.flag("count-unrealized", Some("true"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.chain.count_unrealized));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_full_no_arg() {
|
||||
CommandLineTest::new()
|
||||
.flag("count-unrealized-full", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config.chain.count_unrealized_full,
|
||||
CountUnrealizedFull::False
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_full_false() {
|
||||
CommandLineTest::new()
|
||||
.flag("count-unrealized-full", Some("false"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config.chain.count_unrealized_full,
|
||||
CountUnrealizedFull::False
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_full_true() {
|
||||
CommandLineTest::new()
|
||||
.flag("count-unrealized-full", Some("true"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config.chain.count_unrealized_full,
|
||||
CountUnrealizedFull::True
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_payload_statuses_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(!config.chain.always_reset_payload_statuses));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_payload_statuses_present() {
|
||||
CommandLineTest::new()
|
||||
.flag("reset-payload-statuses", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.chain.always_reset_payload_statuses));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn freezer_dir_flag() {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
@@ -196,18 +300,21 @@ fn eth1_endpoints_flag() {
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config.eth1.endpoints[0].full.to_string(),
|
||||
config.eth1.endpoints.get_endpoints()[0].full.to_string(),
|
||||
"http://localhost:9545/"
|
||||
);
|
||||
assert_eq!(
|
||||
config.eth1.endpoints[0].to_string(),
|
||||
config.eth1.endpoints.get_endpoints()[0].to_string(),
|
||||
"http://localhost:9545/"
|
||||
);
|
||||
assert_eq!(
|
||||
config.eth1.endpoints[1].full.to_string(),
|
||||
config.eth1.endpoints.get_endpoints()[1].full.to_string(),
|
||||
"https://infura.io/secret"
|
||||
);
|
||||
assert_eq!(config.eth1.endpoints[1].to_string(), "https://infura.io/");
|
||||
assert_eq!(
|
||||
config.eth1.endpoints.get_endpoints()[1].to_string(),
|
||||
"https://infura.io/"
|
||||
);
|
||||
assert!(config.sync_eth1_chain);
|
||||
});
|
||||
}
|
||||
@@ -225,47 +332,128 @@ fn eth1_purge_cache_flag() {
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.eth1.purge_cache));
|
||||
}
|
||||
|
||||
// Tests for Bellatrix flags.
|
||||
#[test]
|
||||
fn merge_flag() {
|
||||
fn eth1_cache_follow_distance_default() {
|
||||
CommandLineTest::new()
|
||||
.flag("merge", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.execution_layer.is_some()));
|
||||
.with_config(|config| {
|
||||
assert_eq!(config.eth1.cache_follow_distance, None);
|
||||
assert_eq!(config.eth1.cache_follow_distance(), 3 * 2048 / 4);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn merge_execution_endpoints_flag() {
|
||||
fn eth1_cache_follow_distance_manual() {
|
||||
CommandLineTest::new()
|
||||
.flag("eth1-cache-follow-distance", Some("128"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(config.eth1.cache_follow_distance, Some(128));
|
||||
assert_eq!(config.eth1.cache_follow_distance(), 128);
|
||||
});
|
||||
}
|
||||
|
||||
// Tests for Bellatrix flags.
|
||||
fn run_merge_execution_endpoints_flag_test(flag: &str) {
|
||||
use sensitive_url::SensitiveUrl;
|
||||
let urls = vec!["http://sigp.io/no-way:1337", "http://infura.not_real:4242"];
|
||||
let endpoints = urls
|
||||
.iter()
|
||||
.map(|s| SensitiveUrl::parse(s).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
// we don't support redundancy for execution-endpoints
|
||||
// only the first provided endpoint is parsed.
|
||||
|
||||
let mut endpoint_arg = urls[0].to_string();
|
||||
for url in urls.into_iter().skip(1) {
|
||||
for url in urls.iter().skip(1) {
|
||||
endpoint_arg.push(',');
|
||||
endpoint_arg.push_str(url);
|
||||
}
|
||||
|
||||
let (_dirs, jwts): (Vec<_>, Vec<_>) = (0..2)
|
||||
.map(|i| {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let path = dir.path().join(format!("jwt-{}", i));
|
||||
(dir, path)
|
||||
})
|
||||
.unzip();
|
||||
|
||||
let mut jwts_arg = jwts[0].as_os_str().to_str().unwrap().to_string();
|
||||
for jwt in jwts.iter().skip(1) {
|
||||
jwts_arg.push(',');
|
||||
jwts_arg.push_str(jwt.as_os_str().to_str().unwrap());
|
||||
}
|
||||
|
||||
// this is way better but intersperse is still a nightly feature :/
|
||||
// let endpoint_arg: String = urls.into_iter().intersperse(",").collect();
|
||||
CommandLineTest::new()
|
||||
.flag("merge", None)
|
||||
.flag("execution-endpoints", Some(&endpoint_arg))
|
||||
.flag(flag, Some(&endpoint_arg))
|
||||
.flag("execution-jwt", Some(&jwts_arg))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
let config = config.execution_layer.as_ref().unwrap();
|
||||
assert_eq!(config.execution_endpoints, endpoints)
|
||||
assert_eq!(config.execution_endpoints.len(), 1);
|
||||
assert_eq!(
|
||||
config.execution_endpoints[0],
|
||||
SensitiveUrl::parse(&urls[0]).unwrap()
|
||||
);
|
||||
// Only the first secret file should be used.
|
||||
assert_eq!(config.secret_files, vec![jwts[0].clone()]);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn merge_execution_endpoints_flag() {
|
||||
run_merge_execution_endpoints_flag_test("execution-endpoints")
|
||||
}
|
||||
#[test]
|
||||
fn merge_execution_endpoint_flag() {
|
||||
run_merge_execution_endpoints_flag_test("execution-endpoint")
|
||||
}
|
||||
fn run_execution_endpoints_overrides_eth1_endpoints_test(eth1_flag: &str, execution_flag: &str) {
|
||||
use sensitive_url::SensitiveUrl;
|
||||
|
||||
let eth1_endpoint = "http://bad.bad";
|
||||
let execution_endpoint = "http://good.good";
|
||||
|
||||
assert!(eth1_endpoint != execution_endpoint);
|
||||
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let jwt_path = dir.path().join("jwt-file");
|
||||
|
||||
CommandLineTest::new()
|
||||
.flag(eth1_flag, Some(ð1_endpoint))
|
||||
.flag(execution_flag, Some(&execution_endpoint))
|
||||
.flag("execution-jwt", jwt_path.as_os_str().to_str())
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config.execution_layer.as_ref().unwrap().execution_endpoints,
|
||||
vec![SensitiveUrl::parse(execution_endpoint).unwrap()]
|
||||
);
|
||||
|
||||
// The eth1 endpoint should have been set to the --execution-endpoint value in defiance
|
||||
// of --eth1-endpoints.
|
||||
assert_eq!(
|
||||
config.eth1.endpoints,
|
||||
Eth1Endpoint::Auth {
|
||||
endpoint: SensitiveUrl::parse(execution_endpoint).unwrap(),
|
||||
jwt_path: jwt_path.clone(),
|
||||
jwt_id: None,
|
||||
jwt_version: None,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn execution_endpoints_overrides_eth1_endpoints() {
|
||||
run_execution_endpoints_overrides_eth1_endpoints_test("eth1-endpoints", "execution-endpoints");
|
||||
}
|
||||
#[test]
|
||||
fn execution_endpoint_overrides_eth1_endpoint() {
|
||||
run_execution_endpoints_overrides_eth1_endpoints_test("eth1-endpoint", "execution-endpoint");
|
||||
}
|
||||
#[test]
|
||||
fn merge_jwt_secrets_flag() {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let mut file = File::create(dir.path().join("jwtsecrets")).expect("Unable to create file");
|
||||
file.write_all(b"0x3cbc11b0d8fa16f3344eacfd6ff6430b9d30734450e8adcf5400f88d327dcb33")
|
||||
.expect("Unable to write to file");
|
||||
CommandLineTest::new()
|
||||
.flag("merge", None)
|
||||
.flag("execution-endpoints", Some("http://localhost:8551/"))
|
||||
.flag(
|
||||
"jwt-secrets",
|
||||
@@ -283,8 +471,13 @@ fn merge_jwt_secrets_flag() {
|
||||
}
|
||||
#[test]
|
||||
fn merge_fee_recipient_flag() {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
CommandLineTest::new()
|
||||
.flag("merge", None)
|
||||
.flag("execution-endpoint", Some("http://meow.cats"))
|
||||
.flag(
|
||||
"execution-jwt",
|
||||
dir.path().join("jwt-file").as_os_str().to_str(),
|
||||
)
|
||||
.flag(
|
||||
"suggested-fee-recipient",
|
||||
Some("0x00000000219ab540356cbb839cbe05303d7705fa"),
|
||||
@@ -298,20 +491,158 @@ fn merge_fee_recipient_flag() {
|
||||
);
|
||||
});
|
||||
}
|
||||
fn run_payload_builder_flag_test(flag: &str, builders: &str) {
|
||||
use sensitive_url::SensitiveUrl;
|
||||
|
||||
let all_builders: Vec<_> = builders
|
||||
.split(",")
|
||||
.map(|builder| SensitiveUrl::parse(builder).expect("valid builder url"))
|
||||
.collect();
|
||||
run_payload_builder_flag_test_with_config(flag, builders, None, None, |config| {
|
||||
let config = config.execution_layer.as_ref().unwrap();
|
||||
// Only first provided endpoint is parsed as we don't support
|
||||
// redundancy.
|
||||
assert_eq!(config.builder_url, all_builders.get(0).cloned());
|
||||
})
|
||||
}
|
||||
fn run_payload_builder_flag_test_with_config<F: Fn(&Config)>(
|
||||
flag: &str,
|
||||
builders: &str,
|
||||
additional_flag: Option<&str>,
|
||||
additional_flag_value: Option<&str>,
|
||||
f: F,
|
||||
) {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let mut test = CommandLineTest::new();
|
||||
test.flag("execution-endpoint", Some("http://meow.cats"))
|
||||
.flag(
|
||||
"execution-jwt",
|
||||
dir.path().join("jwt-file").as_os_str().to_str(),
|
||||
)
|
||||
.flag(flag, Some(builders));
|
||||
if let Some(additional_flag_name) = additional_flag {
|
||||
test.flag(additional_flag_name, additional_flag_value);
|
||||
}
|
||||
test.run_with_zero_port().with_config(f);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jwt_optional_flags() {
|
||||
fn payload_builder_flags() {
|
||||
run_payload_builder_flag_test("builder", "http://meow.cats");
|
||||
run_payload_builder_flag_test("payload-builder", "http://meow.cats");
|
||||
run_payload_builder_flag_test("payload-builders", "http://meow.cats,http://woof.dogs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builder_fallback_flags() {
|
||||
run_payload_builder_flag_test_with_config(
|
||||
"builder",
|
||||
"http://meow.cats",
|
||||
Some("builder-fallback-skips"),
|
||||
Some("7"),
|
||||
|config| {
|
||||
assert_eq!(config.chain.builder_fallback_skips, 7);
|
||||
},
|
||||
);
|
||||
run_payload_builder_flag_test_with_config(
|
||||
"builder",
|
||||
"http://meow.cats",
|
||||
Some("builder-fallback-skips-per-epoch"),
|
||||
Some("11"),
|
||||
|config| {
|
||||
assert_eq!(config.chain.builder_fallback_skips_per_epoch, 11);
|
||||
},
|
||||
);
|
||||
run_payload_builder_flag_test_with_config(
|
||||
"builder",
|
||||
"http://meow.cats",
|
||||
Some("builder-fallback-epochs-since-finalization"),
|
||||
Some("4"),
|
||||
|config| {
|
||||
assert_eq!(config.chain.builder_fallback_epochs_since_finalization, 4);
|
||||
},
|
||||
);
|
||||
run_payload_builder_flag_test_with_config(
|
||||
"builder",
|
||||
"http://meow.cats",
|
||||
Some("builder-fallback-disable-checks"),
|
||||
None,
|
||||
|config| {
|
||||
assert_eq!(config.chain.builder_fallback_disable_checks, true);
|
||||
},
|
||||
);
|
||||
run_payload_builder_flag_test_with_config(
|
||||
"builder",
|
||||
"http://meow.cats",
|
||||
Some("builder-profit-threshold"),
|
||||
Some("1000000000000000000000000"),
|
||||
|config| {
|
||||
assert_eq!(
|
||||
config
|
||||
.execution_layer
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.builder_profit_threshold,
|
||||
1000000000000000000000000
|
||||
);
|
||||
},
|
||||
);
|
||||
run_payload_builder_flag_test_with_config(
|
||||
"builder",
|
||||
"http://meow.cats",
|
||||
None,
|
||||
None,
|
||||
|config| {
|
||||
assert_eq!(
|
||||
config
|
||||
.execution_layer
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.builder_profit_threshold,
|
||||
0
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn run_jwt_optional_flags_test(jwt_flag: &str, jwt_id_flag: &str, jwt_version_flag: &str) {
|
||||
use sensitive_url::SensitiveUrl;
|
||||
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let execution_endpoint = "http://meow.cats";
|
||||
let jwt_file = "jwt-file";
|
||||
let id = "bn-1";
|
||||
let version = "Lighthouse-v2.1.3";
|
||||
CommandLineTest::new()
|
||||
.flag("merge", None)
|
||||
.flag("jwt-id", Some("bn-1"))
|
||||
.flag("jwt-version", Some("Lighthouse-v2.1.3"))
|
||||
.flag("execution-endpoint", Some(execution_endpoint.clone()))
|
||||
.flag(jwt_flag, dir.path().join(jwt_file).as_os_str().to_str())
|
||||
.flag(jwt_id_flag, Some(id))
|
||||
.flag(jwt_version_flag, Some(version))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
let config = config.execution_layer.as_ref().unwrap();
|
||||
assert_eq!(config.jwt_id, Some("bn-1".to_string()));
|
||||
assert_eq!(config.jwt_version, Some("Lighthouse-v2.1.3".to_string()));
|
||||
let el_config = config.execution_layer.as_ref().unwrap();
|
||||
assert_eq!(el_config.jwt_id, Some(id.to_string()));
|
||||
assert_eq!(el_config.jwt_version, Some(version.to_string()));
|
||||
assert_eq!(
|
||||
config.eth1.endpoints,
|
||||
Eth1Endpoint::Auth {
|
||||
endpoint: SensitiveUrl::parse(execution_endpoint).unwrap(),
|
||||
jwt_path: dir.path().join(jwt_file),
|
||||
jwt_id: Some(id.to_string()),
|
||||
jwt_version: Some(version.to_string()),
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn jwt_optional_flags() {
|
||||
run_jwt_optional_flags_test("execution-jwt", "execution-jwt-id", "execution-jwt-version");
|
||||
}
|
||||
#[test]
|
||||
fn jwt_optional_alias_flags() {
|
||||
run_jwt_optional_flags_test("jwt-secrets", "jwt-id", "jwt-version");
|
||||
}
|
||||
#[test]
|
||||
fn terminal_total_difficulty_override_flag() {
|
||||
use beacon_node::beacon_chain::types::Uint256;
|
||||
CommandLineTest::new()
|
||||
@@ -719,6 +1050,21 @@ fn http_tls_flags() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn http_spec_fork_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert_eq!(config.http_api.spec_fork_name, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn http_spec_fork_override() {
|
||||
CommandLineTest::new()
|
||||
.flag("http-spec-fork", Some("altair"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert_eq!(config.http_api.spec_fork_name, Some(ForkName::Altair)));
|
||||
}
|
||||
|
||||
// Tests for Metrics flags.
|
||||
#[test]
|
||||
fn metrics_flag() {
|
||||
@@ -1043,8 +1389,34 @@ fn slasher_broadcast_flag() {
|
||||
assert!(slasher_config.broadcast);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn malloc_tuning_flag() {
|
||||
fn slasher_backend_default() {
|
||||
CommandLineTest::new()
|
||||
.flag("slasher", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
let slasher_config = config.slasher.as_ref().unwrap();
|
||||
assert_eq!(slasher_config.backend, slasher::DatabaseBackend::Mdbx);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slasher_backend_override_to_default() {
|
||||
// Hard to test this flag because all but one backend is disabled by default and the backend
|
||||
// called "disabled" results in a panic.
|
||||
CommandLineTest::new()
|
||||
.flag("slasher", None)
|
||||
.flag("slasher-backend", Some("mdbx"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
let slasher_config = config.slasher.as_ref().unwrap();
|
||||
assert_eq!(slasher_config.backend, slasher::DatabaseBackend::Mdbx);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malloc_tuning_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("disable-malloc-tuning", None)
|
||||
.run_with_zero_port()
|
||||
@@ -1067,3 +1439,16 @@ fn ensure_panic_on_failed_launch() {
|
||||
assert_eq!(slasher_config.chunk_size, 10);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn monitoring_endpoint() {
|
||||
CommandLineTest::new()
|
||||
.flag("monitoring-endpoint", Some("http://example:8000"))
|
||||
.flag("monitoring-endpoint-period", Some("30"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
let api_conf = config.monitoring_api.as_ref().unwrap();
|
||||
assert_eq!(api_conf.monitoring_endpoint.as_str(), "http://example:8000");
|
||||
assert_eq!(api_conf.update_period_secs, Some(30));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -249,66 +249,6 @@ fn fee_recipient_flag() {
|
||||
)
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn fee_recipient_file_flag() {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let mut file =
|
||||
File::create(dir.path().join("fee_recipient.txt")).expect("Unable to create file");
|
||||
let new_key = Keypair::random();
|
||||
let pubkeybytes = PublicKeyBytes::from(new_key.pk);
|
||||
let contents = "default:0x00000000219ab540356cbb839cbe05303d7705fa";
|
||||
file.write_all(contents.as_bytes())
|
||||
.expect("Unable to write to file");
|
||||
CommandLineTest::new()
|
||||
.flag(
|
||||
"suggested-fee-recipient-file",
|
||||
dir.path().join("fee_recipient.txt").as_os_str().to_str(),
|
||||
)
|
||||
.run()
|
||||
.with_config(|config| {
|
||||
// Public key not present so load default.
|
||||
assert_eq!(
|
||||
config
|
||||
.fee_recipient_file
|
||||
.clone()
|
||||
.unwrap()
|
||||
.load_fee_recipient(&pubkeybytes)
|
||||
.unwrap(),
|
||||
Some(Address::from_str("0x00000000219ab540356cbb839cbe05303d7705fa").unwrap())
|
||||
)
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn fee_recipient_file_with_pk_flag() {
|
||||
let dir = TempDir::new().expect("Unable to create temporary directory");
|
||||
let mut file =
|
||||
File::create(dir.path().join("fee_recipient.txt")).expect("Unable to create file");
|
||||
let new_key = Keypair::random();
|
||||
let pubkeybytes = PublicKeyBytes::from(new_key.pk);
|
||||
let contents = format!(
|
||||
"{}:0x00000000219ab540356cbb839cbe05303d7705fa",
|
||||
pubkeybytes.to_string()
|
||||
);
|
||||
file.write_all(contents.as_bytes())
|
||||
.expect("Unable to write to file");
|
||||
CommandLineTest::new()
|
||||
.flag(
|
||||
"suggested-fee-recipient-file",
|
||||
dir.path().join("fee_recipient.txt").as_os_str().to_str(),
|
||||
)
|
||||
.run()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config
|
||||
.fee_recipient_file
|
||||
.clone()
|
||||
.unwrap()
|
||||
.load_fee_recipient(&pubkeybytes)
|
||||
.unwrap(),
|
||||
Some(Address::from_str("0x00000000219ab540356cbb839cbe05303d7705fa").unwrap())
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
// Tests for HTTP flags.
|
||||
#[test]
|
||||
@@ -426,9 +366,14 @@ fn metrics_allow_origin_all_flag() {
|
||||
pub fn malloc_tuning_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("disable-malloc-tuning", None)
|
||||
// Simply ensure that the node can start with this flag, it's very difficult to observe the
|
||||
// effects of it.
|
||||
.run();
|
||||
.run()
|
||||
.with_config(|config| assert_eq!(config.http_metrics.allocator_metrics_enabled, false));
|
||||
}
|
||||
#[test]
|
||||
pub fn malloc_tuning_default() {
|
||||
CommandLineTest::new()
|
||||
.run()
|
||||
.with_config(|config| assert_eq!(config.http_metrics.allocator_metrics_enabled, true));
|
||||
}
|
||||
#[test]
|
||||
fn doppelganger_protection_flag() {
|
||||
@@ -443,3 +388,57 @@ fn no_doppelganger_protection_flag() {
|
||||
.run()
|
||||
.with_config(|config| assert!(!config.enable_doppelganger_protection));
|
||||
}
|
||||
#[test]
|
||||
fn no_gas_limit_flag() {
|
||||
CommandLineTest::new()
|
||||
.run()
|
||||
.with_config(|config| assert!(config.gas_limit.is_none()));
|
||||
}
|
||||
#[test]
|
||||
fn gas_limit_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("gas-limit", Some("600"))
|
||||
.flag("builder-proposals", None)
|
||||
.run()
|
||||
.with_config(|config| assert_eq!(config.gas_limit, Some(600)));
|
||||
}
|
||||
#[test]
|
||||
fn no_builder_proposals_flag() {
|
||||
CommandLineTest::new()
|
||||
.run()
|
||||
.with_config(|config| assert!(!config.builder_proposals));
|
||||
}
|
||||
#[test]
|
||||
fn builder_proposals_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("builder-proposals", None)
|
||||
.run()
|
||||
.with_config(|config| assert!(config.builder_proposals));
|
||||
}
|
||||
#[test]
|
||||
fn no_builder_registration_timestamp_override_flag() {
|
||||
CommandLineTest::new()
|
||||
.run()
|
||||
.with_config(|config| assert!(config.builder_registration_timestamp_override.is_none()));
|
||||
}
|
||||
#[test]
|
||||
fn builder_registration_timestamp_override_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("builder-registration-timestamp-override", Some("100"))
|
||||
.run()
|
||||
.with_config(|config| {
|
||||
assert_eq!(config.builder_registration_timestamp_override, Some(100))
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn monitoring_endpoint() {
|
||||
CommandLineTest::new()
|
||||
.flag("monitoring-endpoint", Some("http://example:8000"))
|
||||
.flag("monitoring-endpoint-period", Some("30"))
|
||||
.run()
|
||||
.with_config(|config| {
|
||||
let api_conf = config.monitoring_api.as_ref().unwrap();
|
||||
assert_eq!(api_conf.monitoring_endpoint.as_str(), "http://example:8000");
|
||||
assert_eq!(api_conf.update_period_secs, Some(30));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user