mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +00:00
introduce availability pending block
This commit is contained in:
committed by
Pawan Dhananjay
parent
34cea6d1c3
commit
110eaf92c4
@@ -7,7 +7,7 @@ use crate::attester_cache::{AttesterCache, AttesterCacheKey};
|
|||||||
use crate::beacon_proposer_cache::compute_proposer_duties_from_head;
|
use crate::beacon_proposer_cache::compute_proposer_duties_from_head;
|
||||||
use crate::beacon_proposer_cache::BeaconProposerCache;
|
use crate::beacon_proposer_cache::BeaconProposerCache;
|
||||||
use crate::blob_cache::BlobCache;
|
use crate::blob_cache::BlobCache;
|
||||||
use crate::blob_verification::{AsBlock, AvailableBlock, BlockWrapper};
|
use crate::blob_verification::{AsBlock, AvailabilityPendingBlock, BlockWrapper};
|
||||||
use crate::block_times_cache::BlockTimesCache;
|
use crate::block_times_cache::BlockTimesCache;
|
||||||
use crate::block_verification::{
|
use crate::block_verification::{
|
||||||
check_block_is_finalized_checkpoint_or_descendant, check_block_relevancy, get_block_root,
|
check_block_is_finalized_checkpoint_or_descendant, check_block_relevancy, get_block_root,
|
||||||
@@ -2818,6 +2818,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let chain = self.clone();
|
let chain = self.clone();
|
||||||
let block_hash = self
|
let block_hash = self
|
||||||
.spawn_blocking_handle(
|
.spawn_blocking_handle(
|
||||||
@@ -2849,7 +2851,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn import_block(
|
fn import_block(
|
||||||
&self,
|
&self,
|
||||||
signed_block: AvailableBlock<T::EthSpec>,
|
signed_block: AvailabilityPendingBlock<T::EthSpec>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
mut state: BeaconState<T::EthSpec>,
|
mut state: BeaconState<T::EthSpec>,
|
||||||
confirmed_state_roots: Vec<Hash256>,
|
confirmed_state_roots: Vec<Hash256>,
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use derivative::Derivative;
|
use derivative::Derivative;
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
use crate::beacon_chain::{BeaconChain, BeaconChainTypes, MAXIMUM_GOSSIP_CLOCK_DISPARITY};
|
use crate::beacon_chain::{BeaconChain, BeaconChainTypes, MAXIMUM_GOSSIP_CLOCK_DISPARITY};
|
||||||
use crate::{kzg_utils, BeaconChainError};
|
use crate::{kzg_utils, BeaconChainError, BlockError};
|
||||||
use state_processing::per_block_processing::eip4844::eip4844::verify_kzg_commitments_against_transactions;
|
use state_processing::per_block_processing::eip4844::eip4844::verify_kzg_commitments_against_transactions;
|
||||||
use types::signed_beacon_block::BlobReconstructionError;
|
use types::signed_beacon_block::BlobReconstructionError;
|
||||||
use types::{
|
use types::{
|
||||||
@@ -12,6 +13,7 @@ use types::{
|
|||||||
Transactions,
|
Transactions,
|
||||||
};
|
};
|
||||||
use types::{Epoch, ExecPayload};
|
use types::{Epoch, ExecPayload};
|
||||||
|
use crate::block_verification::PayloadVerificationOutcome;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BlobError {
|
pub enum BlobError {
|
||||||
@@ -89,8 +91,8 @@ pub fn validate_blob_for_gossip<T: BeaconChainTypes>(
|
|||||||
block_wrapper: BlockWrapper<T::EthSpec>,
|
block_wrapper: BlockWrapper<T::EthSpec>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
chain: &BeaconChain<T>,
|
chain: &BeaconChain<T>,
|
||||||
) -> Result<AvailableBlock<T::EthSpec>, BlobError> {
|
) -> Result<AvailabilityPendingBlock<T::EthSpec>, BlobError> {
|
||||||
if let BlockWrapper::BlockAndBlob(ref block, ref blobs_sidecar) = block_wrapper {
|
if let BlockWrapper::BlockAndBlobs(ref block, ref blobs_sidecar) = block_wrapper {
|
||||||
let blob_slot = blobs_sidecar.beacon_block_slot;
|
let blob_slot = blobs_sidecar.beacon_block_slot;
|
||||||
// Do not gossip or process blobs from future or past slots.
|
// Do not gossip or process blobs from future or past slots.
|
||||||
let latest_permissible_slot = chain
|
let latest_permissible_slot = chain
|
||||||
@@ -112,7 +114,7 @@ pub fn validate_blob_for_gossip<T: BeaconChainTypes>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
block_wrapper.into_available_block(block_root, chain)
|
block_wrapper.into_availablilty_pending_block(block_root, chain)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify_data_availability<T: BeaconChainTypes>(
|
fn verify_data_availability<T: BeaconChainTypes>(
|
||||||
@@ -157,7 +159,8 @@ fn verify_data_availability<T: BeaconChainTypes>(
|
|||||||
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
|
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
|
||||||
pub enum BlockWrapper<E: EthSpec> {
|
pub enum BlockWrapper<E: EthSpec> {
|
||||||
Block(Arc<SignedBeaconBlock<E>>),
|
Block(Arc<SignedBeaconBlock<E>>),
|
||||||
BlockAndBlob(Arc<SignedBeaconBlock<E>>, Arc<BlobsSidecar<E>>),
|
BlockAndBlobs(Arc<SignedBeaconBlock<E>>, Arc<BlobsSidecar<E>>),
|
||||||
|
BlockAndBlobsFuture(Arc<SignedBeaconBlock<E>>, DataAvailabilityHandle<E>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: EthSpec> BlockWrapper<E> {
|
impl<E: EthSpec> BlockWrapper<E> {
|
||||||
@@ -166,7 +169,7 @@ impl<E: EthSpec> BlockWrapper<E> {
|
|||||||
blobs_sidecar: Option<Arc<BlobsSidecar<E>>>,
|
blobs_sidecar: Option<Arc<BlobsSidecar<E>>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
if let Some(blobs_sidecar) = blobs_sidecar {
|
if let Some(blobs_sidecar) = blobs_sidecar {
|
||||||
BlockWrapper::BlockAndBlob(block, blobs_sidecar)
|
BlockWrapper::BlockAndBlobs(block, blobs_sidecar)
|
||||||
} else {
|
} else {
|
||||||
BlockWrapper::Block(block)
|
BlockWrapper::Block(block)
|
||||||
}
|
}
|
||||||
@@ -185,7 +188,7 @@ impl<E: EthSpec> From<SignedBeaconBlockAndBlobsSidecar<E>> for BlockWrapper<E> {
|
|||||||
beacon_block,
|
beacon_block,
|
||||||
blobs_sidecar,
|
blobs_sidecar,
|
||||||
} = block;
|
} = block;
|
||||||
BlockWrapper::BlockAndBlob(beacon_block, blobs_sidecar)
|
BlockWrapper::BlockAndBlobs(beacon_block, blobs_sidecar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,20 +204,12 @@ pub enum DataAvailabilityCheckRequired {
|
|||||||
No,
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait IntoAvailableBlock<T: BeaconChainTypes> {
|
impl<T: BeaconChainTypes> BlockWrapper<T::EthSpec> {
|
||||||
fn into_available_block(
|
fn into_availablilty_pending_block(
|
||||||
self,
|
self,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
chain: &BeaconChain<T>,
|
chain: &BeaconChain<T>,
|
||||||
) -> Result<AvailableBlock<T::EthSpec>, BlobError>;
|
) -> Result<AvailabilityPendingBlock<T::EthSpec>, BlobError> {
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: BeaconChainTypes> IntoAvailableBlock<T> for BlockWrapper<T::EthSpec> {
|
|
||||||
fn into_available_block(
|
|
||||||
self,
|
|
||||||
block_root: Hash256,
|
|
||||||
chain: &BeaconChain<T>,
|
|
||||||
) -> Result<AvailableBlock<T::EthSpec>, BlobError> {
|
|
||||||
let data_availability_boundary = chain.data_availability_boundary();
|
let data_availability_boundary = chain.data_availability_boundary();
|
||||||
let da_check_required =
|
let da_check_required =
|
||||||
data_availability_boundary.map_or(DataAvailabilityCheckRequired::No, |boundary| {
|
data_availability_boundary.map_or(DataAvailabilityCheckRequired::No, |boundary| {
|
||||||
@@ -225,8 +220,8 @@ impl<T: BeaconChainTypes> IntoAvailableBlock<T> for BlockWrapper<T::EthSpec> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => AvailableBlock::new(block, block_root, da_check_required),
|
BlockWrapper::Block(block) => AvailabilityPendingBlock::new(block, block_root, da_check_required),
|
||||||
BlockWrapper::BlockAndBlob(block, blobs_sidecar) => {
|
BlockWrapper::BlockAndBlobs(block, blobs_sidecar) => {
|
||||||
if matches!(da_check_required, DataAvailabilityCheckRequired::Yes) {
|
if matches!(da_check_required, DataAvailabilityCheckRequired::Yes) {
|
||||||
let kzg_commitments = block
|
let kzg_commitments = block
|
||||||
.message()
|
.message()
|
||||||
@@ -250,7 +245,7 @@ impl<T: BeaconChainTypes> IntoAvailableBlock<T> for BlockWrapper<T::EthSpec> {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
AvailableBlock::new_with_blobs(block, blobs_sidecar, da_check_required)
|
AvailabilityPendingBlock::new_with_blobs(block, blobs_sidecar, da_check_required)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,7 +257,30 @@ impl<T: BeaconChainTypes> IntoAvailableBlock<T> for BlockWrapper<T::EthSpec> {
|
|||||||
/// cannot be circumvented on construction.
|
/// cannot be circumvented on construction.
|
||||||
#[derive(Clone, Debug, Derivative)]
|
#[derive(Clone, Debug, Derivative)]
|
||||||
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
|
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
|
||||||
pub struct AvailableBlock<E: EthSpec>(AvailableBlockInner<E>);
|
pub struct AvailabilityPendingBlock<E: EthSpec>{
|
||||||
|
block: Arc<SignedBeaconBlock<E>>,
|
||||||
|
data_availability_handle: DataAvailabilityHandle<E>
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Used to await the result of data availability check.
|
||||||
|
type DataAvailabilityHandle<E> = JoinHandle<Result<Option<Arc<BlobsSidecar<E>>>, BlobError>>;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Derivative)]
|
||||||
|
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
|
||||||
|
pub struct AvailableBlock<E: EthSpec> {
|
||||||
|
block: Arc<SignedBeaconBlock<E>>,
|
||||||
|
blobs: Blobs<E>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum Blobs<E: EthSpec> {
|
||||||
|
/// These blobs are available.
|
||||||
|
Available(Arc<BlobsSidecar<E>>),
|
||||||
|
/// This block is from outside the data availability boundary or the block is from prior
|
||||||
|
/// to the eip4844 fork.
|
||||||
|
NotRequired,
|
||||||
|
/// The block doesn't have any blob transactions.
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
/// A wrapper over a [`SignedBeaconBlock`] or a [`SignedBeaconBlockAndBlobsSidecar`].
|
/// A wrapper over a [`SignedBeaconBlock`] or a [`SignedBeaconBlockAndBlobsSidecar`].
|
||||||
#[derive(Clone, Debug, Derivative)]
|
#[derive(Clone, Debug, Derivative)]
|
||||||
@@ -272,7 +290,7 @@ enum AvailableBlockInner<E: EthSpec> {
|
|||||||
BlockAndBlob(SignedBeaconBlockAndBlobsSidecar<E>),
|
BlockAndBlob(SignedBeaconBlockAndBlobsSidecar<E>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: EthSpec> AvailableBlock<E> {
|
impl<E: EthSpec> AvailabilityPendingBlock<E> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
beacon_block: Arc<SignedBeaconBlock<E>>,
|
beacon_block: Arc<SignedBeaconBlock<E>>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
@@ -372,11 +390,11 @@ impl<E: EthSpec> IntoBlockWrapper<E> for BlockWrapper<E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: EthSpec> IntoBlockWrapper<E> for AvailableBlock<E> {
|
impl<E: EthSpec> IntoBlockWrapper<E> for AvailabilityPendingBlock<E> {
|
||||||
fn into_block_wrapper(self) -> BlockWrapper<E> {
|
fn into_block_wrapper(self) -> BlockWrapper<E> {
|
||||||
let (block, blobs) = self.deconstruct();
|
let (block, blobs) = self.deconstruct();
|
||||||
if let Some(blobs) = blobs {
|
if let Some(blobs) = blobs {
|
||||||
BlockWrapper::BlockAndBlob(block, blobs)
|
BlockWrapper::BlockAndBlobs(block, blobs)
|
||||||
} else {
|
} else {
|
||||||
BlockWrapper::Block(block)
|
BlockWrapper::Block(block)
|
||||||
}
|
}
|
||||||
@@ -399,49 +417,49 @@ impl<E: EthSpec> AsBlock<E> for BlockWrapper<E> {
|
|||||||
fn slot(&self) -> Slot {
|
fn slot(&self) -> Slot {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.slot(),
|
BlockWrapper::Block(block) => block.slot(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.slot(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.slot(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn epoch(&self) -> Epoch {
|
fn epoch(&self) -> Epoch {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.epoch(),
|
BlockWrapper::Block(block) => block.epoch(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.epoch(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.epoch(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn parent_root(&self) -> Hash256 {
|
fn parent_root(&self) -> Hash256 {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.parent_root(),
|
BlockWrapper::Block(block) => block.parent_root(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.parent_root(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.parent_root(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn state_root(&self) -> Hash256 {
|
fn state_root(&self) -> Hash256 {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.state_root(),
|
BlockWrapper::Block(block) => block.state_root(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.state_root(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.state_root(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn signed_block_header(&self) -> SignedBeaconBlockHeader {
|
fn signed_block_header(&self) -> SignedBeaconBlockHeader {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block.signed_block_header(),
|
BlockWrapper::Block(block) => block.signed_block_header(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.signed_block_header(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.signed_block_header(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn message(&self) -> BeaconBlockRef<E> {
|
fn message(&self) -> BeaconBlockRef<E> {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block.message(),
|
BlockWrapper::Block(block) => block.message(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.message(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.message(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn as_block(&self) -> &SignedBeaconBlock<E> {
|
fn as_block(&self) -> &SignedBeaconBlock<E> {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block,
|
BlockWrapper::Block(block) => &block,
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block,
|
BlockWrapper::BlockAndBlobs(block, _) => &block,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
|
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block.clone(),
|
BlockWrapper::Block(block) => block.clone(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.clone(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn canonical_root(&self) -> Hash256 {
|
fn canonical_root(&self) -> Hash256 {
|
||||||
@@ -456,49 +474,49 @@ impl<E: EthSpec> AsBlock<E> for &BlockWrapper<E> {
|
|||||||
fn slot(&self) -> Slot {
|
fn slot(&self) -> Slot {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.slot(),
|
BlockWrapper::Block(block) => block.slot(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.slot(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.slot(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn epoch(&self) -> Epoch {
|
fn epoch(&self) -> Epoch {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.epoch(),
|
BlockWrapper::Block(block) => block.epoch(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.epoch(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.epoch(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn parent_root(&self) -> Hash256 {
|
fn parent_root(&self) -> Hash256 {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.parent_root(),
|
BlockWrapper::Block(block) => block.parent_root(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.parent_root(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.parent_root(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn state_root(&self) -> Hash256 {
|
fn state_root(&self) -> Hash256 {
|
||||||
match self {
|
match self {
|
||||||
BlockWrapper::Block(block) => block.state_root(),
|
BlockWrapper::Block(block) => block.state_root(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.state_root(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.state_root(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn signed_block_header(&self) -> SignedBeaconBlockHeader {
|
fn signed_block_header(&self) -> SignedBeaconBlockHeader {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block.signed_block_header(),
|
BlockWrapper::Block(block) => block.signed_block_header(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.signed_block_header(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.signed_block_header(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn message(&self) -> BeaconBlockRef<E> {
|
fn message(&self) -> BeaconBlockRef<E> {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block.message(),
|
BlockWrapper::Block(block) => block.message(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.message(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.message(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn as_block(&self) -> &SignedBeaconBlock<E> {
|
fn as_block(&self) -> &SignedBeaconBlock<E> {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block,
|
BlockWrapper::Block(block) => &block,
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block,
|
BlockWrapper::BlockAndBlobs(block, _) => &block,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
|
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
|
||||||
match &self {
|
match &self {
|
||||||
BlockWrapper::Block(block) => block.clone(),
|
BlockWrapper::Block(block) => block.clone(),
|
||||||
BlockWrapper::BlockAndBlob(block, _) => block.clone(),
|
BlockWrapper::BlockAndBlobs(block, _) => block.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn canonical_root(&self) -> Hash256 {
|
fn canonical_root(&self) -> Hash256 {
|
||||||
@@ -509,7 +527,7 @@ impl<E: EthSpec> AsBlock<E> for &BlockWrapper<E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: EthSpec> AsBlock<E> for AvailableBlock<E> {
|
impl<E: EthSpec> AsBlock<E> for AvailabilityPendingBlock<E> {
|
||||||
fn slot(&self) -> Slot {
|
fn slot(&self) -> Slot {
|
||||||
match &self.0 {
|
match &self.0 {
|
||||||
AvailableBlockInner::Block(block) => block.slot(),
|
AvailableBlockInner::Block(block) => block.slot(),
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
#![allow(clippy::result_large_err)]
|
#![allow(clippy::result_large_err)]
|
||||||
|
|
||||||
use crate::blob_verification::{
|
use crate::blob_verification::{
|
||||||
validate_blob_for_gossip, AsBlock, AvailableBlock, BlobError, BlockWrapper, IntoAvailableBlock,
|
validate_blob_for_gossip, AsBlock, AvailabilityPendingBlock, BlobError, BlockWrapper, IntoAvailableBlock,
|
||||||
IntoBlockWrapper,
|
IntoBlockWrapper,
|
||||||
};
|
};
|
||||||
use crate::eth1_finalization_cache::Eth1FinalizationData;
|
use crate::eth1_finalization_cache::Eth1FinalizationData;
|
||||||
@@ -637,7 +637,7 @@ pub fn signature_verify_chain_segment<T: BeaconChainTypes>(
|
|||||||
#[derive(Derivative)]
|
#[derive(Derivative)]
|
||||||
#[derivative(Debug(bound = "T: BeaconChainTypes"))]
|
#[derivative(Debug(bound = "T: BeaconChainTypes"))]
|
||||||
pub struct GossipVerifiedBlock<T: BeaconChainTypes> {
|
pub struct GossipVerifiedBlock<T: BeaconChainTypes> {
|
||||||
pub block: AvailableBlock<T::EthSpec>,
|
pub block: AvailabilityPendingBlock<T::EthSpec>,
|
||||||
pub block_root: Hash256,
|
pub block_root: Hash256,
|
||||||
parent: Option<PreProcessingSnapshot<T::EthSpec>>,
|
parent: Option<PreProcessingSnapshot<T::EthSpec>>,
|
||||||
consensus_context: ConsensusContext<T::EthSpec>,
|
consensus_context: ConsensusContext<T::EthSpec>,
|
||||||
@@ -646,7 +646,7 @@ pub struct GossipVerifiedBlock<T: BeaconChainTypes> {
|
|||||||
/// A wrapper around a `SignedBeaconBlock` that indicates that all signatures (except the deposit
|
/// A wrapper around a `SignedBeaconBlock` that indicates that all signatures (except the deposit
|
||||||
/// signatures) have been verified.
|
/// signatures) have been verified.
|
||||||
pub struct SignatureVerifiedBlock<T: BeaconChainTypes> {
|
pub struct SignatureVerifiedBlock<T: BeaconChainTypes> {
|
||||||
block: AvailableBlock<T::EthSpec>,
|
block: AvailabilityPendingBlock<T::EthSpec>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
parent: Option<PreProcessingSnapshot<T::EthSpec>>,
|
parent: Option<PreProcessingSnapshot<T::EthSpec>>,
|
||||||
consensus_context: ConsensusContext<T::EthSpec>,
|
consensus_context: ConsensusContext<T::EthSpec>,
|
||||||
@@ -668,8 +668,8 @@ type PayloadVerificationHandle<E> =
|
|||||||
/// Note: a `ExecutionPendingBlock` is not _forever_ valid to be imported, it may later become invalid
|
/// Note: a `ExecutionPendingBlock` is not _forever_ valid to be imported, it may later become invalid
|
||||||
/// due to finality or some other event. A `ExecutionPendingBlock` should be imported into the
|
/// due to finality or some other event. A `ExecutionPendingBlock` should be imported into the
|
||||||
/// `BeaconChain` immediately after it is instantiated.
|
/// `BeaconChain` immediately after it is instantiated.
|
||||||
pub struct ExecutionPendingBlock<T: BeaconChainTypes> {
|
pub struct ExecutionPendingBlock<T: BeaconChainTypes, B: IntoAvailablBlock> {
|
||||||
pub block: AvailableBlock<T::EthSpec>,
|
pub block: B,
|
||||||
pub block_root: Hash256,
|
pub block_root: Hash256,
|
||||||
pub state: BeaconState<T::EthSpec>,
|
pub state: BeaconState<T::EthSpec>,
|
||||||
pub parent_block: SignedBeaconBlock<T::EthSpec, BlindedPayload<T::EthSpec>>,
|
pub parent_block: SignedBeaconBlock<T::EthSpec, BlindedPayload<T::EthSpec>>,
|
||||||
@@ -978,7 +978,7 @@ impl<T: BeaconChainTypes> SignatureVerifiedBlock<T> {
|
|||||||
///
|
///
|
||||||
/// Returns an error if the block is invalid, or if the block was unable to be verified.
|
/// Returns an error if the block is invalid, or if the block was unable to be verified.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
block: AvailableBlock<T::EthSpec>,
|
block: AvailabilityPendingBlock<T::EthSpec>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
chain: &BeaconChain<T>,
|
chain: &BeaconChain<T>,
|
||||||
) -> Result<Self, BlockError<T::EthSpec>> {
|
) -> Result<Self, BlockError<T::EthSpec>> {
|
||||||
@@ -1028,7 +1028,7 @@ impl<T: BeaconChainTypes> SignatureVerifiedBlock<T> {
|
|||||||
|
|
||||||
/// As for `new` above but producing `BlockSlashInfo`.
|
/// As for `new` above but producing `BlockSlashInfo`.
|
||||||
pub fn check_slashable(
|
pub fn check_slashable(
|
||||||
block: AvailableBlock<T::EthSpec>,
|
block: AvailabilityPendingBlock<T::EthSpec>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
chain: &BeaconChain<T>,
|
chain: &BeaconChain<T>,
|
||||||
) -> Result<Self, BlockSlashInfo<BlockError<T::EthSpec>>> {
|
) -> Result<Self, BlockSlashInfo<BlockError<T::EthSpec>>> {
|
||||||
@@ -1151,7 +1151,7 @@ impl<T: BeaconChainTypes> IntoExecutionPendingBlock<T> for Arc<SignedBeaconBlock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: BeaconChainTypes> IntoExecutionPendingBlock<T> for AvailableBlock<T::EthSpec> {
|
impl<T: BeaconChainTypes> IntoExecutionPendingBlock<T> for AvailabilityPendingBlock<T::EthSpec> {
|
||||||
/// Verifies the `SignedBeaconBlock` by first transforming it into a `SignatureVerifiedBlock`
|
/// Verifies the `SignedBeaconBlock` by first transforming it into a `SignatureVerifiedBlock`
|
||||||
/// and then using that implementation of `IntoExecutionPendingBlock` to complete verification.
|
/// and then using that implementation of `IntoExecutionPendingBlock` to complete verification.
|
||||||
fn into_execution_pending_block_slashable(
|
fn into_execution_pending_block_slashable(
|
||||||
@@ -1182,7 +1182,7 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
|
|||||||
///
|
///
|
||||||
/// Returns an error if the block is invalid, or if the block was unable to be verified.
|
/// Returns an error if the block is invalid, or if the block was unable to be verified.
|
||||||
pub fn from_signature_verified_components(
|
pub fn from_signature_verified_components(
|
||||||
block: AvailableBlock<T::EthSpec>,
|
block: AvailabilityPendingBlock<T::EthSpec>,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
parent: PreProcessingSnapshot<T::EthSpec>,
|
parent: PreProcessingSnapshot<T::EthSpec>,
|
||||||
mut consensus_context: ConsensusContext<T::EthSpec>,
|
mut consensus_context: ConsensusContext<T::EthSpec>,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::blob_verification::AvailableBlock;
|
use crate::blob_verification::AvailabilityPendingBlock;
|
||||||
use crate::{
|
use crate::{
|
||||||
attester_cache::{CommitteeLengths, Error},
|
attester_cache::{CommitteeLengths, Error},
|
||||||
metrics,
|
metrics,
|
||||||
@@ -51,7 +51,7 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
|
|||||||
pub fn add_head_block(
|
pub fn add_head_block(
|
||||||
&self,
|
&self,
|
||||||
beacon_block_root: Hash256,
|
beacon_block_root: Hash256,
|
||||||
block: AvailableBlock<E>,
|
block: AvailabilityPendingBlock<E>,
|
||||||
proto_block: ProtoBlock,
|
proto_block: ProtoBlock,
|
||||||
state: &BeaconState<E>,
|
state: &BeaconState<E>,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
|
|||||||
Reference in New Issue
Block a user