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 tokio::sync::mpsc::UnboundedSender;
|
||||
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;
|
||||
|
||||
/// Handles a request from the HTTP API for full blocks.
|
||||
@ -22,7 +25,7 @@ pub async fn publish_block<T: BeaconChainTypes>(
|
||||
log: Logger,
|
||||
) -> Result<(), Rejection> {
|
||||
let seen_timestamp = timestamp_now();
|
||||
let (block, _maybe_blobs) = block_contents.deconstruct();
|
||||
let (block, maybe_blobs) = block_contents.deconstruct();
|
||||
let block = Arc::new(block);
|
||||
|
||||
//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
|
||||
// specification is very clear that this is the desired behaviour.
|
||||
let wrapped_block: BlockWrapper<T::EthSpec> =
|
||||
if matches!(block.as_ref(), SignedBeaconBlock::Eip4844(_)) {
|
||||
todo!("to be implemented")
|
||||
} else {
|
||||
let wrapped_block: BlockWrapper<T::EthSpec> = match block.as_ref() {
|
||||
SignedBeaconBlock::Base(_)
|
||||
| SignedBeaconBlock::Altair(_)
|
||||
| SignedBeaconBlock::Merge(_)
|
||||
| SignedBeaconBlock::Capella(_) => {
|
||||
crate::publish_pubsub_message(network_tx, PubsubMessage::BeaconBlock(block.clone()))?;
|
||||
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.
|
||||
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 serde_derive::{Deserialize, Serialize};
|
||||
use ssz::{Decode, DecodeError};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::sync::Arc;
|
||||
use ssz_types::VariableList;
|
||||
use std::sync::Arc;
|
||||
use tree_hash_derive::TreeHash;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq)]
|
||||
@ -41,4 +44,4 @@ impl<T: EthSpec> SignedBeaconBlockAndBlobsSidecar<T> {
|
||||
pub struct SignedBeaconBlockAndBlobSidecars<T: EthSpec, Payload: AbstractExecPayload<T>> {
|
||||
pub signed_block: SignedBeaconBlock<T, Payload>,
|
||||
pub signed_blob_sidecars: VariableList<SignedBlobSidecar<T>, <T as EthSpec>::MaxBlobsPerBlock>,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user