mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 18:21:45 +00:00
handle parent blob request edge cases correctly. fix data availability boundary check
This commit is contained in:
@@ -9,6 +9,7 @@ use slot_clock::SlotClock;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tree_hash::TreeHash;
|
||||
use types::signed_block_and_blobs::BlockWrapper;
|
||||
use types::{
|
||||
AbstractExecPayload, BlindedPayload, BlobsSidecar, EthSpec, ExecPayload, ExecutionBlockHash,
|
||||
FullPayload, Hash256, SignedBeaconBlock, SignedBeaconBlockAndBlobsSidecar,
|
||||
@@ -31,13 +32,20 @@ pub async fn publish_block<T: BeaconChainTypes>(
|
||||
let block_root = block_root.unwrap_or_else(|| block.canonical_root());
|
||||
|
||||
// Send the block, regardless of whether or not it is valid. The API
|
||||
// specification is very clear that this is the desired behaviour.
|
||||
let message = if matches!(block.as_ref(), &SignedBeaconBlock::Eip4844(_)) {
|
||||
// specification is very clear that this isa the desired behaviour.
|
||||
let wrapped_block = if matches!(block.as_ref(), &SignedBeaconBlock::Eip4844(_)) {
|
||||
if let Some(sidecar) = chain.blob_cache.pop(&block_root) {
|
||||
PubsubMessage::BeaconBlockAndBlobsSidecars(SignedBeaconBlockAndBlobsSidecar {
|
||||
beacon_block: block.clone(),
|
||||
let block_and_blobs = SignedBeaconBlockAndBlobsSidecar {
|
||||
beacon_block: block,
|
||||
blobs_sidecar: Arc::new(sidecar),
|
||||
})
|
||||
};
|
||||
crate::publish_pubsub_message(
|
||||
network_tx,
|
||||
PubsubMessage::BeaconBlockAndBlobsSidecars(block_and_blobs.clone()),
|
||||
)?;
|
||||
BlockWrapper::BlockAndBlob {
|
||||
block_sidecar_pair: block_and_blobs,
|
||||
}
|
||||
} else {
|
||||
//FIXME(sean): This should probably return a specific no-blob-cached error code, beacon API coordination required
|
||||
return Err(warp_utils::reject::broadcast_without_import(format!(
|
||||
@@ -45,18 +53,19 @@ pub async fn publish_block<T: BeaconChainTypes>(
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
PubsubMessage::BeaconBlock(block.clone())
|
||||
crate::publish_pubsub_message(network_tx, PubsubMessage::BeaconBlock(block.clone()))?;
|
||||
BlockWrapper::Block { block }
|
||||
};
|
||||
crate::publish_pubsub_message(network_tx, message)?;
|
||||
|
||||
// Determine the delay after the start of the slot, register it with metrics.
|
||||
let block = wrapped_block.block();
|
||||
let delay = get_block_delay_ms(seen_timestamp, block.message(), &chain.slot_clock);
|
||||
metrics::observe_duration(&metrics::HTTP_API_BLOCK_BROADCAST_DELAY_TIMES, delay);
|
||||
|
||||
match chain
|
||||
.process_block(
|
||||
block_root,
|
||||
block.clone(),
|
||||
wrapped_block.clone(),
|
||||
CountUnrealized::True,
|
||||
NotifyExecutionLayer::Yes,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user