fixup! Allow user to set an epoch margin for pruning
This commit is contained in:
parent
a2eda76291
commit
8f137df02e
@ -3018,10 +3018,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
// Only consider blobs if the eip4844 fork is enabled.
|
// Only consider blobs if the eip4844 fork is enabled.
|
||||||
if let Some(data_availability_boundary) = self.data_availability_boundary() {
|
if let Some(data_availability_boundary) = self.data_availability_boundary() {
|
||||||
let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
|
let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
|
||||||
let import_boundary = match self.store.get_config().blob_prune_margin_epochs {
|
let margin_epochs = self.store.get_config().blob_prune_margin_epochs;
|
||||||
Some(margin_epochs) => data_availability_boundary - margin_epochs,
|
let import_boundary = data_availability_boundary - margin_epochs;
|
||||||
None => data_availability_boundary,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Only store blobs at the data availability boundary, minus any configured epochs
|
// Only store blobs at the data availability boundary, minus any configured epochs
|
||||||
// margin, or younger (of higher epoch number).
|
// margin, or younger (of higher epoch number).
|
||||||
|
@ -424,9 +424,7 @@ pub fn get_config<E: EthSpec>(
|
|||||||
if let Some(blob_prune_margin_epochs) =
|
if let Some(blob_prune_margin_epochs) =
|
||||||
clap_utils::parse_optional(cli_args, "blob-prune-margin-epochs")?
|
clap_utils::parse_optional(cli_args, "blob-prune-margin-epochs")?
|
||||||
{
|
{
|
||||||
if blob_prune_margin_epochs > 0 {
|
client_config.store.blob_prune_margin_epochs = blob_prune_margin_epochs;
|
||||||
client_config.store.blob_prune_margin_epochs = Some(blob_prune_margin_epochs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -9,7 +9,7 @@ pub const DEFAULT_SLOTS_PER_RESTORE_POINT: u64 = 8192;
|
|||||||
pub const DEFAULT_BLOCK_CACHE_SIZE: usize = 5;
|
pub const DEFAULT_BLOCK_CACHE_SIZE: usize = 5;
|
||||||
pub const DEFAULT_BLOB_CACHE_SIZE: usize = 5;
|
pub const DEFAULT_BLOB_CACHE_SIZE: usize = 5;
|
||||||
pub const DEFAULT_EPOCHS_PER_BLOB_PRUNE: u64 = 1;
|
pub const DEFAULT_EPOCHS_PER_BLOB_PRUNE: u64 = 1;
|
||||||
pub const DEFAULT_BLOB_PUNE_MARGIN_EPOCHS: Option<u64> = None;
|
pub const DEFAULT_BLOB_PUNE_MARGIN_EPOCHS: u64 = 0;
|
||||||
|
|
||||||
/// Database configuration parameters.
|
/// Database configuration parameters.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
@ -34,7 +34,7 @@ pub struct StoreConfig {
|
|||||||
pub epochs_per_blob_prune: u64,
|
pub epochs_per_blob_prune: u64,
|
||||||
/// The margin for blob pruning in epochs. The oldest blobs are pruned up until
|
/// The margin for blob pruning in epochs. The oldest blobs are pruned up until
|
||||||
/// data_availability_boundary - blob_prune_margin_epochs. Default: 0.
|
/// data_availability_boundary - blob_prune_margin_epochs. Default: 0.
|
||||||
pub blob_prune_margin_epochs: Option<u64>,
|
pub blob_prune_margin_epochs: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Variant of `StoreConfig` that gets written to disk. Contains immutable configuration params.
|
/// Variant of `StoreConfig` that gets written to disk. Contains immutable configuration params.
|
||||||
|
@ -1779,18 +1779,12 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
// middle of an epoch otherwise the oldest blob slot is a start slot.
|
// middle of an epoch otherwise the oldest blob slot is a start slot.
|
||||||
let last_pruned_epoch = oldest_blob_slot.epoch(E::slots_per_epoch()) - 1;
|
let last_pruned_epoch = oldest_blob_slot.epoch(E::slots_per_epoch()) - 1;
|
||||||
|
|
||||||
// At most prune up until the data availability boundary epoch, leaving at least blobs in
|
// At most prune blobs up until the data availability boundary epoch, leaving at least
|
||||||
// the data availability boundary epoch and younger.
|
// blobs of the data availability boundary epoch and younger.
|
||||||
let end_epoch = {
|
let earliest_prunable_epoch = data_availability_boundary - 1;
|
||||||
let earliest_prunable_epoch = data_availability_boundary - 1;
|
// Stop pruning before reaching the data availability boundary if a margin is configured.
|
||||||
// Stop pruning before reaching the data availability boundary if a margin is
|
let margin_epochs = self.get_config().blob_prune_margin_epochs;
|
||||||
// configured.
|
let end_epoch = earliest_prunable_epoch - margin_epochs;
|
||||||
if let Some(margin) = self.get_config().blob_prune_margin_epochs {
|
|
||||||
earliest_prunable_epoch - margin
|
|
||||||
} else {
|
|
||||||
earliest_prunable_epoch
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if !force {
|
if !force {
|
||||||
if last_pruned_epoch.as_u64() + self.get_config().epochs_per_blob_prune
|
if last_pruned_epoch.as_u64() + self.get_config().epochs_per_blob_prune
|
||||||
|
@ -130,9 +130,7 @@ fn parse_client_config<E: EthSpec>(
|
|||||||
if let Some(blob_prune_margin_epochs) =
|
if let Some(blob_prune_margin_epochs) =
|
||||||
clap_utils::parse_optional(cli_args, "blob-prune-margin-epochs")?
|
clap_utils::parse_optional(cli_args, "blob-prune-margin-epochs")?
|
||||||
{
|
{
|
||||||
if blob_prune_margin_epochs > 0 {
|
client_config.store.blob_prune_margin_epochs = blob_prune_margin_epochs;
|
||||||
client_config.store.blob_prune_margin_epochs = Some(blob_prune_margin_epochs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(client_config)
|
Ok(client_config)
|
||||||
|
@ -1370,7 +1370,7 @@ fn epochs_per_blob_prune_on_startup_five() {
|
|||||||
fn blob_prune_margin_epochs_default() {
|
fn blob_prune_margin_epochs_default() {
|
||||||
CommandLineTest::new()
|
CommandLineTest::new()
|
||||||
.run_with_zero_port()
|
.run_with_zero_port()
|
||||||
.with_config(|config| assert!(config.blob_prune_margin_epochs.is_none()));
|
.with_config(|config| assert!(config.blob_prune_margin_epochs == 0));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn blob_prune_margin_epochs_on_startup_ten() {
|
fn blob_prune_margin_epochs_on_startup_ten() {
|
||||||
|
Loading…
Reference in New Issue
Block a user