Check known parent on rpc blob process (#5893)

* Check known parent on rpc blob process

* fix test

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into blob-unknown-parent
This commit is contained in:
Lion - dapplion
2024-09-05 17:24:21 +02:00
committed by GitHub
parent 0e94fe1aa8
commit 369807becc
3 changed files with 40 additions and 13 deletions

View File

@@ -3073,6 +3073,23 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
return Err(BlockError::BlockIsAlreadyKnown(block_root));
}
// Reject RPC blobs referencing unknown parents. Otherwise we allow potentially invalid data
// into the da_checker, where invalid = descendant of invalid blocks.
// Note: blobs should have at least one item and all items have the same parent root.
if let Some(parent_root) = blobs
.iter()
.filter_map(|b| b.as_ref().map(|b| b.block_parent_root()))
.next()
{
if !self
.canonical_head
.fork_choice_read_lock()
.contains_block(&parent_root)
{
return Err(BlockError::ParentUnknown { parent_root });
}
}
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_blob_sidecar_subscribers() {
for blob in blobs.iter().filter_map(|maybe_blob| maybe_blob.as_ref()) {
@@ -3122,6 +3139,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
return Err(BlockError::BlockIsAlreadyKnown(block_root));
}
// Reject RPC columns referencing unknown parents. Otherwise we allow potentially invalid data
// into the da_checker, where invalid = descendant of invalid blocks.
// Note: custody_columns should have at least one item and all items have the same parent root.
if let Some(parent_root) = custody_columns.iter().map(|c| c.block_parent_root()).next() {
if !self
.canonical_head
.fork_choice_read_lock()
.contains_block(&parent_root)
{
return Err(BlockError::ParentUnknown { parent_root });
}
}
let r = self
.check_rpc_custody_columns_availability_and_import(slot, block_root, custody_columns)
.await;