-
Notifications
You must be signed in to change notification settings - Fork 741
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
Add DataColumnSidecarsByRoot
req/resp protocol
#5196
Changes from 9 commits
5becc19
f14e9de
dd15bb3
c55e959
64061e2
4f3b243
e707536
bb1b416
04c82a3
3a96784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ use ssz_types::VariableList; | |||||||||||||
use state_processing::ConsensusContext; | ||||||||||||||
use std::sync::Arc; | ||||||||||||||
use types::blob_sidecar::{BlobIdentifier, BlobSidecarError, FixedBlobSidecarList}; | ||||||||||||||
use types::data_column_sidecar::DataColumnSidecarList; | ||||||||||||||
use types::{ | ||||||||||||||
BeaconBlockRef, BeaconState, BlindedPayload, BlobSidecarList, Epoch, EthSpec, Hash256, | ||||||||||||||
SignedBeaconBlock, SignedBeaconBlockHeader, Slot, | ||||||||||||||
|
@@ -43,20 +44,23 @@ impl<E: EthSpec> RpcBlock<E> { | |||||||||||||
match &self.block { | ||||||||||||||
RpcBlockInner::Block(block) => block, | ||||||||||||||
RpcBlockInner::BlockAndBlobs(block, _) => block, | ||||||||||||||
RpcBlockInner::BlockAndDataColumns(block, _) => block, | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
pub fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> { | ||||||||||||||
match &self.block { | ||||||||||||||
RpcBlockInner::Block(block) => block.clone(), | ||||||||||||||
RpcBlockInner::BlockAndBlobs(block, _) => block.clone(), | ||||||||||||||
RpcBlockInner::BlockAndDataColumns(block, _) => block.clone(), | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
pub fn blobs(&self) -> Option<&BlobSidecarList<E>> { | ||||||||||||||
match &self.block { | ||||||||||||||
RpcBlockInner::Block(_) => None, | ||||||||||||||
RpcBlockInner::BlockAndBlobs(_, blobs) => Some(blobs), | ||||||||||||||
RpcBlockInner::BlockAndDataColumns(_, _) => None, | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
@@ -72,6 +76,9 @@ enum RpcBlockInner<E: EthSpec> { | |||||||||||||
/// This variant is used with parent lookups and by-range responses. It should have all blobs | ||||||||||||||
/// ordered, all block roots matching, and the correct number of blobs for this block. | ||||||||||||||
BlockAndBlobs(Arc<SignedBeaconBlock<E>>, BlobSidecarList<E>), | ||||||||||||||
/// This variant is used with parent lookups and by-range responses. It should have all data columns | ||||||||||||||
/// ordered, all block roots matching, and the correct number of data columns for this block. | ||||||||||||||
BlockAndDataColumns(Arc<SignedBeaconBlock<E>>, DataColumnSidecarList<E>), | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
impl<E: EthSpec> RpcBlock<E> { | ||||||||||||||
|
@@ -141,25 +148,36 @@ impl<E: EthSpec> RpcBlock<E> { | |||||||||||||
Self::new(Some(block_root), block, blobs) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
#[allow(clippy::type_complexity)] | ||||||||||||||
pub fn deconstruct( | ||||||||||||||
self, | ||||||||||||||
) -> ( | ||||||||||||||
Hash256, | ||||||||||||||
Arc<SignedBeaconBlock<E>>, | ||||||||||||||
Option<BlobSidecarList<E>>, | ||||||||||||||
Option<DataColumnSidecarList<E>>, | ||||||||||||||
) { | ||||||||||||||
let block_root = self.block_root(); | ||||||||||||||
match self.block { | ||||||||||||||
RpcBlockInner::Block(block) => (block_root, block, None), | ||||||||||||||
RpcBlockInner::BlockAndBlobs(block, blobs) => (block_root, block, Some(blobs)), | ||||||||||||||
RpcBlockInner::Block(block) => (block_root, block, None, None), | ||||||||||||||
RpcBlockInner::BlockAndBlobs(block, blobs) => (block_root, block, Some(blobs), None), | ||||||||||||||
RpcBlockInner::BlockAndDataColumns(block, data_columns) => { | ||||||||||||||
(block_root, block, None, Some(data_columns)) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
pub fn n_blobs(&self) -> usize { | ||||||||||||||
match &self.block { | ||||||||||||||
RpcBlockInner::Block(_) => 0, | ||||||||||||||
RpcBlockInner::Block(_) | RpcBlockInner::BlockAndDataColumns(_, _) => 0, | ||||||||||||||
RpcBlockInner::BlockAndBlobs(_, blobs) => blobs.len(), | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
pub fn n_data_columns(&self) -> usize { | ||||||||||||||
match &self.block { | ||||||||||||||
RpcBlockInner::Block(_) | RpcBlockInner::BlockAndBlobs(_, _) => 0, | ||||||||||||||
RpcBlockInner::BlockAndDataColumns(_, data_columns) => data_columns.len(), | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// A block that has gone through all pre-deneb block processing checks including block processing | ||||||||||||||
|
@@ -485,12 +503,13 @@ impl<E: EthSpec> AsBlock<E> for AvailableBlock<E> { | |||||||||||||
} | ||||||||||||||
|
||||||||||||||
fn into_rpc_block(self) -> RpcBlock<E> { | ||||||||||||||
let (block_root, block, blobs_opt) = self.deconstruct(); | ||||||||||||||
let (block_root, block, blobs_opt, data_columns_opt) = self.deconstruct(); | ||||||||||||||
// Circumvent the constructor here, because an Available block will have already had | ||||||||||||||
// consistency checks performed. | ||||||||||||||
let inner = match blobs_opt { | ||||||||||||||
None => RpcBlockInner::Block(block), | ||||||||||||||
Some(blobs) => RpcBlockInner::BlockAndBlobs(block, blobs), | ||||||||||||||
let inner = match (blobs_opt, data_columns_opt) { | ||||||||||||||
(None, None) => RpcBlockInner::Block(block), | ||||||||||||||
(Some(blobs), _) => RpcBlockInner::BlockAndBlobs(block, blobs), | ||||||||||||||
(_, Some(data_columns)) => RpcBlockInner::BlockAndDataColumns(block, data_columns), | ||||||||||||||
Comment on lines
+509
to
+512
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. What happens here if we have both blobs and data_columns available? I guess we'd return a would a 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. Yeah, so originally I was thinking to prioritise blobs, but then it's kind of pointless because we aren't executing the data column code paths. I've been thinking about this and talking to Sean about this as well. A potentially way to introduce this and test it out may be add column subnets and sampling (without making it mandatory for 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. Can you
so the enum type guarantees that blobs and columns do not exist at the same time 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. Not sure if I'm understanding correctly but lighthouse/beacon_node/beacon_chain/src/data_availability_checker.rs Lines 603 to 608 in e707536
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. For an |
||||||||||||||
}; | ||||||||||||||
RpcBlock { | ||||||||||||||
block_root, | ||||||||||||||
|
@@ -522,12 +541,14 @@ impl<E: EthSpec> AsBlock<E> for RpcBlock<E> { | |||||||||||||
match &self.block { | ||||||||||||||
RpcBlockInner::Block(block) => block, | ||||||||||||||
RpcBlockInner::BlockAndBlobs(block, _) => block, | ||||||||||||||
RpcBlockInner::BlockAndDataColumns(block, _) => block, | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> { | ||||||||||||||
match &self.block { | ||||||||||||||
RpcBlockInner::Block(block) => block.clone(), | ||||||||||||||
RpcBlockInner::BlockAndBlobs(block, _) => block.clone(), | ||||||||||||||
RpcBlockInner::BlockAndDataColumns(block, _) => block.clone(), | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
fn canonical_root(&self) -> Hash256 { | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think match statements are executed in order from left to right. There might be a weird edge case here where both data columns and blobs are avail, but we return 0. If we're trying to support both blobs and data_columns initially, this edge case has the potential to cause issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you're right - perhaps we can add the
BlockAndBlobsAndDataColumns
variant to the other arm?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this type is used for RPC responses, so i don't think blobs and data column will coexist - we either request for
block + blobs
orblock + data columns
during lookups and sync, depending on the fork we're at.