Add blobs publishing
This commit is contained in:
parent
a8978a5f69
commit
775ca89801
@ -10,7 +10,10 @@ use slot_clock::SlotClock;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
use tree_hash::TreeHash;
|
use tree_hash::TreeHash;
|
||||||
use types::{AbstractExecPayload, BlindedPayload, EthSpec, ExecPayload, ExecutionBlockHash, FullPayload, Hash256, SignedBeaconBlock, SignedBlockContents};
|
use types::{
|
||||||
|
AbstractExecPayload, BlindedPayload, EthSpec, ExecPayload, ExecutionBlockHash, FullPayload,
|
||||||
|
Hash256, SignedBeaconBlock, SignedBlockContents,
|
||||||
|
};
|
||||||
use warp::Rejection;
|
use warp::Rejection;
|
||||||
|
|
||||||
/// Handles a request from the HTTP API for full blocks.
|
/// Handles a request from the HTTP API for full blocks.
|
||||||
@ -22,7 +25,7 @@ pub async fn publish_block<T: BeaconChainTypes>(
|
|||||||
log: Logger,
|
log: Logger,
|
||||||
) -> Result<(), Rejection> {
|
) -> Result<(), Rejection> {
|
||||||
let seen_timestamp = timestamp_now();
|
let seen_timestamp = timestamp_now();
|
||||||
let (block, _maybe_blobs) = block_contents.deconstruct();
|
let (block, maybe_blobs) = block_contents.deconstruct();
|
||||||
let block = Arc::new(block);
|
let block = Arc::new(block);
|
||||||
|
|
||||||
//FIXME(sean) have to move this to prior to publishing because it's included in the blobs sidecar message.
|
//FIXME(sean) have to move this to prior to publishing because it's included in the blobs sidecar message.
|
||||||
@ -36,13 +39,27 @@ pub async fn publish_block<T: BeaconChainTypes>(
|
|||||||
|
|
||||||
// Send the block, regardless of whether or not it is valid. The API
|
// Send the block, regardless of whether or not it is valid. The API
|
||||||
// specification is very clear that this is the desired behaviour.
|
// specification is very clear that this is the desired behaviour.
|
||||||
let wrapped_block: BlockWrapper<T::EthSpec> =
|
let wrapped_block: BlockWrapper<T::EthSpec> = match block.as_ref() {
|
||||||
if matches!(block.as_ref(), SignedBeaconBlock::Eip4844(_)) {
|
SignedBeaconBlock::Base(_)
|
||||||
todo!("to be implemented")
|
| SignedBeaconBlock::Altair(_)
|
||||||
} else {
|
| SignedBeaconBlock::Merge(_)
|
||||||
|
| SignedBeaconBlock::Capella(_) => {
|
||||||
crate::publish_pubsub_message(network_tx, PubsubMessage::BeaconBlock(block.clone()))?;
|
crate::publish_pubsub_message(network_tx, PubsubMessage::BeaconBlock(block.clone()))?;
|
||||||
block.into()
|
block.into()
|
||||||
};
|
}
|
||||||
|
SignedBeaconBlock::Eip4844(_) => {
|
||||||
|
crate::publish_pubsub_message(network_tx, PubsubMessage::BeaconBlock(block.clone()))?;
|
||||||
|
if let Some(blobs) = maybe_blobs {
|
||||||
|
for (blob_index, blob) in blobs.into_iter().enumerate() {
|
||||||
|
crate::publish_pubsub_message(
|
||||||
|
network_tx,
|
||||||
|
PubsubMessage::BlobSidecar(Box::new((blob_index as u64, blob))),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
block.into()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Determine the delay after the start of the slot, register it with metrics.
|
// Determine the delay after the start of the slot, register it with metrics.
|
||||||
let block = wrapped_block.as_block();
|
let block = wrapped_block.as_block();
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
use crate::{AbstractExecPayload, BlobsSidecar, EthSpec, SignedBeaconBlock, SignedBeaconBlockEip4844, SignedBlobSidecar};
|
use crate::{
|
||||||
|
AbstractExecPayload, BlobsSidecar, EthSpec, SignedBeaconBlock, SignedBeaconBlockEip4844,
|
||||||
|
SignedBlobSidecar,
|
||||||
|
};
|
||||||
use derivative::Derivative;
|
use derivative::Derivative;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use ssz::{Decode, DecodeError};
|
use ssz::{Decode, DecodeError};
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use std::sync::Arc;
|
|
||||||
use ssz_types::VariableList;
|
use ssz_types::VariableList;
|
||||||
|
use std::sync::Arc;
|
||||||
use tree_hash_derive::TreeHash;
|
use tree_hash_derive::TreeHash;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq)]
|
||||||
|
Loading…
Reference in New Issue
Block a user