diff --git a/beacon_node/beacon_chain/src/builder.rs b/beacon_node/beacon_chain/src/builder.rs index 62df1eb1fb..45375ec01e 100644 --- a/beacon_node/beacon_chain/src/builder.rs +++ b/beacon_node/beacon_chain/src/builder.rs @@ -267,9 +267,11 @@ where self.genesis_time = Some(genesis_state.genesis_time()); // Prune finalized execution payloads. - store - .try_prune_execution_payloads(false) - .map_err(|e| format!("Error pruning execution payloads: {e:?}"))?; + if store.get_config().prune_payloads_on_init { + store + .try_prune_execution_payloads(false) + .map_err(|e| format!("Error pruning execution payloads: {e:?}"))?; + } self.op_pool = Some( store diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 3c421a1a3f..d9d5c715b4 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -515,6 +515,13 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .takes_value(true) .default_value("true") ) + .arg( + Arg::with_name("prune-payloads-on-startup") + .long("prune-payloads-on-startup") + .help("Check for execution payloads to prune on start-up.") + .takes_value(true) + .default_value("true") + ) /* * Misc. diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index b57ba02687..368fce573d 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -358,6 +358,12 @@ pub fn get_config( .map_err(|_| "auto-compact-db takes a boolean".to_string())?; } + if let Some(prune_payloads_on_init) = + clap_utils::parse_optional(cli_args, "prune-payloads-on-startup")? + { + client_config.store.prune_payloads_on_init = prune_payloads_on_init; + } + /* * Zero-ports * diff --git a/beacon_node/store/src/config.rs b/beacon_node/store/src/config.rs index 4268ec2e91..9bc9ee8a45 100644 --- a/beacon_node/store/src/config.rs +++ b/beacon_node/store/src/config.rs @@ -21,6 +21,8 @@ pub struct StoreConfig { pub compact_on_init: bool, /// Whether to compact the database during database pruning. pub compact_on_prune: bool, + /// Whether to try pruning execution payloads on initialization. + pub prune_payloads_on_init: bool, } /// Variant of `StoreConfig` that gets written to disk. Contains immutable configuration params. @@ -43,6 +45,7 @@ impl Default for StoreConfig { block_cache_size: DEFAULT_BLOCK_CACHE_SIZE, compact_on_init: false, compact_on_prune: true, + prune_payloads_on_init: true, } } } diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index b28c1a0c3e..aed8ebf394 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -1227,6 +1227,19 @@ fn compact_db_flag() { .with_config(|config| assert!(config.store.compact_on_init)); } #[test] +fn prune_payloads_on_startup_default() { + CommandLineTest::new() + .run_with_zero_port() + .with_config(|config| assert!(config.store.prune_payloads_on_init)); +} +#[test] +fn prune_payloads_on_startup_false() { + CommandLineTest::new() + .flag("prune-payloads-on-startup", Some("false")) + .run_with_zero_port() + .with_config(|config| assert!(!config.store.prune_payloads_on_init)); +} +#[test] fn reconstruct_historic_states_flag() { CommandLineTest::new() .flag("reconstruct-historic-states", None)