diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 59d29298a7..ab0bcb7414 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3029,7 +3029,7 @@ impl BeaconChain { blob_info.last_pruned_epoch + *MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS; if current_epoch > next_epoch_to_prune { - blob_info.data_availability_breakpoint = block_root; + blob_info.data_availability_breakpoint = Some(block_root); self.store.compare_and_set_blob_info_with_write( self.store.get_blob_info(), Some(blob_info), diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 5106505798..ad4aa3233c 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -213,7 +213,7 @@ impl HotColdDB, LevelDB> { } if db.spec.eip4844_fork_epoch.is_some() { - *db.blob_info.write() = db.load_blob_info()?; + *db.blob_info.write() = db.load_blob_info()?.or(Some(BlobInfo::default())); } // Ensure that the schema version of the on-disk database matches the software. @@ -1700,18 +1700,25 @@ impl, Cold: ItemStore> HotColdDB return Ok(()); } - if blob_info.data_availability_breakpoint == blob_info.oldest_blob_parent { + let data_availability_breakpoint: Hash256; + + if let Some(breakpoint) = blob_info.data_availability_breakpoint { + if breakpoint == blob_info.oldest_blob_parent { + return Ok(()); + } + data_availability_breakpoint = breakpoint; + } else { return Ok(()); } // Load the state from which to prune blobs so we can backtrack. let erase_state = self .get_state( - &blob_info.data_availability_breakpoint, + &data_availability_breakpoint, Some(blob_info.last_pruned_epoch.end_slot(E::slots_per_epoch())), )? .ok_or(HotColdDBError::MissingStateToPruneBlobs( - blob_info.data_availability_breakpoint, + data_availability_breakpoint, blob_info.oldest_blob_slot, ))?; @@ -1808,7 +1815,7 @@ impl, Cold: ItemStore> HotColdDB ); blob_info.last_pruned_epoch = erase_epoch; - blob_info.oldest_blob_parent = blob_info.data_availability_breakpoint; + blob_info.oldest_blob_parent = data_availability_breakpoint; self.compare_and_set_blob_info_with_write(self.get_blob_info(), Some(blob_info))?; Ok(()) diff --git a/beacon_node/store/src/metadata.rs b/beacon_node/store/src/metadata.rs index 803b75b983..3757940c21 100644 --- a/beacon_node/store/src/metadata.rs +++ b/beacon_node/store/src/metadata.rs @@ -120,12 +120,12 @@ impl StoreItem for AnchorInfo { } /// Database parameters relevant to blob sync. -#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode, Serialize, Deserialize, Default)] pub struct BlobInfo { /// The latest epoch that blobs were pruned. pub last_pruned_epoch: Epoch, /// The block root of the next blobs to prune from. - pub data_availability_breakpoint: Hash256, + pub data_availability_breakpoint: Option, /// The block root of the next blob that needs to be added to fill in the history. pub oldest_blob_parent: Hash256, /// The slot before which blobs are available.