Skip to content

Only reconstruct column at most once per block #5794

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 15, 2024
Merged
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 @@ -65,6 +65,7 @@ pub struct PendingComponents<E: EthSpec> {
pub verified_blobs: FixedVector<Option<KzgVerifiedBlob<E>>, E::MaxBlobsPerBlock>,
pub verified_data_columns: VariableList<KzgVerifiedCustodyDataColumn<E>, E::NumberOfColumns>,
pub executed_block: Option<DietAvailabilityPendingExecutedBlock<E>>,
pub reconstruction_started: bool,
}

pub enum BlockImportRequirement {
Expand Down Expand Up @@ -278,6 +279,7 @@ impl<E: EthSpec> PendingComponents<E> {
verified_blobs: FixedVector::default(),
verified_data_columns: VariableList::default(),
executed_block: None,
reconstruction_started: false,
}
}

Expand All @@ -302,6 +304,7 @@ impl<E: EthSpec> PendingComponents<E> {
verified_blobs,
verified_data_columns,
executed_block,
..
} = self;

let blobs_available_timestamp = verified_blobs
Expand Down Expand Up @@ -360,6 +363,10 @@ impl<E: EthSpec> PendingComponents<E> {
)))
}

pub fn reconstruction_started(&mut self) {
self.reconstruction_started = true;
}

/// Returns the epoch of the block if it is cached, otherwise returns the epoch of the first blob.
pub fn epoch(&self) -> Option<Epoch> {
self.executed_block
Expand Down Expand Up @@ -838,6 +845,8 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
// - We >= 50% of columns
let data_columns_to_publish =
if self.should_reconstruct(&block_import_requirement, &pending_components) {
pending_components.reconstruction_started();

let timer = metrics::start_timer(&metrics::DATA_AVAILABILITY_RECONSTRUCTION_TIME);

let existing_column_indices = pending_components
Expand Down Expand Up @@ -908,7 +917,8 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
return false;
};

*num_expected_columns == T::EthSpec::number_of_columns()
!pending_components.reconstruction_started
&& *num_expected_columns == T::EthSpec::number_of_columns()
&& pending_components.verified_data_columns.len() >= T::EthSpec::number_of_columns() / 2
}

Expand Down
Loading