mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Merged with unstable
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lighthouse"
|
||||
version = "3.2.1"
|
||||
version = "3.3.0"
|
||||
authors = ["Sigma Prime <contact@sigmaprime.io>"]
|
||||
edition = "2021"
|
||||
autotests = false
|
||||
|
||||
@@ -55,6 +55,7 @@ pub struct LoggerConfig {
|
||||
pub max_log_size: u64,
|
||||
pub max_log_number: usize,
|
||||
pub compression: bool,
|
||||
pub is_restricted: bool,
|
||||
}
|
||||
impl Default for LoggerConfig {
|
||||
fn default() -> Self {
|
||||
@@ -68,6 +69,7 @@ impl Default for LoggerConfig {
|
||||
max_log_size: 200,
|
||||
max_log_number: 5,
|
||||
compression: false,
|
||||
is_restricted: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,7 +259,7 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
|
||||
.rotate_size(config.max_log_size)
|
||||
.rotate_keep(config.max_log_number)
|
||||
.rotate_compress(config.compression)
|
||||
.restrict_permissions(true)
|
||||
.restrict_permissions(config.is_restricted)
|
||||
.build()
|
||||
.map_err(|e| format!("Unable to build file logger: {}", e))?;
|
||||
|
||||
@@ -380,7 +382,7 @@ impl<E: EthSpec> Environment<E> {
|
||||
}
|
||||
|
||||
/// Returns a `Context` where no "service" has been added to the logger output.
|
||||
pub fn core_context(&mut self) -> RuntimeContext<E> {
|
||||
pub fn core_context(&self) -> RuntimeContext<E> {
|
||||
RuntimeContext {
|
||||
executor: TaskExecutor::new(
|
||||
Arc::downgrade(self.runtime()),
|
||||
@@ -395,7 +397,7 @@ impl<E: EthSpec> Environment<E> {
|
||||
}
|
||||
|
||||
/// Returns a `Context` where the `service_name` is added to the logger output.
|
||||
pub fn service_context(&mut self, service_name: String) -> RuntimeContext<E> {
|
||||
pub fn service_context(&self, service_name: String) -> RuntimeContext<E> {
|
||||
RuntimeContext {
|
||||
executor: TaskExecutor::new(
|
||||
Arc::downgrade(self.runtime()),
|
||||
|
||||
@@ -129,6 +129,15 @@ fn main() {
|
||||
to store old logs.")
|
||||
.global(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("logfile-no-restricted-perms")
|
||||
.long("logfile-no-restricted-perms")
|
||||
.help(
|
||||
"If present, log files will be generated as world-readable meaning they can be read by \
|
||||
any user on the machine. Note that logs can often contain sensitive information \
|
||||
about your validator and so this flag should be used with caution.")
|
||||
.global(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("log-format")
|
||||
.long("log-format")
|
||||
@@ -407,6 +416,8 @@ fn run<E: EthSpec>(
|
||||
|
||||
let logfile_compress = matches.is_present("logfile-compress");
|
||||
|
||||
let logfile_restricted = !matches.is_present("logfile-no-restricted-perms");
|
||||
|
||||
// Construct the path to the log file.
|
||||
let mut log_path: Option<PathBuf> = clap_utils::parse_optional(matches, "logfile")?;
|
||||
if log_path.is_none() {
|
||||
@@ -446,6 +457,7 @@ fn run<E: EthSpec>(
|
||||
max_log_size: logfile_max_size * 1_024 * 1_024,
|
||||
max_log_number: logfile_max_number,
|
||||
compression: logfile_compress,
|
||||
is_restricted: logfile_restricted,
|
||||
};
|
||||
|
||||
let builder = environment_builder.initialize_logger(logger_config.clone())?;
|
||||
|
||||
@@ -56,7 +56,9 @@ impl CommandLineTestExec for CommandLineTest {
|
||||
fn datadir_flag() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config_and_dir(|config, dir| assert_eq!(config.data_dir, dir.path().join("beacon")));
|
||||
.with_config_and_dir(|config, dir| {
|
||||
assert_eq!(*config.data_dir(), dir.path().join("beacon"))
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -132,6 +134,25 @@ fn fork_choice_before_proposal_timeout_zero() {
|
||||
.with_config(|config| assert_eq!(config.chain.fork_choice_before_proposal_timeout_ms, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checkpoint_sync_url_timeout_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("checkpoint-sync-url-timeout", Some("300"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(config.chain.checkpoint_sync_url_timeout, 300);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checkpoint_sync_url_timeout_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(config.chain.checkpoint_sync_url_timeout, 60);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paranoid_block_proposal_default() {
|
||||
CommandLineTest::new()
|
||||
@@ -1527,6 +1548,23 @@ fn enabled_disable_log_timestamp_flag() {
|
||||
assert!(config.logger_config.disable_log_timestamp);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn logfile_restricted_perms_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert!(config.logger_config.is_restricted);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn logfile_no_restricted_perms_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("logfile-no-restricted-perms", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert!(config.logger_config.is_restricted == false);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sync_eth1_chain_default() {
|
||||
@@ -1561,3 +1599,29 @@ fn sync_eth1_chain_disable_deposit_contract_sync_flag() {
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert_eq!(config.sync_eth1_chain, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn light_client_server_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert_eq!(config.network.enable_light_client_server, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn light_client_server_enabled() {
|
||||
CommandLineTest::new()
|
||||
.flag("light-client-server", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert_eq!(config.network.enable_light_client_server, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gui_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("gui", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert!(config.http_api.enabled);
|
||||
assert!(config.validator_monitor_auto);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user