Configurable epochs-per-state-diff

This commit is contained in:
Michael Sproul
2023-01-31 10:04:12 +11:00
parent 90797a1b04
commit c64d7a48d6
3 changed files with 34 additions and 0 deletions

View File

@@ -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.
*/

View File

@@ -403,6 +403,12 @@ pub fn get_config<E: EthSpec>(
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
*

View File

@@ -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]