Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update is_available condition #19

Open
wants to merge 2 commits into
base: data-cols-by-root
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ pub trait AvailabilityView<E: EthSpec> {
&mut self,
) -> &mut FixedVector<Option<Self::DataColumnType>, E::DataColumnCount>;

/// EIP-7594 config param to consider a block available if at least `samples_per_slot` are
/// available
fn samples_per_slot(&self) -> usize;

/// Checks if a block exists in the cache.
///
/// Returns:
Expand Down Expand Up @@ -102,6 +106,11 @@ pub trait AvailabilityView<E: EthSpec> {
self.get_cached_blobs().iter().flatten().count()
}

/// Returns the number of blobs that have been received and are stored in the cache.
fn num_received_columns(&self) -> usize {
self.get_cached_data_columns().iter().flatten().count()
}

/// Inserts a block into the cache.
fn insert_block(&mut self, block: Self::BlockType) {
*self.get_cached_block_mut() = Some(block)
Expand Down Expand Up @@ -198,7 +207,9 @@ pub trait AvailabilityView<E: EthSpec> {
/// of expected blobs.
fn is_available(&self) -> bool {
if let Some(num_expected_blobs) = self.num_expected_blobs() {
// Note: the first equality covers the case of no columns to sample post EIP-7594

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean "pre" EIP-7594?

num_expected_blobs == self.num_received_blobs()
|| self.num_received_columns() >= self.samples_per_slot()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the get_cached_data_columns currently stores the gossip verified data columns, so it's really the custody_columns rather than the sample columns.

} else {
false
}
Expand Down Expand Up @@ -252,6 +263,11 @@ macro_rules! impl_availability_view {
) -> &mut FixedVector<Option<Self::DataColumnType>, E::DataColumnCount> {
&mut self.$data_column_field
}

fn samples_per_slot(&self) -> usize {
// TODO(das): make it a config param
16
}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl<T: EthSpec> PendingComponents<T> {
return Err(AvailabilityCheckError::Unexpected);
};
let num_blobs_expected = diet_executed_block.num_blobs_expected();
// TODO(das): blobs may be empty post PeerDAS but the blob can have commitments
let Some(verified_blobs) = verified_blobs
.into_iter()
.cloned()
Expand Down Expand Up @@ -573,10 +574,20 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
// Merge in the data columns.
pending_components.merge_data_columns(fixed_data_columns);

write_lock.put_pending_components(block_root, pending_components, &self.overflow_store)?;

// TODO(das): Currently this does not change availability status and nor import yet.
Ok(Availability::MissingComponents(block_root))
if pending_components.is_available() {
// No need to hold the write lock anymore
drop(write_lock);
pending_components.make_available(|diet_block| {
self.state_cache.recover_pending_executed_block(diet_block)
})
} else {
write_lock.put_pending_components(
block_root,
pending_components,
&self.overflow_store,
)?;
Ok(Availability::MissingComponents(block_root))
}
}

pub fn put_kzg_verified_blobs<I: IntoIterator<Item = KzgVerifiedBlob<T::EthSpec>>>(
Expand Down
Loading