Modularize CGC logic in network service

This commit is contained in:
dapplion
2025-04-10 18:47:54 -03:00
parent 1c7d47052f
commit 630c79d110
7 changed files with 336 additions and 138 deletions

View File

@@ -19,7 +19,7 @@ use tracing::{debug, error, info_span, Instrument};
use types::blob_sidecar::{BlobIdentifier, BlobSidecar, FixedBlobSidecarList};
use types::{
BlobSidecarList, ChainSpec, DataColumnIdentifier, DataColumnSidecar, DataColumnSidecarList,
Epoch, EthSpec, Hash256, RuntimeVariableList, SignedBeaconBlock,
Epoch, EthSpec, ForkName, Hash256, RuntimeVariableList, SignedBeaconBlock,
};
mod error;
@@ -495,10 +495,23 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
fork_epoch,
current_slot
.epoch(T::EthSpec::slots_per_epoch())
// TODO(das): use min_epochs_for_data_columns
.saturating_sub(self.spec.min_epochs_for_blob_sidecars_requests),
))
}
pub fn oldest_epoch_with_data_columns(&self) -> Option<Epoch> {
let fulu_fork_epoch = self.spec.fork_epoch(ForkName::Fulu)?;
if fulu_fork_epoch == Epoch::max_value() {
return None;
}
let current_epoch = self.slot_clock.now()?.epoch(T::EthSpec::slots_per_epoch());
Some(std::cmp::max(
fulu_fork_epoch,
current_epoch.saturating_sub(self.spec.min_epochs_for_blob_sidecars_requests),
))
}
/// Returns true if the given epoch lies within the da boundary and false otherwise.
pub fn da_check_required_for_epoch(&self, block_epoch: Epoch) -> bool {
self.data_availability_boundary()