-
Notifications
You must be signed in to change notification settings - Fork 862
Fix for #7377 Update DataColumnSidecarsByRoot request to use DataColumnsByRootIdentifier #7399
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
base: unstable
Are you sure you want to change the base?
Conversation
Status: testing |
Status: review ready |
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.
@SunnysidedJ thanks a lot for this PR!
I'm still reviewing but thought I'd post my comments I have so far. I'll continue review this afternoon.
@@ -32,6 +34,51 @@ pub struct DataColumnIdentifier { | |||
pub index: ColumnIndex, | |||
} |
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.
DataColumnIdentifier
can be removed
let number_of_columns = spec.number_of_columns as usize; | ||
// TODO we aren't handling the case where self.indices > NUMBER_OF_COLUMNS defined by the | ||
// spec. Do we do this else where? I think we shall use RuntimeVariableList::new() and | ||
// handle errors. |
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.
Yes agree that we should use RuntimeVariableList::new()
instead, perhaps modify this function to try_into_request
and return Result
here
)? | ||
.into_iter() | ||
.map(|bytes| { | ||
// Split manually: first 32 bytes = block_root and next 4 bytes = vector tag |
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 it would be a bit cleaner to use SszDecoderBuilder
here to decode, and call into a separate DataColumnByRootIdentifier
decode function
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.
Something like this:
let mut builder = ssz::SszDecoderBuilder::new(&bytes);
builder.register_type::<Hash256>()?;
builder.register_anonymous_variable_length_item()?;
let mut decoder = builder.build()?;
let block_root = decoder.decode_next()?;
let indices = decoder.decode_next_with(|bytes| DataColumnsByRootIdentifier::from_ssz_bytes(bytes, num_columns))?;
Ok(DataColumnsByRootIdentifier {
block_root,
indices,
})
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've added some more comments, let me know what you think. Thanks!
@@ -1781,7 +1793,10 @@ fn default_max_blobs_by_root_request() -> usize { | |||
} | |||
|
|||
fn default_data_columns_by_root_request() -> usize { | |||
max_data_columns_by_root_request_common(default_max_request_data_column_sidecars()) | |||
max_data_columns_by_root_request_common( | |||
default_max_request_data_column_sidecars(), |
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.
this should be default_max_request_blocks()
?
@@ -2083,6 +2098,7 @@ impl Config { | |||
max_blobs_by_root_request: max_blobs_by_root_request_common(max_request_blob_sidecars), | |||
max_data_columns_by_root_request: max_data_columns_by_root_request_common( | |||
max_request_data_column_sidecars, |
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.
default_max_request_blocks()
} | ||
|
||
impl DataColumnsByRootRequest { | ||
pub fn new(data_column_ids: Vec<DataColumnIdentifier>, spec: &ChainSpec) -> Self { | ||
pub fn new(data_column_ids: Vec<DataColumnsByRootIdentifier>, spec: &ChainSpec) -> Self { | ||
let data_column_ids = RuntimeVariableList::from_vec( | ||
data_column_ids, | ||
spec.max_request_data_column_sidecars as usize, |
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.
This should be MAX_REQUEST_BLOCKS_DENEB
for data_column_ids_by_root in request.data_column_ids.as_slice() { | ||
match self.chain.get_data_columns_checking_all_caches( | ||
data_column_ids_by_root.block_root, | ||
&Vec::from(data_column_ids_by_root.indices.clone()), |
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 we can do data_column_ids_by_root.indices.as_slice()
here to avoid cloning?
@@ -405,16 +405,18 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> { | |||
} | |||
|
|||
/// Fetch a data column from the cache without affecting the LRU ordering |
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.
/// Fetch a data column from the cache without affecting the LRU ordering | |
/// Fetch data columns of a given `block_root` from the cache without affecting the LRU ordering |
} else if let Some(all_cols) = self.early_attester_cache.get_data_columns(block_root) { | ||
Ok(Some(all_cols)) | ||
} else { | ||
self.get_data_columns(&block_root) |
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.
We probably want to avoid loading all data columns from disk and just load the required one here.
Ok(Some(all_cols)) | ||
} else { | ||
self.get_data_columns(&block_root) | ||
}; |
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.
Doesn't look like we need to wrap it with Result
here and unwrap it below.
We could simplify this to something like
let columns = if let Some(all_cols) = self
.data_availability_checker
.get_data_columns(block_root)?
{
Some(all_cols)
} else if let Some(all_cols) = self.early_attester_cache.get_data_columns(block_root) {
Some(all_cols)
} else {
self.get_data_columns(&block_root)?
};
and then return Ok(columns)
after filtering.
.iter() | ||
.filter(|col| indices.contains(&col.index)) | ||
.cloned() | ||
.collect(), |
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.
you could do into_iter
to avoid having to clone the elements
Issue Addressed
Update DataColumnSidecarsByRoot request to use DataColumnsByRootIdentifier #7377
Proposed Changes
As described in ethereum/consensus-specs#4284
Additional Info