Skip to content

Inefficient get_data_column_keys #8270

@michaelsproul

Description

@michaelsproul

Description

This function looks slow to me:

/// Fetch all keys in the data_column column with prefix `block_root`
pub fn get_data_column_keys(&self, block_root: Hash256) -> Result<Vec<ColumnIndex>, Error> {
self.blobs_db
.iter_column_from::<Vec<u8>>(DBColumn::BeaconDataColumn, block_root.as_slice())
.take_while(|res| {
res.as_ref()
.is_ok_and(|(key, _)| key.starts_with(block_root.as_slice()))
})
.map(|key| key.and_then(|(key, _)| parse_data_column_key(key).map(|key| key.1)))
.collect()
}

It is reading the data columns from the database just to work out how many columns there are. I think we could calculate the number of columns from E::number_of_columns(), without doing any reads? We'd just need to account for the fact that some columns are expected to be missing based on custody count

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions