remove blob wrapper

This commit is contained in:
realbigsean
2022-11-19 15:18:42 -05:00
parent dfd0013eab
commit 45897ad4e1
21 changed files with 199 additions and 159 deletions

View File

@@ -1,8 +1,8 @@
use std::marker::PhantomData;
use tree_hash::TreeHash;
use types::{
AbstractExecPayload, BeaconState, BeaconStateError, ChainSpec, EthSpec, ExecPayload, Hash256,
SignedBeaconBlock, Slot,
AbstractExecPayload, BeaconState, BeaconStateError, BlobsSidecar, ChainSpec, EthSpec,
ExecPayload, Hash256, SignedBeaconBlock, Slot,
};
#[derive(Debug)]
@@ -13,6 +13,12 @@ pub struct ConsensusContext<T: EthSpec> {
proposer_index: Option<u64>,
/// Block root of the block at `slot`.
current_block_root: Option<Hash256>,
/// Should only be populated if the sidecar has not been validated.
blobs_sidecar: Option<Box<BlobsSidecar<T>>>,
/// Whether `validate_blobs_sidecar` has successfully passed.
blobs_sidecar_validated: bool,
/// Whether `verify_kzg_commitments_against_transactions` has successfully passed.
blobs_verified_vs_txs: bool,
_phantom: PhantomData<T>,
}
@@ -34,6 +40,9 @@ impl<T: EthSpec> ConsensusContext<T> {
slot,
proposer_index: None,
current_block_root: None,
blobs_sidecar: None,
blobs_sidecar_validated: false,
blobs_verified_vs_txs: false,
_phantom: PhantomData,
}
}
@@ -89,4 +98,22 @@ impl<T: EthSpec> ConsensusContext<T> {
})
}
}
pub fn set_blobs_sidecar_validated(mut self, blobs_sidecar_validated: bool) -> Self {
self.blobs_sidecar_validated = blobs_sidecar_validated;
self
}
pub fn set_blobs_verified_vs_txs(mut self, blobs_verified_vs_txs: bool) -> Self {
self.blobs_verified_vs_txs = blobs_verified_vs_txs;
self
}
pub fn blobs_sidecar_validated(&self) -> bool {
self.blobs_sidecar_validated
}
pub fn blobs_verified_vs_txs(&self) -> bool {
self.blobs_verified_vs_txs
}
}

View File

@@ -180,6 +180,9 @@ pub fn per_block_processing<T: EthSpec, Payload: AbstractExecPayload<T>>(
process_blob_kzg_commitments(block.body())?;
//FIXME(sean) add `validate_blobs_sidecar` (is_data_available) and only run it if the consensus
// context tells us it wasnt already run
Ok(())
}

View File

@@ -18,6 +18,7 @@ pub fn process_blob_kzg_commitments<T: EthSpec, Payload: AbstractExecPayload<T>>
block_body.blob_kzg_commitments(),
) {
if let Some(transactions) = payload.transactions() {
//FIXME(sean) only run if this wasn't run in gossip (use consensus context)
if !verify_kzg_commitments_against_transactions::<T>(transactions, kzg_commitments)? {
return Err(BlockProcessingError::BlobVersionHashMismatch);
}

View File

@@ -11,7 +11,7 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
// FIXME(sean) This is a hack to let us participate in testnets where capella doesn't exist.
// if we are disabling withdrawals, assume we should fork off of bellatrix.
let previous_fork_version = if cfg!(feature ="withdrawals") {
let previous_fork_version = if cfg!(feature = "withdrawals") {
pre.fork.current_version
} else {
spec.bellatrix_fork_version

View File

@@ -150,7 +150,6 @@ pub use crate::historical_batch::HistoricalBatch;
pub use crate::indexed_attestation::IndexedAttestation;
pub use crate::kzg_commitment::KzgCommitment;
pub use crate::kzg_proof::KzgProof;
pub use crate::signed_block_and_blobs::SignedBeaconBlockAndBlobsSidecar;
pub use crate::participation_flags::ParticipationFlags;
pub use crate::participation_list::ParticipationList;
pub use crate::payload::{
@@ -172,6 +171,7 @@ pub use crate::signed_beacon_block::{
SignedBlindedBeaconBlock,
};
pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader;
pub use crate::signed_block_and_blobs::SignedBeaconBlockAndBlobsSidecar;
pub use crate::signed_contribution_and_proof::SignedContributionAndProof;
pub use crate::signed_voluntary_exit::SignedVoluntaryExit;
pub use crate::signing_data::{SignedRoot, SigningData};

View File

@@ -1,37 +1,13 @@
use std::sync::Arc;
use serde_derive::{Deserialize, Serialize};
use ssz::{Decode, DecodeError};
use ssz_derive::{Decode, Encode};
use tree_hash_derive::TreeHash;
use crate::{BlobsSidecar, EthSpec, SignedBeaconBlock, SignedBeaconBlockEip4844};
use serde_derive::{Deserialize, Serialize};
use ssz::{Decode, DecodeError, Encode};
use ssz_derive::{Decode, Encode};
use std::sync::Arc;
use tree_hash_derive::TreeHash;
#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq)]
#[serde(bound = "T: EthSpec")]
pub struct SignedBeaconBlockAndBlobsSidecar<T: EthSpec> {
pub beacon_block: SignedBeaconBlock<T>,
pub beacon_block: SignedBeaconBlockEip4844<T>,
pub blobs_sidecar: BlobsSidecar<T>,
}
impl <T: EthSpec>Decode for SignedBeaconBlockAndBlobsSidecar<T> {
fn is_ssz_fixed_len() -> bool {
todo!()
}
fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
todo!()
}
}
pub enum BlockMaybeBlobs<T: EthSpec> {
Block(Arc<SignedBeaconBlock<T>>),
BlockAndBlobs(Arc<SignedBeaconBlockAndBlobsSidecar<T>>),
}
impl <T: EthSpec> BlockMaybeBlobs<T> {
pub fn blobs(&self) -> Option<&BlobsSidecar<T>>{
match self {
Self::Block(_) => None,
Self::BlockAndBlobs(block_and_blobs) => Some(&block_and_blobs.blobs_sidecar)
}
}
}