fix compile

This commit is contained in:
realbigsean
2023-07-11 16:05:05 -04:00
parent 6fd2ef49e4
commit 782a53ad9d
12 changed files with 212 additions and 102 deletions

View File

@@ -511,7 +511,6 @@ pub fn verify_kzg_for_blob_list<T: EthSpec>(
let (blobs, (commitments, proofs)): (Vec<_>, (Vec<_>, Vec<_>)) = blob_list
.clone()
.into_iter()
//TODO(sean) remove clone
.map(|blob| (blob.blob.clone(), (blob.kzg_commitment, blob.kzg_proof)))
.unzip();
if validate_blobs::<T>(

View File

@@ -69,7 +69,7 @@ use crate::{
metrics, BeaconChain, BeaconChainError, BeaconChainTypes,
};
use derivative::Derivative;
use eth2::types::EventKind;
use eth2::types::{ArcBlockContentsTuple, EventKind, SignedBlockContents};
use execution_layer::PayloadStatus;
pub use fork_choice::{AttestationFromBlock, PayloadVerificationStatus};
use parking_lot::RwLockReadGuard;
@@ -92,7 +92,7 @@ use std::fs;
use std::io::Write;
use std::sync::Arc;
use std::time::Duration;
use store::{Error as DBError, HotStateSummary, KeyValueStore, StoreOp};
use store::{Error as DBError, HotStateSummary, KeyValueStore, SignedBlobSidecarList, StoreOp};
use task_executor::JoinHandle;
use tree_hash::TreeHash;
use types::blob_sidecar::BlobIdentifier;
@@ -627,6 +627,13 @@ pub struct GossipVerifiedBlock<T: BeaconChainTypes> {
consensus_context: ConsensusContext<T::EthSpec>,
}
impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
/// Useful for publishing after gossip verification.
pub fn into_block_wrapper(self) -> BlockWrapper<T::EthSpec> {
self.block.into_block_wrapper()
}
}
/// A wrapper around a `SignedBeaconBlock` that indicates that all signatures (except the deposit
/// signatures) have been verified.
pub struct SignatureVerifiedBlock<T: BeaconChainTypes> {
@@ -801,32 +808,45 @@ pub trait IntoGossipVerifiedBlock<T: BeaconChainTypes>: Sized {
self,
chain: &BeaconChain<T>,
) -> Result<GossipVerifiedBlock<T>, BlockError<T::EthSpec>>;
fn inner(&self) -> Arc<SignedBeaconBlock<T::EthSpec>>;
fn inner(&self) -> &SignedBeaconBlock<T::EthSpec>;
fn parts(self) -> ArcBlockContentsTuple<T::EthSpec>;
}
impl<T: BeaconChainTypes> IntoGossipVerifiedBlock<T> for GossipVerifiedBlock<T> {
impl<T: BeaconChainTypes> IntoGossipVerifiedBlock<T>
for (
GossipVerifiedBlock<T>,
Option<SignedBlobSidecarList<T::EthSpec>>,
)
{
fn into_gossip_verified_block(
self,
_chain: &BeaconChain<T>,
) -> Result<GossipVerifiedBlock<T>, BlockError<T::EthSpec>> {
Ok(self)
Ok(self.0)
}
fn inner(&self) -> Arc<SignedBeaconBlock<T::EthSpec>> {
self.block.clone()
fn inner(&self) -> &SignedBeaconBlock<T::EthSpec> {
self.0.block.as_block()
}
fn parts(self) -> ArcBlockContentsTuple<T::EthSpec> {
(self.0.block.block_cloned(), self.1)
}
}
impl<T: BeaconChainTypes> IntoGossipVerifiedBlock<T> for Arc<SignedBeaconBlock<T::EthSpec>> {
impl<T: BeaconChainTypes> IntoGossipVerifiedBlock<T> for SignedBlockContents<T::EthSpec> {
fn into_gossip_verified_block(
self,
chain: &BeaconChain<T>,
) -> Result<GossipVerifiedBlock<T>, BlockError<T::EthSpec>> {
GossipVerifiedBlock::new(self, chain)
GossipVerifiedBlock::new(self.deconstruct().into(), chain)
}
fn inner(&self) -> Arc<SignedBeaconBlock<T::EthSpec>> {
self.clone()
fn inner(&self) -> &SignedBeaconBlock<T::EthSpec> {
self.signed_block()
}
fn parts(self) -> ArcBlockContentsTuple<T::EthSpec> {
let (block, blobs) = self.deconstruct();
(Arc::new(block), blobs)
}
}

View File

@@ -531,6 +531,17 @@ pub enum VerifiedBlobs<E: EthSpec> {
PreDeneb,
}
impl<E: EthSpec> VerifiedBlobs<E> {
pub fn to_blobs(self) -> Option<BlobSidecarList<E>> {
match self {
Self::Available(blobs) => Some(blobs),
Self::NotRequired => None,
Self::EmptyBlobs => None,
Self::PreDeneb => None,
}
}
}
/// A fully available block that is ready to be imported into fork choice.
#[derive(Clone, Debug, PartialEq)]
pub struct AvailableBlock<E: EthSpec> {

View File

@@ -71,7 +71,7 @@ pub use beacon_fork_choice_store::{BeaconForkChoiceStore, Error as ForkChoiceSto
pub use block_verification::{
get_block_root, AvailabilityPendingExecutedBlock, BlockError, ExecutedBlock,
ExecutionPayloadError, ExecutionPendingBlock, GossipVerifiedBlock, IntoExecutionPendingBlock,
PayloadVerificationOutcome, PayloadVerificationStatus,IntoGossipVerifiedBlock,
IntoGossipVerifiedBlock, PayloadVerificationOutcome, PayloadVerificationStatus,
};
pub use canonical_head::{CachedHead, CanonicalHead, CanonicalHeadRwLock};
pub use eth1_chain::{Eth1Chain, Eth1ChainBackend};

View File

@@ -906,7 +906,7 @@ where
&self,
mut state: BeaconState<E>,
slot: Slot,
) -> (SignedBeaconBlock<E>, BeaconState<E>) {
) -> (BlockContentsTuple<E, FullPayload<E>>, BeaconState<E>) {
assert_ne!(slot, 0, "can't produce a block at slot 0");
assert!(slot >= state.slot());
@@ -946,7 +946,44 @@ where
&self.spec,
);
(signed_block, pre_state)
let block_contents: BlockContentsTuple<E, FullPayload<E>> = match &signed_block {
SignedBeaconBlock::Base(_)
| SignedBeaconBlock::Altair(_)
| SignedBeaconBlock::Merge(_)
| SignedBeaconBlock::Capella(_) => (signed_block, None),
SignedBeaconBlock::Deneb(_) => {
if let Some(blobs) = self
.chain
.proposal_blob_cache
.pop(&signed_block.canonical_root())
{
let signed_blobs: SignedBlobSidecarList<E> = Vec::from(blobs)
.into_iter()
.map(|blob| {
blob.sign(
&self.validator_keypairs[proposer_index].sk,
&state.fork(),
state.genesis_validators_root(),
&self.spec,
)
})
.collect::<Vec<_>>()
.into();
let mut guard = self.blob_signature_cache.write();
for blob in &signed_blobs {
guard.insert(
BlobSignatureKey::new(blob.message.block_root, blob.message.index),
blob.signature.clone(),
);
}
(signed_block, Some(signed_blobs))
} else {
(signed_block, None)
}
}
};
(block_contents, pre_state)
}
/// Create a randao reveal for a block at `slot`.
@@ -1737,11 +1774,12 @@ where
state: BeaconState<E>,
slot: Slot,
block_modifier: impl FnOnce(&mut BeaconBlock<E>),
) -> (SignedBeaconBlock<E>, BeaconState<E>) {
) -> (BlockContentsTuple<E, FullPayload<E>>, BeaconState<E>) {
assert_ne!(slot, 0, "can't produce a block at slot 0");
assert!(slot >= state.slot());
let (block, state) = self.make_block_return_pre_state(state, slot).await;
let ((block, blobs), state) = self.make_block_return_pre_state(state, slot).await;
let (mut block, _) = block.deconstruct();
block_modifier(&mut block);
@@ -1754,7 +1792,7 @@ where
state.genesis_validators_root(),
&self.spec,
);
(signed_block, state)
((signed_block, blobs), state)
}
pub fn make_deposits<'a>(