Plug in pruning of blobs into app
This commit is contained in:
parent
7bf88c2336
commit
fe0c911402
@ -914,6 +914,20 @@ where
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prune blobs sidecars older than the blob data availability boundary in the background.
|
||||||
|
if beacon_chain.store.get_config().prune_blobs {
|
||||||
|
let store = beacon_chain.store.clone();
|
||||||
|
let log = log.clone();
|
||||||
|
beacon_chain.task_executor.spawn_blocking(
|
||||||
|
move || {
|
||||||
|
if let Err(e) = store.try_prune_blobs(false) {
|
||||||
|
error!(log, "Error pruning blobs in background"; "error" => ?e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"prune_blobs_background",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(beacon_chain)
|
Ok(beacon_chain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ pub struct StoreConfig {
|
|||||||
pub compact_on_prune: bool,
|
pub compact_on_prune: bool,
|
||||||
/// Whether to prune payloads on initialization and finalization.
|
/// Whether to prune payloads on initialization and finalization.
|
||||||
pub prune_payloads: bool,
|
pub prune_payloads: bool,
|
||||||
|
/// Whether to prune blobs older than the blob data availability boundary.
|
||||||
|
pub prune_blobs: 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.
|
||||||
@ -50,6 +52,7 @@ impl Default for StoreConfig {
|
|||||||
compact_on_init: false,
|
compact_on_init: false,
|
||||||
compact_on_prune: true,
|
compact_on_prune: true,
|
||||||
prune_payloads: true,
|
prune_payloads: true,
|
||||||
|
prune_blobs: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,12 @@ pub fn prune_payloads_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.about("Prune finalized execution payloads")
|
.about("Prune finalized execution payloads")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn prune_blobs_app<'a, 'b>() -> App<'a, 'b> {
|
||||||
|
App::new("prune_blobs")
|
||||||
|
.setting(clap::AppSettings::ColoredHelp)
|
||||||
|
.about("Prune blobs older than data availability boundary")
|
||||||
|
}
|
||||||
|
|
||||||
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||||
App::new(CMD)
|
App::new(CMD)
|
||||||
.visible_aliases(&["db"])
|
.visible_aliases(&["db"])
|
||||||
@ -92,6 +98,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.subcommand(version_cli_app())
|
.subcommand(version_cli_app())
|
||||||
.subcommand(inspect_cli_app())
|
.subcommand(inspect_cli_app())
|
||||||
.subcommand(prune_payloads_app())
|
.subcommand(prune_payloads_app())
|
||||||
|
.subcommand(prune_blobs_app())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_client_config<E: EthSpec>(
|
fn parse_client_config<E: EthSpec>(
|
||||||
@ -287,6 +294,29 @@ pub fn prune_payloads<E: EthSpec>(
|
|||||||
db.try_prune_execution_payloads(force)
|
db.try_prune_execution_payloads(force)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn prune_blobs<E: EthSpec>(
|
||||||
|
client_config: ClientConfig,
|
||||||
|
runtime_context: &RuntimeContext<E>,
|
||||||
|
log: Logger,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let spec = &runtime_context.eth2_config.spec;
|
||||||
|
let hot_path = client_config.get_db_path();
|
||||||
|
let cold_path = client_config.get_freezer_db_path();
|
||||||
|
|
||||||
|
let db = HotColdDB::<E, LevelDB<E>, LevelDB<E>>::open(
|
||||||
|
&hot_path,
|
||||||
|
&cold_path,
|
||||||
|
|_, _, _| Ok(()),
|
||||||
|
client_config.store,
|
||||||
|
spec.clone(),
|
||||||
|
log,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// If we're trigging a prune manually then ignore the check on the split's parent that bails
|
||||||
|
// out early by passing true to the force parameter.
|
||||||
|
db.try_prune_blobs(true)
|
||||||
|
}
|
||||||
|
|
||||||
/// Run the database manager, returning an error string if the operation did not succeed.
|
/// Run the database manager, returning an error string if the operation did not succeed.
|
||||||
pub fn run<T: EthSpec>(cli_args: &ArgMatches<'_>, env: Environment<T>) -> Result<(), String> {
|
pub fn run<T: EthSpec>(cli_args: &ArgMatches<'_>, env: Environment<T>) -> Result<(), String> {
|
||||||
let client_config = parse_client_config(cli_args, &env)?;
|
let client_config = parse_client_config(cli_args, &env)?;
|
||||||
@ -304,6 +334,7 @@ pub fn run<T: EthSpec>(cli_args: &ArgMatches<'_>, env: Environment<T>) -> Result
|
|||||||
inspect_db(inspect_config, client_config, &context, log)
|
inspect_db(inspect_config, client_config, &context, log)
|
||||||
}
|
}
|
||||||
("prune_payloads", Some(_)) => prune_payloads(client_config, &context, log),
|
("prune_payloads", Some(_)) => prune_payloads(client_config, &context, log),
|
||||||
|
("prune_blobs", Some(_)) => prune_blobs(client_config, &context, log),
|
||||||
_ => {
|
_ => {
|
||||||
return Err("Unknown subcommand, for help `lighthouse database_manager --help`".into())
|
return Err("Unknown subcommand, for help `lighthouse database_manager --help`".into())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user