Add flag to disable prune on startup

This commit is contained in:
Michael Sproul
2022-09-12 11:41:45 +10:00
parent de775d6aa5
commit b28e8d0848
5 changed files with 34 additions and 3 deletions

View File

@@ -267,9 +267,11 @@ where
self.genesis_time = Some(genesis_state.genesis_time()); self.genesis_time = Some(genesis_state.genesis_time());
// Prune finalized execution payloads. // Prune finalized execution payloads.
if store.get_config().prune_payloads_on_init {
store store
.try_prune_execution_payloads(false) .try_prune_execution_payloads(false)
.map_err(|e| format!("Error pruning execution payloads: {e:?}"))?; .map_err(|e| format!("Error pruning execution payloads: {e:?}"))?;
}
self.op_pool = Some( self.op_pool = Some(
store store

View File

@@ -515,6 +515,13 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true) .takes_value(true)
.default_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. * Misc.

View File

@@ -358,6 +358,12 @@ pub fn get_config<E: EthSpec>(
.map_err(|_| "auto-compact-db takes a boolean".to_string())?; .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 * Zero-ports
* *

View File

@@ -21,6 +21,8 @@ pub struct StoreConfig {
pub compact_on_init: bool, pub compact_on_init: bool,
/// Whether to compact the database during database pruning. /// Whether to compact the database during database pruning.
pub compact_on_prune: bool, 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. /// 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, block_cache_size: DEFAULT_BLOCK_CACHE_SIZE,
compact_on_init: false, compact_on_init: false,
compact_on_prune: true, compact_on_prune: true,
prune_payloads_on_init: true,
} }
} }
} }

View File

@@ -1227,6 +1227,19 @@ fn compact_db_flag() {
.with_config(|config| assert!(config.store.compact_on_init)); .with_config(|config| assert!(config.store.compact_on_init));
} }
#[test] #[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() { fn reconstruct_historic_states_flag() {
CommandLineTest::new() CommandLineTest::new()
.flag("reconstruct-historic-states", None) .flag("reconstruct-historic-states", None)