-
Notifications
You must be signed in to change notification settings - Fork 965
Block availability data enum #6866
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
Merged
mergify
merged 21 commits into
sigp:unstable
from
dapplion:block-availability-data-enum
Feb 24, 2025
Merged
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
59ff256
Use enum for clear block availability states
dapplion dd03585
Re-add Component added to data availability checker log
dapplion a171ab7
Complete is_available
dapplion 190622d
Fix TODOs
dapplion 637d615
Complete early attester cache impl
dapplion b060bab
Fix store tests
dapplion 5358dbb
Review PR
dapplion a59dafe
Merge remote-tracking branch 'sigp/unstable' into block-availability-…
dapplion 10bf2c4
Merge remote-tracking branch 'sigp/unstable' into block-availability-…
dapplion 134764f
Merge is_available with make_available
dapplion 8edd2e9
Deprecate clone_without_recv
dapplion 417b5e9
Stricter error conditions
dapplion f16136c
Remove timestamp from BlockAvailableData
dapplion 0283e14
no early returns
dapplion a637616
typos
dapplion 9e92d6b
extend
dapplion 7354030
rename to blob_data
dapplion 4d52ab6
Revert verify rpc blocks changes
dapplion b3263a5
Update stale comment
dapplion ca40b49
Update var name
dapplion 8c1d589
Merge remote-tracking branch 'origin/unstable' into block-availabilit…
jimmygchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,7 +348,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
| Ok(MaybeAvailableBlock::Available(AvailableBlock { | ||
| block_root, | ||
| block, | ||
| data: AvailableBlockData::Blobs(blob_list), | ||
| blob_data: AvailableBlockData::Blobs(blob_list), | ||
| blobs_available_timestamp: None, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you're just preserving existing behaviour, but it doesn't seem like we set |
||
| spec: self.spec.clone(), | ||
| })) | ||
|
|
@@ -368,7 +368,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
| Ok(MaybeAvailableBlock::Available(AvailableBlock { | ||
| block_root, | ||
| block, | ||
| data: AvailableBlockData::DataColumns( | ||
| blob_data: AvailableBlockData::DataColumns( | ||
| data_column_list | ||
| .into_iter() | ||
| .map(|d| d.clone_arc()) | ||
|
|
@@ -385,8 +385,8 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
| Ok(MaybeAvailableBlock::Available(AvailableBlock { | ||
| block_root, | ||
| block, | ||
| blob_data: AvailableBlockData::NoData, | ||
| blobs_available_timestamp: None, | ||
| data: AvailableBlockData::NoData, | ||
| spec: self.spec.clone(), | ||
| })) | ||
| } | ||
|
|
@@ -442,7 +442,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
| MaybeAvailableBlock::Available(AvailableBlock { | ||
| block_root, | ||
| block, | ||
| data: AvailableBlockData::Blobs(blobs), | ||
| blob_data: AvailableBlockData::Blobs(blobs), | ||
| blobs_available_timestamp: None, | ||
| spec: self.spec.clone(), | ||
| }) | ||
|
|
@@ -454,7 +454,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
| MaybeAvailableBlock::Available(AvailableBlock { | ||
| block_root, | ||
| block, | ||
| data: AvailableBlockData::DataColumns( | ||
| blob_data: AvailableBlockData::DataColumns( | ||
| data_columns.into_iter().map(|d| d.into_inner()).collect(), | ||
| ), | ||
| blobs_available_timestamp: None, | ||
|
|
@@ -467,7 +467,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
| MaybeAvailableBlock::Available(AvailableBlock { | ||
michaelsproul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| block_root, | ||
| block, | ||
| data: AvailableBlockData::NoData, | ||
| blob_data: AvailableBlockData::NoData, | ||
| blobs_available_timestamp: None, | ||
| spec: self.spec.clone(), | ||
| }) | ||
|
|
@@ -543,11 +543,11 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
| &self, | ||
| block_root: &Hash256, | ||
| ) -> Result<DataColumnReconstructionResult<T::EthSpec>, AvailabilityCheckError> { | ||
| let pending_components = match self | ||
| let verified_data_columns = match self | ||
| .availability_cache | ||
| .check_and_set_reconstruction_started(block_root) | ||
| { | ||
| ReconstructColumnsDecision::Yes(pending_components) => pending_components, | ||
| ReconstructColumnsDecision::Yes(verified_data_columns) => verified_data_columns, | ||
| ReconstructColumnsDecision::No(reason) => { | ||
| return Ok(DataColumnReconstructionResult::NotStarted(reason)); | ||
| } | ||
|
|
@@ -558,7 +558,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> { | |
|
|
||
| let all_data_columns = KzgVerifiedCustodyDataColumn::reconstruct_columns( | ||
| &self.kzg, | ||
| &pending_components.verified_data_columns, | ||
| &verified_data_columns, | ||
| &self.spec, | ||
| ) | ||
| .map_err(|e| { | ||
|
|
@@ -711,41 +711,16 @@ async fn availability_cache_maintenance_service<T: BeaconChainTypes>( | |
| } | ||
| } | ||
|
|
||
| fn verify_kzg_for_data_column_list_with_scoring<'a, E: EthSpec, I>( | ||
| data_column_iter: I, | ||
| kzg: &'a Kzg, | ||
| ) -> Result<(), AvailabilityCheckError> | ||
| where | ||
| I: Iterator<Item = &'a Arc<DataColumnSidecar<E>>> + Clone, | ||
| { | ||
| let Err(batch_err) = verify_kzg_for_data_column_list(data_column_iter.clone(), kzg) else { | ||
| return Ok(()); | ||
| }; | ||
|
|
||
| let data_columns = data_column_iter.collect::<Vec<_>>(); | ||
| // Find which column is invalid. If len is 1 or 0 continue to default case below. | ||
| // If len > 1 at least one column MUST fail. | ||
| if data_columns.len() > 1 { | ||
| for data_column in data_columns { | ||
| if let Err(e) = verify_kzg_for_data_column(data_column.clone(), kzg) { | ||
| return Err(AvailabilityCheckError::InvalidColumn(data_column.index, e)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // len 0 should never happen | ||
| Err(AvailabilityCheckError::InvalidColumn(0, batch_err)) | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub enum AvailableBlockData<E: EthSpec> { | ||
| /// Block is pre-Deneb or has zero blobs | ||
| NoData, | ||
| /// Block is post-Deneb, pre-PeerDAS and has more than zero blobs | ||
| Blobs(BlobSidecarList<E>), | ||
| /// Block is post-PeerDAS and has more than zero blobs | ||
| DataColumns(DataColumnSidecarList<E>), | ||
| /// An optional receiver for `DataColumnSidecarList`. | ||
| /// | ||
| /// This field is `Some` when data columns are being computed asynchronously. | ||
| /// The resulting `DataColumnSidecarList` will be sent through this receiver. | ||
| /// Block is post-PeerDAS, has more than zero blobs and we recomputed the columns from the EL's | ||
| /// mempool blobs | ||
| DataColumnsRecv(oneshot::Receiver<DataColumnSidecarList<E>>), | ||
| } | ||
|
|
||
|
|
@@ -754,7 +729,7 @@ pub enum AvailableBlockData<E: EthSpec> { | |
| pub struct AvailableBlock<E: EthSpec> { | ||
| block_root: Hash256, | ||
| block: Arc<SignedBeaconBlock<E>>, | ||
| data: AvailableBlockData<E>, | ||
| blob_data: AvailableBlockData<E>, | ||
| /// Timestamp at which this block first became available (UNIX timestamp, time since 1970). | ||
| blobs_available_timestamp: Option<Duration>, | ||
| pub spec: Arc<ChainSpec>, | ||
|
|
@@ -770,7 +745,7 @@ impl<E: EthSpec> AvailableBlock<E> { | |
| Self { | ||
| block_root, | ||
| block, | ||
| data, | ||
| blob_data: data, | ||
| blobs_available_timestamp: None, | ||
| spec, | ||
| } | ||
|
|
@@ -788,13 +763,13 @@ impl<E: EthSpec> AvailableBlock<E> { | |
| } | ||
|
|
||
| pub fn data(&self) -> &AvailableBlockData<E> { | ||
| &self.data | ||
| &self.blob_data | ||
| } | ||
|
|
||
| pub fn has_blobs(&self) -> bool { | ||
| match self.data { | ||
| match self.blob_data { | ||
| AvailableBlockData::NoData => false, | ||
| AvailableBlockData::Blobs(_) => true, | ||
| AvailableBlockData::Blobs(..) => true, | ||
| AvailableBlockData::DataColumns(_) => false, | ||
| AvailableBlockData::DataColumnsRecv(_) => false, | ||
| } | ||
|
|
@@ -805,18 +780,18 @@ impl<E: EthSpec> AvailableBlock<E> { | |
| let AvailableBlock { | ||
| block_root, | ||
| block, | ||
| data, | ||
| blob_data, | ||
| .. | ||
| } = self; | ||
| (block_root, block, data) | ||
| (block_root, block, blob_data) | ||
| } | ||
|
|
||
| /// Only used for testing | ||
| pub fn __clone_without_recv(&self) -> Result<Self, String> { | ||
| Ok(Self { | ||
| block_root: self.block_root, | ||
| block: self.block.clone(), | ||
| data: match &self.data { | ||
| blob_data: match &self.blob_data { | ||
| AvailableBlockData::NoData => AvailableBlockData::NoData, | ||
| AvailableBlockData::Blobs(blobs) => AvailableBlockData::Blobs(blobs.clone()), | ||
| AvailableBlockData::DataColumns(data_columns) => { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.