diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index da48f0be9b..f77aa89810 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -566,6 +566,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .default_value("4") .takes_value(true) ) + .arg( + Arg::with_name("epochs-per-state-diff") + .long("epochs-per-state-diff") + .value_name("EPOCHS") + .help("Number of epochs between state diffs stored in the database. Lower values \ + result in more writes and more data stored, while higher values result in \ + more block replaying and longer load times in case of cache miss.") + .default_value("4") + .takes_value(true) + ) /* * Misc. */ diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index e1e09d88ac..63cae17091 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -403,6 +403,12 @@ pub fn get_config( client_config.store_migrator.epochs_per_run = epochs_per_migration; } + if let Some(epochs_per_state_diff) = + clap_utils::parse_optional(cli_args, "epochs-per-state-diff")? + { + client_config.store.epochs_per_state_diff = epochs_per_state_diff; + } + /* * Zero-ports * diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index 76ffc9ecc3..51c9708c1f 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -1371,6 +1371,24 @@ fn db_migration_period_override() { .run_with_zero_port() .with_config(|config| assert_eq!(config.store_migrator.epochs_per_run, 128)); } +#[test] +fn epochs_per_state_diff_default() { + CommandLineTest::new() + .run_with_zero_port() + .with_config(|config| { + assert_eq!( + config.store.epochs_per_state_diff, + beacon_node::beacon_chain::store::config::DEFAULT_EPOCHS_PER_STATE_DIFF + ) + }); +} +#[test] +fn epochs_per_state_diff_override() { + CommandLineTest::new() + .flag("epochs-per-state-diff", Some("1")) + .run_with_zero_port() + .with_config(|config| assert_eq!(config.store.epochs_per_state_diff, 1)); +} // Tests for Slasher flags. #[test]