diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 4629d8d13..2a1da6e4a 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3015,17 +3015,23 @@ impl BeaconChain { ops.push(StoreOp::PutBlock(block_root, signed_block.clone())); ops.push(StoreOp::PutState(block.state_root(), &state)); - // Only store blobs at the data availability boundary or younger. - // - // todo(emhane): Should we add a marginal of one epoch here to ensure data availability - // consistency across network at epoch boundaries? - let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch()); - if Some(block_epoch) >= self.data_availability_boundary() { - if let Some(blobs) = blobs? { - if blobs.blobs.len() > 0 { - //FIXME(sean) using this for debugging for now - info!(self.log, "Writing blobs to store"; "block_root" => ?block_root); - ops.push(StoreOp::PutBlobs(block_root, blobs)); + // Only consider blobs if the eip4844 fork is enabled. + if let Some(data_availability_boundary) = self.data_availability_boundary() { + let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch()); + let import_boundary = match self.store.get_config().blob_prune_margin_epochs { + Some(margin_epochs) => data_availability_boundary - margin_epochs, + None => data_availability_boundary, + }; + + // Only store blobs at the data availability boundary, minus any configured epochs + // margin, or younger (of higher epoch number). + if block_epoch >= import_boundary { + if let Some(blobs) = blobs? { + if blobs.blobs.len() > 0 { + //FIXME(sean) using this for debugging for now + info!(self.log, "Writing blobs to store"; "block_root" => ?block_root); + ops.push(StoreOp::PutBlobs(block_root, blobs)); + } } } } diff --git a/beacon_node/client/src/config.rs b/beacon_node/client/src/config.rs index 5f79d290a..6c3a98a46 100644 --- a/beacon_node/client/src/config.rs +++ b/beacon_node/client/src/config.rs @@ -201,10 +201,6 @@ impl Config { pub fn create_data_dir(&self) -> Result { ensure_dir_exists(self.get_data_dir()) } - - pub fn get_blob_prune_margin_epochs(&self) -> Option { - self.store.blob_prune_margin_epochs - } } /// Ensure that the directory at `path` exists, by creating it and all parents if necessary.