Update is_available check to support PeerDAS. (#6076)

* Update `is_available` check to support PeerDAS.

* Merge branch 'unstable' into da-checker-das

# Conflicts:
#	beacon_node/beacon_chain/src/data_availability_checker.rs
#	beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

* Simplify code using `map_or`

* Merge branch 'unstable' into da-checker-das

# Conflicts:
#	consensus/types/src/chain_spec.rs

* Remove `epoch` method from `PendingComponents`

* Add `put_kzg_verified_data_columns` method.
This commit is contained in:
Jimmy Chen
2024-07-22 23:23:21 +10:00
committed by GitHub
parent 06dff60992
commit bca732e19d
8 changed files with 195 additions and 23 deletions

View File

@@ -94,8 +94,17 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
log: &Logger,
spec: ChainSpec,
) -> Result<Self, AvailabilityCheckError> {
let overflow_cache =
DataAvailabilityCheckerInner::new(OVERFLOW_LRU_CAPACITY, store, spec.clone())?;
// TODO(das): support supernode or custom custody requirement
let custody_subnet_count = spec.custody_requirement as usize;
let custody_column_count =
custody_subnet_count.saturating_mul(spec.data_columns_per_subnet());
let overflow_cache = DataAvailabilityCheckerInner::new(
OVERFLOW_LRU_CAPACITY,
store,
custody_column_count,
spec.clone(),
)?;
Ok(Self {
availability_cache: Arc::new(overflow_cache),
slot_clock,
@@ -143,6 +152,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
pub fn put_rpc_blobs(
&self,
block_root: Hash256,
epoch: Epoch,
blobs: FixedBlobSidecarList<T::EthSpec>,
) -> Result<Availability<T::EthSpec>, AvailabilityCheckError> {
let Some(kzg) = self.kzg.as_ref() else {
@@ -159,7 +169,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
.map_err(AvailabilityCheckError::Kzg)?;
self.availability_cache
.put_kzg_verified_blobs(block_root, verified_blobs)
.put_kzg_verified_blobs(block_root, epoch, verified_blobs)
}
/// Check if we've cached other blobs for this block. If it completes a set and we also
@@ -171,8 +181,11 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
&self,
gossip_blob: GossipVerifiedBlob<T>,
) -> Result<Availability<T::EthSpec>, AvailabilityCheckError> {
self.availability_cache
.put_kzg_verified_blobs(gossip_blob.block_root(), vec![gossip_blob.into_inner()])
self.availability_cache.put_kzg_verified_blobs(
gossip_blob.block_root(),
gossip_blob.epoch(),
vec![gossip_blob.into_inner()],
)
}
/// Check if we have all the blobs for a block. Returns `Availability` which has information