From 8c6be8a5327010e55aecd3cc837fd8bbb496926c Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 2 Nov 2023 18:49:53 +0530 Subject: [PATCH] Gossip verification compiles --- .../beacon_chain/src/blob_verification.rs | 107 +++++++----------- .../beacon_chain/src/block_verification.rs | 4 +- .../src/block_verification_types.rs | 7 -- .../src/data_availability_checker.rs | 6 +- .../src/data_availability_checker/error.rs | 7 +- .../overflow_lru_cache.rs | 13 +-- .../src/observed_blob_sidecars.rs | 19 ++-- beacon_node/beacon_chain/src/test_utils.rs | 55 +-------- .../lighthouse_network/src/types/pubsub.rs | 22 ++-- consensus/types/src/beacon_block_body.rs | 8 ++ consensus/types/src/blob_sidecar.rs | 10 +- consensus/types/src/eth_spec.rs | 2 +- consensus/types/src/sidecar.rs | 3 +- consensus/types/src/signed_beacon_block.rs | 2 +- 14 files changed, 96 insertions(+), 169 deletions(-) diff --git a/beacon_node/beacon_chain/src/blob_verification.rs b/beacon_node/beacon_chain/src/blob_verification.rs index ca69d2ab6f1..19378130bcd 100644 --- a/beacon_node/beacon_chain/src/blob_verification.rs +++ b/beacon_node/beacon_chain/src/blob_verification.rs @@ -16,10 +16,7 @@ use ssz_derive::{Decode, Encode}; use ssz_types::VariableList; use tree_hash::TreeHash; use types::blob_sidecar::BlobIdentifier; -use types::{ - BeaconStateError, BlobSidecar, BlobSidecarList, CloneConfig, EthSpec, Hash256, - SignedBlobSidecar, Slot, -}; +use types::{BeaconStateError, BlobSidecar, BlobSidecarList, CloneConfig, EthSpec, Hash256, Slot}; /// An error occurred while validating a gossip blob. #[derive(Debug)] @@ -118,7 +115,7 @@ impl std::fmt::Display for GossipBlobError { write!( f, "BlobParentUnknown(parent_root:{})", - blob_sidecar.block_parent_root + blob_sidecar.block_parent_root() ) } other => write!(f, "{:?}", other), @@ -147,62 +144,56 @@ pub type GossipVerifiedBlobList = VariableList< /// the p2p network. #[derive(Debug)] pub struct GossipVerifiedBlob { - blob: SignedBlobSidecar, + blob: Arc>, } impl GossipVerifiedBlob { pub fn new( - blob: SignedBlobSidecar, + blob: Arc>, chain: &BeaconChain, ) -> Result> { - let blob_index = blob.message.index; + let blob_index = blob.index; validate_blob_sidecar_for_gossip(blob, blob_index, chain) } /// Construct a `GossipVerifiedBlob` that is assumed to be valid. /// /// This should ONLY be used for testing. - pub fn __assumed_valid(blob: SignedBlobSidecar) -> Self { + pub fn __assumed_valid(blob: Arc>) -> Self { Self { blob } } pub fn id(&self) -> BlobIdentifier { - self.blob.message.id() + self.blob.id() } pub fn block_root(&self) -> Hash256 { - self.blob.message.block_root - } - pub fn to_blob(self) -> Arc> { - self.blob.message - } - pub fn as_blob(&self) -> &BlobSidecar { - &self.blob.message - } - pub fn signed_blob(&self) -> SignedBlobSidecar { - self.blob.clone() + self.blob.block_root() } pub fn slot(&self) -> Slot { - self.blob.message.slot + self.blob.slot() } pub fn index(&self) -> u64 { - self.blob.message.index + self.blob.index } pub fn kzg_commitment(&self) -> KzgCommitment { - self.blob.message.kzg_commitment + self.blob.kzg_commitment + } + pub fn cloned(&self) -> Arc> { + self.blob.clone() } - pub fn proposer_index(&self) -> u64 { - self.blob.message.proposer_index + pub fn into_inner(self) -> Arc> { + self.blob } } pub fn validate_blob_sidecar_for_gossip( - signed_blob_sidecar: SignedBlobSidecar, + blob_sidecar: Arc>, subnet: u64, chain: &BeaconChain, ) -> Result, GossipBlobError> { - let blob_slot = signed_blob_sidecar.message.slot; - let blob_index = signed_blob_sidecar.message.index; - let block_parent_root = signed_blob_sidecar.message.block_parent_root; - let blob_proposer_index = signed_blob_sidecar.message.proposer_index; - let block_root = signed_blob_sidecar.message.block_root; + let blob_slot = blob_sidecar.slot(); + let blob_index = blob_sidecar.index; + let block_parent_root = blob_sidecar.block_parent_root(); + let blob_proposer_index = blob_sidecar.block_proposer_index(); + let block_root = blob_sidecar.block_root(); let blob_epoch = blob_slot.epoch(T::EthSpec::slots_per_epoch()); // Verify that the blob_sidecar was received on the correct subnet. @@ -213,7 +204,16 @@ pub fn validate_blob_sidecar_for_gossip( }); } - let blob_root = get_blob_root(&signed_blob_sidecar); + // This condition is not possible if we have received the blob from the network + // since we only subscribe to `MaxBlobsPerBlock` subnets over gossip network. + // We include this check only for completeness. + // Getting this error would imply something very wrong with our networking decoding logic. + if blob_index >= T::EthSpec::max_blobs_per_block() as u64 { + return Err(GossipBlobError::InvalidSubnet { + expected: subnet, + received: blob_index, + }); + } // Verify that the sidecar is not from a future slot. let latest_permissible_slot = chain @@ -244,7 +244,7 @@ pub fn validate_blob_sidecar_for_gossip( if chain .observed_blob_sidecars .read() - .is_known(&signed_blob_sidecar.message) + .is_known(&blob_sidecar) .map_err(|e| GossipBlobError::BeaconChainError(e.into()))? { return Err(GossipBlobError::RepeatBlob { @@ -261,9 +261,7 @@ pub fn validate_blob_sidecar_for_gossip( .fork_choice_read_lock() .get_block(&block_parent_root) else { - return Err(GossipBlobError::BlobParentUnknown( - signed_blob_sidecar.message, - )); + return Err(GossipBlobError::BlobParentUnknown(blob_sidecar)); }; if parent_block.slot >= blob_slot { @@ -392,31 +390,6 @@ pub fn validate_blob_sidecar_for_gossip( }); } - // Signature verification - let signature_is_valid = { - let pubkey_cache = chain - .validator_pubkey_cache - .try_read_for(VALIDATOR_PUBKEY_CACHE_LOCK_TIMEOUT) - .ok_or(BeaconChainError::ValidatorPubkeyCacheLockTimeout) - .map_err(GossipBlobError::BeaconChainError)?; - - let pubkey = pubkey_cache - .get(proposer_index) - .ok_or_else(|| GossipBlobError::UnknownValidator(proposer_index as u64))?; - - signed_blob_sidecar.verify_signature( - Some(blob_root), - pubkey, - &fork, - chain.genesis_validators_root, - &chain.spec, - ) - }; - - if !signature_is_valid { - return Err(GossipBlobError::ProposerSignatureInvalid); - } - // Now the signature is valid, store the proposal so we don't accept another blob sidecar // with the same `BlobIdentifier`. // It's important to double-check that the proposer still hasn't been observed so we don't @@ -431,7 +404,7 @@ pub fn validate_blob_sidecar_for_gossip( if chain .observed_blob_sidecars .write() - .observe_sidecar(&signed_blob_sidecar.message) + .observe_sidecar(&blob_sidecar) .map_err(|e| GossipBlobError::BeaconChainError(e.into()))? { return Err(GossipBlobError::RepeatBlob { @@ -441,9 +414,7 @@ pub fn validate_blob_sidecar_for_gossip( }); } - Ok(GossipVerifiedBlob { - blob: signed_blob_sidecar, - }) + Ok(GossipVerifiedBlob { blob: blob_sidecar }) } /// Wrapper over a `BlobSidecar` for which we have completed kzg verification. @@ -478,7 +449,7 @@ impl KzgVerifiedBlob { self.blob.clone() } pub fn block_root(&self) -> Hash256 { - self.blob.block_root + self.blob.block_root() } pub fn blob_index(&self) -> u64 { self.blob.index @@ -537,10 +508,10 @@ pub fn verify_kzg_for_blob_list( /// Returns the canonical root of the given `blob`. /// /// Use this function to ensure that we report the blob hashing time Prometheus metric. -pub fn get_blob_root(blob: &SignedBlobSidecar) -> Hash256 { +pub fn get_blob_root(blob: &BlobSidecar) -> Hash256 { let blob_root_timer = metrics::start_timer(&metrics::BLOCK_PROCESSING_BLOB_ROOT); - let blob_root = blob.message.tree_hash_root(); + let blob_root = blob.tree_hash_root(); metrics::stop_timer(blob_root_timer); diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index 7f1a596ec3c..0752c6671ce 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -682,12 +682,12 @@ impl IntoGossipVerifiedBlockContents for GossipVerifiedB fn inner_block(&self) -> &SignedBeaconBlock { self.0.block.as_block() } - fn inner_blobs(&self) -> Option> { + fn inner_blobs(&self) -> Option> { self.1.as_ref().map(|blobs| { VariableList::from( blobs .into_iter() - .map(GossipVerifiedBlob::signed_blob) + .map(GossipVerifiedBlob::cloned) .collect::>(), ) }) diff --git a/beacon_node/beacon_chain/src/block_verification_types.rs b/beacon_node/beacon_chain/src/block_verification_types.rs index d236e94f939..b5045d10a48 100644 --- a/beacon_node/beacon_chain/src/block_verification_types.rs +++ b/beacon_node/beacon_chain/src/block_verification_types.rs @@ -91,13 +91,6 @@ impl RpcBlock { return Err(AvailabilityCheckError::MissingBlobs); } for (blob, &block_commitment) in blobs.iter().zip(block_commitments.iter()) { - let blob_block_root = blob.block_root; - if blob_block_root != block_root { - return Err(AvailabilityCheckError::InconsistentBlobBlockRoots { - block_root, - blob_block_root, - }); - } let blob_commitment = blob.kzg_commitment; if blob_commitment != block_commitment { return Err(AvailabilityCheckError::KzgCommitmentMismatch { diff --git a/beacon_node/beacon_chain/src/data_availability_checker.rs b/beacon_node/beacon_chain/src/data_availability_checker.rs index a8d077a6d04..069531f1030 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker.rs @@ -221,7 +221,7 @@ impl DataAvailabilityChecker { ) -> Result, AvailabilityCheckError> { // Verify the KZG commitments. let kzg_verified_blob = if let Some(kzg) = self.kzg.as_ref() { - verify_kzg_for_blob(gossip_blob.to_blob(), kzg)? + verify_kzg_for_blob(gossip_blob.into_inner(), kzg)? } else { return Err(AvailabilityCheckError::KzgNotInitialized); }; @@ -310,8 +310,8 @@ impl DataAvailabilityChecker { block_root: Hash256, blob: &GossipVerifiedBlob, ) { - let index = blob.as_blob().index; - let commitment = blob.as_blob().kzg_commitment; + let index = blob.index(); + let commitment = blob.kzg_commitment(); self.processing_cache .write() .entry(block_root) diff --git a/beacon_node/beacon_chain/src/data_availability_checker/error.rs b/beacon_node/beacon_chain/src/data_availability_checker/error.rs index b2979f2bf04..dbee2dc2de7 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/error.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/error.rs @@ -16,10 +16,6 @@ pub enum Error { BlobIndexInvalid(u64), StoreError(store::Error), DecodeError(ssz::DecodeError), - InconsistentBlobBlockRoots { - block_root: Hash256, - blob_block_root: Hash256, - }, ParentStateMissing(Hash256), BlockReplayError(state_processing::BlockReplayError), RebuildingStateCaches(BeaconStateError), @@ -47,8 +43,7 @@ impl Error { Error::Kzg(_) | Error::BlobIndexInvalid(_) | Error::KzgCommitmentMismatch { .. } - | Error::KzgVerificationFailed - | Error::InconsistentBlobBlockRoots { .. } => ErrorCategory::Malicious, + | Error::KzgVerificationFailed => ErrorCategory::Malicious, } } } diff --git a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs index e2eef45d250..3d0adc3de04 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs @@ -125,7 +125,10 @@ impl PendingComponents { for maybe_blob in self.verified_blobs.iter() { if maybe_blob.is_some() { return maybe_blob.as_ref().map(|kzg_verified_blob| { - kzg_verified_blob.as_blob().slot.epoch(T::slots_per_epoch()) + kzg_verified_blob + .as_blob() + .slot() + .epoch(T::slots_per_epoch()) }); } } @@ -421,12 +424,6 @@ impl OverflowLRUCache { // Initial check to ensure all provided blobs have a consistent block root. for blob in kzg_verified_blobs { let blob_block_root = blob.block_root(); - if blob_block_root != block_root { - return Err(AvailabilityCheckError::InconsistentBlobBlockRoots { - block_root, - blob_block_root, - }); - } if let Some(blob_opt) = fixed_blobs.get_mut(blob.blob_index() as usize) { *blob_opt = Some(blob); } @@ -651,7 +648,7 @@ impl OverflowLRUCache { OverflowKey::Blob(_, _) => { KzgVerifiedBlob::::from_ssz_bytes(value_bytes.as_slice())? .as_blob() - .slot + .slot() .epoch(T::EthSpec::slots_per_epoch()) } }; diff --git a/beacon_node/beacon_chain/src/observed_blob_sidecars.rs b/beacon_node/beacon_chain/src/observed_blob_sidecars.rs index 6c2f07ff593..4d609a1fa3e 100644 --- a/beacon_node/beacon_chain/src/observed_blob_sidecars.rs +++ b/beacon_node/beacon_chain/src/observed_blob_sidecars.rs @@ -50,12 +50,12 @@ impl ObservedBlobSidecars { /// This will update `self` so future calls to it indicate that this `blob_sidecar` is known. /// /// The supplied `blob_sidecar` **MUST** have completed proposer signature verification. - pub fn observe_sidecar(&mut self, blob_sidecar: &Arc>) -> Result { + pub fn observe_sidecar(&mut self, blob_sidecar: &BlobSidecar) -> Result { self.sanitize_blob_sidecar(blob_sidecar)?; let did_not_exist = self .items - .entry((blob_sidecar.block_root, blob_sidecar.slot)) + .entry((blob_sidecar.block_root(), blob_sidecar.slot())) .or_insert_with(|| HashSet::with_capacity(T::max_blobs_per_block())) .insert(blob_sidecar.index); @@ -63,23 +63,23 @@ impl ObservedBlobSidecars { } /// Returns `true` if the `blob_sidecar` has already been observed in the cache within the prune window. - pub fn is_known(&self, blob_sidecar: &Arc>) -> Result { + pub fn is_known(&self, blob_sidecar: &BlobSidecar) -> Result { self.sanitize_blob_sidecar(blob_sidecar)?; let is_known = self .items - .get(&(blob_sidecar.block_root, blob_sidecar.slot)) + .get(&(blob_sidecar.block_root(), blob_sidecar.slot())) .map_or(false, |set| set.contains(&blob_sidecar.index)); Ok(is_known) } - fn sanitize_blob_sidecar(&self, blob_sidecar: &Arc>) -> Result<(), Error> { + fn sanitize_blob_sidecar(&self, blob_sidecar: &BlobSidecar) -> Result<(), Error> { if blob_sidecar.index >= T::max_blobs_per_block() as u64 { return Err(Error::InvalidBlobIndex(blob_sidecar.index)); } let finalized_slot = self.finalized_slot; - if finalized_slot > 0 && blob_sidecar.slot <= finalized_slot { + if finalized_slot > 0 && blob_sidecar.slot() <= finalized_slot { return Err(Error::FinalizedBlob { - slot: blob_sidecar.slot, + slot: blob_sidecar.slot(), finalized_slot, }); } @@ -107,8 +107,9 @@ mod tests { fn get_blob_sidecar(slot: u64, block_root: Hash256, index: u64) -> Arc> { let mut blob_sidecar = BlobSidecar::empty(); - blob_sidecar.block_root = block_root; - blob_sidecar.slot = slot.into(); + // TODO(pawan): have a block root setter for tests + // blob_sidecar.block_root = block_root; + blob_sidecar.signed_block_header.message.slot = slot.into(); blob_sidecar.index = index; Arc::new(blob_sidecar) } diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index 7ef98425441..61c103de531 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -617,21 +617,6 @@ pub struct BeaconChainHarness { pub rng: Mutex, } -#[derive(Clone, Debug, Hash, Eq, PartialEq)] -pub struct BlobSignatureKey { - block_root: Hash256, - blob_index: u64, -} - -impl BlobSignatureKey { - pub fn new(block_root: Hash256, blob_index: u64) -> Self { - Self { - block_root, - blob_index, - } - } -} - pub type CommitteeAttestations = Vec<(Attestation, SubnetId)>; pub type HarnessAttestations = Vec<(CommitteeAttestations, Option>)>; @@ -903,10 +888,7 @@ where | SignedBeaconBlock::Altair(_) | SignedBeaconBlock::Merge(_) | SignedBeaconBlock::Capella(_) => (signed_block, None), - SignedBeaconBlock::Deneb(_) => ( - signed_block, - maybe_blob_sidecars.map(|blobs| self.sign_blobs(blobs, &state, proposer_index)), - ), + SignedBeaconBlock::Deneb(_) => (signed_block, maybe_blob_sidecars), }; (block_contents, state) @@ -1028,35 +1010,6 @@ where ) } - /// Sign blobs, and cache their signatures. - pub fn sign_blobs( - &self, - blobs: BlobSidecarList, - state: &BeaconState, - proposer_index: usize, - ) -> SignedSidecarList> { - let signed_blobs: SignedSidecarList> = Vec::from(blobs) - .into_iter() - .map(|blob| { - blob.sign( - &self.validator_keypairs[proposer_index].sk, - &state.fork(), - state.genesis_validators_root(), - &self.spec, - ) - }) - .collect::>() - .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_blobs - } - /// Produces an "unaggregated" attestation for the given `slot` and `index` that attests to /// `beacon_block_root`. The provided `state` should match the `block.state_root` for the /// `block` identified by `beacon_block_root`. @@ -2589,14 +2542,12 @@ pub fn generate_rand_block_and_blobs( .enumerate() { blob_sidecars.push(BlobSidecar { - block_root, index: index as u64, - slot: block.slot(), - block_parent_root: block.parent_root(), - proposer_index: block.message().proposer_index(), blob: blob.clone(), kzg_commitment, kzg_proof, + signed_block_header: block.signed_block_header(), + kzg_commitment_inclusion_proof: block.kzg_commitment_merkle_proof(index).unwrap(), }); } } diff --git a/beacon_node/lighthouse_network/src/types/pubsub.rs b/beacon_node/lighthouse_network/src/types/pubsub.rs index 6cb94022b5e..60fe3748265 100644 --- a/beacon_node/lighthouse_network/src/types/pubsub.rs +++ b/beacon_node/lighthouse_network/src/types/pubsub.rs @@ -9,11 +9,12 @@ use std::boxed::Box; use std::io::{Error, ErrorKind}; use std::sync::Arc; use types::{ - Attestation, AttesterSlashing, EthSpec, ForkContext, ForkName, LightClientFinalityUpdate, - LightClientOptimisticUpdate, ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock, - SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockCapella, - SignedBeaconBlockDeneb, SignedBeaconBlockMerge, SignedBlsToExecutionChange, - SignedContributionAndProof, SignedVoluntaryExit, SubnetId, SyncCommitteeMessage, SyncSubnetId, BlobSidecar, + Attestation, AttesterSlashing, BlobSidecar, EthSpec, ForkContext, ForkName, + LightClientFinalityUpdate, LightClientOptimisticUpdate, ProposerSlashing, + SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, + SignedBeaconBlockCapella, SignedBeaconBlockDeneb, SignedBeaconBlockMerge, + SignedBlsToExecutionChange, SignedContributionAndProof, SignedVoluntaryExit, SubnetId, + SyncCommitteeMessage, SyncSubnetId, }; #[derive(Debug, Clone, PartialEq)] @@ -21,7 +22,7 @@ pub enum PubsubMessage { /// Gossipsub message providing notification of a new block. BeaconBlock(Arc>), /// Gossipsub message providing notification of a [`BlobSidecar`] along with the subnet id where it was received. - BlobSidecar(Box<(u64, BlobSidecar)>), + BlobSidecar(Box<(u64, Arc>)>), /// Gossipsub message providing notification of a Aggregate attestation and associated proof. AggregateAndProofAttestation(Box>), /// Gossipsub message providing notification of a raw un-aggregated attestation with its shard id. @@ -204,8 +205,10 @@ impl PubsubMessage { GossipKind::BlobSidecar(blob_index) => { match fork_context.from_context_bytes(gossip_topic.fork_digest) { Some(ForkName::Deneb) => { - let blob_sidecar = BlobSidecar::from_ssz_bytes(data) - .map_err(|e| format!("{:?}", e))?; + let blob_sidecar = Arc::new( + BlobSidecar::from_ssz_bytes(data) + .map_err(|e| format!("{:?}", e))?, + ); Ok(PubsubMessage::BlobSidecar(Box::new(( *blob_index, blob_sidecar, @@ -318,7 +321,8 @@ impl std::fmt::Display for PubsubMessage { PubsubMessage::BlobSidecar(data) => write!( f, "BlobSidecar: slot: {}, blob index: {}", - data.1.slot(), data.1.index, + data.1.slot(), + data.1.index, ), PubsubMessage::AggregateAndProofAttestation(att) => write!( f, diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 2f7c6891e4c..e88764b4aa2 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -98,6 +98,14 @@ impl<'a, T: EthSpec, Payload: AbstractExecPayload> BeaconBlockBodyRef<'a, T, Self::Deneb(body) => Ok(Payload::Ref::from(&body.execution_payload)), } } + + /// Produces the proof of inclusion for a `KzgCommitment` in `self`. + pub fn kzg_commitment_merkle_proof( + &self, + _index: usize, + ) -> Option> { + todo!() + } } impl<'a, T: EthSpec, Payload: AbstractExecPayload> BeaconBlockBodyRef<'a, T, Payload> { diff --git a/consensus/types/src/blob_sidecar.rs b/consensus/types/src/blob_sidecar.rs index cf681b9ab1f..c4e52d8056f 100644 --- a/consensus/types/src/blob_sidecar.rs +++ b/consensus/types/src/blob_sidecar.rs @@ -104,8 +104,6 @@ impl From> for BlindedBlobSidecar { } } - - impl PartialOrd for BlobSidecar { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) @@ -135,6 +133,14 @@ impl BlobSidecar { self.signed_block_header.message.tree_hash_root() } + pub fn block_parent_root(&self) -> Hash256 { + self.signed_block_header.message.parent_root + } + + pub fn block_proposer_index(&self) -> u64 { + self.signed_block_header.message.proposer_index + } + pub fn empty() -> Self { Self { index: 0, diff --git a/consensus/types/src/eth_spec.rs b/consensus/types/src/eth_spec.rs index 412b1e7d671..17baad9c4c7 100644 --- a/consensus/types/src/eth_spec.rs +++ b/consensus/types/src/eth_spec.rs @@ -2,11 +2,11 @@ use crate::*; use safe_arith::SafeArith; use serde::{Deserialize, Serialize}; -use ssz_types::typenum::{U17, U9}; use ssz_types::typenum::{ bit::B0, UInt, Unsigned, U0, U1024, U1048576, U1073741824, U1099511627776, U128, U131072, U16, U16777216, U2, U2048, U256, U32, U4, U4096, U512, U6, U625, U64, U65536, U8, U8192, }; +use ssz_types::typenum::{U17, U9}; use std::fmt::{self, Debug}; use std::str::FromStr; diff --git a/consensus/types/src/sidecar.rs b/consensus/types/src/sidecar.rs index 2a781ba11b0..71bd6ec3281 100644 --- a/consensus/types/src/sidecar.rs +++ b/consensus/types/src/sidecar.rs @@ -165,7 +165,8 @@ impl Sidecar for BlindedBlobSidecar { let kzg_proof = kzg_proofs.get(blob_index).ok_or(format!( "Missing KZG proof for slot {} blob index: {}", - block.slot(), blob_index + block.slot(), + blob_index ))?; Ok(Arc::new(BlindedBlobSidecar { diff --git a/consensus/types/src/signed_beacon_block.rs b/consensus/types/src/signed_beacon_block.rs index a58d3dc52d9..559d6c126ce 100644 --- a/consensus/types/src/signed_beacon_block.rs +++ b/consensus/types/src/signed_beacon_block.rs @@ -230,7 +230,7 @@ impl> SignedBeaconBlock &self, _index: usize, ) -> Option> { - todo!() + self.message().body().kzg_commitment_merkle_proof(_index) } /// Convenience accessor for the block's slot.