Skip to content

Commit b28e8d0

Browse files
committed
Add flag to disable prune on startup
1 parent de775d6 commit b28e8d0

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

beacon_node/beacon_chain/src/builder.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ where
267267
self.genesis_time = Some(genesis_state.genesis_time());
268268

269269
// Prune finalized execution payloads.
270-
store
271-
.try_prune_execution_payloads(false)
272-
.map_err(|e| format!("Error pruning execution payloads: {e:?}"))?;
270+
if store.get_config().prune_payloads_on_init {
271+
store
272+
.try_prune_execution_payloads(false)
273+
.map_err(|e| format!("Error pruning execution payloads: {e:?}"))?;
274+
}
273275

274276
self.op_pool = Some(
275277
store

beacon_node/src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,13 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
515515
.takes_value(true)
516516
.default_value("true")
517517
)
518+
.arg(
519+
Arg::with_name("prune-payloads-on-startup")
520+
.long("prune-payloads-on-startup")
521+
.help("Check for execution payloads to prune on start-up.")
522+
.takes_value(true)
523+
.default_value("true")
524+
)
518525

519526
/*
520527
* Misc.

beacon_node/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ pub fn get_config<E: EthSpec>(
358358
.map_err(|_| "auto-compact-db takes a boolean".to_string())?;
359359
}
360360

361+
if let Some(prune_payloads_on_init) =
362+
clap_utils::parse_optional(cli_args, "prune-payloads-on-startup")?
363+
{
364+
client_config.store.prune_payloads_on_init = prune_payloads_on_init;
365+
}
366+
361367
/*
362368
* Zero-ports
363369
*

beacon_node/store/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub struct StoreConfig {
2121
pub compact_on_init: bool,
2222
/// Whether to compact the database during database pruning.
2323
pub compact_on_prune: bool,
24+
/// Whether to try pruning execution payloads on initialization.
25+
pub prune_payloads_on_init: bool,
2426
}
2527

2628
/// Variant of `StoreConfig` that gets written to disk. Contains immutable configuration params.
@@ -43,6 +45,7 @@ impl Default for StoreConfig {
4345
block_cache_size: DEFAULT_BLOCK_CACHE_SIZE,
4446
compact_on_init: false,
4547
compact_on_prune: true,
48+
prune_payloads_on_init: true,
4649
}
4750
}
4851
}

lighthouse/tests/beacon_node.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,19 @@ fn compact_db_flag() {
12271227
.with_config(|config| assert!(config.store.compact_on_init));
12281228
}
12291229
#[test]
1230+
fn prune_payloads_on_startup_default() {
1231+
CommandLineTest::new()
1232+
.run_with_zero_port()
1233+
.with_config(|config| assert!(config.store.prune_payloads_on_init));
1234+
}
1235+
#[test]
1236+
fn prune_payloads_on_startup_false() {
1237+
CommandLineTest::new()
1238+
.flag("prune-payloads-on-startup", Some("false"))
1239+
.run_with_zero_port()
1240+
.with_config(|config| assert!(!config.store.prune_payloads_on_init));
1241+
}
1242+
#[test]
12301243
fn reconstruct_historic_states_flag() {
12311244
CommandLineTest::new()
12321245
.flag("reconstruct-historic-states", None)

0 commit comments

Comments
 (0)