Revert "remove into gossip verified block"
This reverts commit 246d52d209
.
This commit is contained in:
parent
c4da1ba450
commit
6fd2ef49e4
@ -796,6 +796,40 @@ pub struct BlockImportData<E: EthSpec> {
|
|||||||
pub consensus_context: ConsensusContext<E>,
|
pub consensus_context: ConsensusContext<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait IntoGossipVerifiedBlock<T: BeaconChainTypes>: Sized {
|
||||||
|
fn into_gossip_verified_block(
|
||||||
|
self,
|
||||||
|
chain: &BeaconChain<T>,
|
||||||
|
) -> Result<GossipVerifiedBlock<T>, BlockError<T::EthSpec>>;
|
||||||
|
fn inner(&self) -> Arc<SignedBeaconBlock<T::EthSpec>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: BeaconChainTypes> IntoGossipVerifiedBlock<T> for GossipVerifiedBlock<T> {
|
||||||
|
fn into_gossip_verified_block(
|
||||||
|
self,
|
||||||
|
_chain: &BeaconChain<T>,
|
||||||
|
) -> Result<GossipVerifiedBlock<T>, BlockError<T::EthSpec>> {
|
||||||
|
Ok(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn inner(&self) -> Arc<SignedBeaconBlock<T::EthSpec>> {
|
||||||
|
self.block.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: BeaconChainTypes> IntoGossipVerifiedBlock<T> for Arc<SignedBeaconBlock<T::EthSpec>> {
|
||||||
|
fn into_gossip_verified_block(
|
||||||
|
self,
|
||||||
|
chain: &BeaconChain<T>,
|
||||||
|
) -> Result<GossipVerifiedBlock<T>, BlockError<T::EthSpec>> {
|
||||||
|
GossipVerifiedBlock::new(self, chain)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn inner(&self) -> Arc<SignedBeaconBlock<T::EthSpec>> {
|
||||||
|
self.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Implemented on types that can be converted into a `ExecutionPendingBlock`.
|
/// Implemented on types that can be converted into a `ExecutionPendingBlock`.
|
||||||
///
|
///
|
||||||
/// Used to allow functions to accept blocks at various stages of verification.
|
/// Used to allow functions to accept blocks at various stages of verification.
|
||||||
|
@ -71,7 +71,7 @@ pub use beacon_fork_choice_store::{BeaconForkChoiceStore, Error as ForkChoiceSto
|
|||||||
pub use block_verification::{
|
pub use block_verification::{
|
||||||
get_block_root, AvailabilityPendingExecutedBlock, BlockError, ExecutedBlock,
|
get_block_root, AvailabilityPendingExecutedBlock, BlockError, ExecutedBlock,
|
||||||
ExecutionPayloadError, ExecutionPendingBlock, GossipVerifiedBlock, IntoExecutionPendingBlock,
|
ExecutionPayloadError, ExecutionPendingBlock, GossipVerifiedBlock, IntoExecutionPendingBlock,
|
||||||
PayloadVerificationOutcome, PayloadVerificationStatus,
|
PayloadVerificationOutcome, PayloadVerificationStatus,IntoGossipVerifiedBlock,
|
||||||
};
|
};
|
||||||
pub use canonical_head::{CachedHead, CanonicalHead, CanonicalHeadRwLock};
|
pub use canonical_head::{CachedHead, CanonicalHead, CanonicalHeadRwLock};
|
||||||
pub use eth1_chain::{Eth1Chain, Eth1ChainBackend};
|
pub use eth1_chain::{Eth1Chain, Eth1ChainBackend};
|
||||||
|
@ -3,7 +3,7 @@ use crate::metrics;
|
|||||||
use beacon_chain::blob_verification::BlockWrapper;
|
use beacon_chain::blob_verification::BlockWrapper;
|
||||||
use beacon_chain::validator_monitor::{get_block_delay_ms, timestamp_now};
|
use beacon_chain::validator_monitor::{get_block_delay_ms, timestamp_now};
|
||||||
use beacon_chain::{
|
use beacon_chain::{
|
||||||
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes, BlockError,
|
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes, BlockError,IntoGossipVerifiedBlock,
|
||||||
GossipVerifiedBlock, NotifyExecutionLayer,
|
GossipVerifiedBlock, NotifyExecutionLayer,
|
||||||
};
|
};
|
||||||
use eth2::types::BroadcastValidation;
|
use eth2::types::BroadcastValidation;
|
||||||
@ -13,6 +13,7 @@ use lighthouse_network::PubsubMessage;
|
|||||||
use network::NetworkMessage;
|
use network::NetworkMessage;
|
||||||
use slog::{debug, error, info, warn, Logger};
|
use slog::{debug, error, info, warn, Logger};
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
|
use std::marker::PhantomData;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
@ -23,28 +24,28 @@ use types::{
|
|||||||
};
|
};
|
||||||
use warp::Rejection;
|
use warp::Rejection;
|
||||||
|
|
||||||
pub enum ProvenancedBlock<T: EthSpec> {
|
pub enum ProvenancedBlock<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>> {
|
||||||
/// The payload was built using a local EE.
|
/// The payload was built using a local EE.
|
||||||
Local(SignedBlockContents<T, FullPayload<T>>),
|
Local(B, PhantomData<T>),
|
||||||
/// The payload was build using a remote builder (e.g., via a mev-boost
|
/// The payload was build using a remote builder (e.g., via a mev-boost
|
||||||
/// compatible relay).
|
/// compatible relay).
|
||||||
Builder(SignedBlockContents<T, FullPayload<T>>),
|
Builder(B, PhantomData<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: EthSpec> ProvenancedBlock<T> {
|
impl<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>> ProvenancedBlock<T, B> {
|
||||||
pub fn local(block: SignedBlockContents<T>) -> Self {
|
pub fn local(block: B) -> Self {
|
||||||
Self::Local(block)
|
Self::Local(block, PhantomData)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn builder(block: SignedBlockContents<T>) -> Self {
|
pub fn builder(block: B) -> Self {
|
||||||
Self::Builder(block)
|
Self::Builder(block, PhantomData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a request from the HTTP API for full blocks.
|
/// Handles a request from the HTTP API for full blocks.
|
||||||
pub async fn publish_block<T: BeaconChainTypes>(
|
pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
|
||||||
block_root: Option<Hash256>,
|
block_root: Option<Hash256>,
|
||||||
provenanced_block: ProvenancedBlock<T::EthSpec>,
|
provenanced_block: ProvenancedBlock<T, B>,
|
||||||
chain: Arc<BeaconChain<T>>,
|
chain: Arc<BeaconChain<T>>,
|
||||||
network_tx: &UnboundedSender<NetworkMessage<T::EthSpec>>,
|
network_tx: &UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||||
log: Logger,
|
log: Logger,
|
||||||
@ -53,11 +54,11 @@ pub async fn publish_block<T: BeaconChainTypes>(
|
|||||||
let seen_timestamp = timestamp_now();
|
let seen_timestamp = timestamp_now();
|
||||||
|
|
||||||
let (block, blobs_opt, is_locally_built_block) = match provenanced_block {
|
let (block, blobs_opt, is_locally_built_block) = match provenanced_block {
|
||||||
ProvenancedBlock::Local(block_contents) => {
|
ProvenancedBlock::Local(block_contents, _) => {
|
||||||
let (block, maybe_blobs) = block_contents.deconstruct();
|
let (block, maybe_blobs, ) = block_contents.deconstruct();
|
||||||
(Arc::new(block), maybe_blobs, true)
|
(Arc::new(block), maybe_blobs, true)
|
||||||
}
|
}
|
||||||
ProvenancedBlock::Builder(block_contents) => {
|
ProvenancedBlock::Builder(block_contents, _) => {
|
||||||
let (block, maybe_blobs) = block_contents.deconstruct();
|
let (block, maybe_blobs) = block_contents.deconstruct();
|
||||||
(Arc::new(block), maybe_blobs, false)
|
(Arc::new(block), maybe_blobs, false)
|
||||||
}
|
}
|
||||||
@ -124,8 +125,8 @@ pub async fn publish_block<T: BeaconChainTypes>(
|
|||||||
let log_clone = log.clone();
|
let log_clone = log.clone();
|
||||||
|
|
||||||
/* if we can form a `GossipVerifiedBlock`, we've passed our basic gossip checks */
|
/* if we can form a `GossipVerifiedBlock`, we've passed our basic gossip checks */
|
||||||
let gossip_verified_block = GossipVerifiedBlock::new(
|
let gossip_verified_block =
|
||||||
BlockWrapper::new(block.clone(), mapped_blobs),
|
BlockWrapper::new(block.clone(), mapped_blobs).into_gossip_verified_block(
|
||||||
&chain,
|
&chain,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
@ -270,8 +271,8 @@ pub async fn publish_blinded_block<T: BeaconChainTypes>(
|
|||||||
validation_level: BroadcastValidation,
|
validation_level: BroadcastValidation,
|
||||||
) -> Result<(), Rejection> {
|
) -> Result<(), Rejection> {
|
||||||
let block_root = block.signed_block().canonical_root();
|
let block_root = block.signed_block().canonical_root();
|
||||||
let full_block = reconstruct_block(chain.clone(), block_root, block, log.clone()).await?;
|
let full_block: ProvenancedBlock<T, SignedBlockContents<T::EthSpec>> = reconstruct_block(chain.clone(), block_root, block, log.clone()).await?;
|
||||||
publish_block::<T>(
|
publish_block::<T, _>(
|
||||||
Some(block_root),
|
Some(block_root),
|
||||||
full_block,
|
full_block,
|
||||||
chain,
|
chain,
|
||||||
@ -290,7 +291,7 @@ pub async fn reconstruct_block<T: BeaconChainTypes>(
|
|||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
block: SignedBlockContents<T::EthSpec, BlindedPayload<T::EthSpec>>,
|
block: SignedBlockContents<T::EthSpec, BlindedPayload<T::EthSpec>>,
|
||||||
log: Logger,
|
log: Logger,
|
||||||
) -> Result<ProvenancedBlock<T::EthSpec>, Rejection> {
|
) -> Result<ProvenancedBlock<T::EthSpec, SignedBlockContents<T::EthSpec>>, Rejection> {
|
||||||
let full_payload_opt = if let Ok(payload_header) =
|
let full_payload_opt = if let Ok(payload_header) =
|
||||||
block.signed_block().message().body().execution_payload()
|
block.signed_block().message().body().execution_payload()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user