Skip to content

Commit

Permalink
Merge pull request #307 from EchoAlice/blob_sidecar
Browse files Browse the repository at this point in the history
Update blob_sidecar type
  • Loading branch information
ralexstokes authored Nov 5, 2023
2 parents 9e92243 + 12f0ae2 commit 70ed563
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
28 changes: 11 additions & 17 deletions ethereum-consensus/src/deneb/blob_sidecar.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::{
deneb::polynomial_commitments::{KzgCommitment, KzgProof},
primitives::{BlobIndex, BlsSignature, Root, Slot, ValidatorIndex},
deneb::{
polynomial_commitments::{KzgCommitment, KzgProof},
SignedBeaconBlockHeader,
},
primitives::{BlobIndex, Bytes32, Root},
ssz::prelude::*,
};

Expand All @@ -12,26 +15,17 @@ pub type Blob<const BYTES_PER_BLOB: usize> = ByteVector<BYTES_PER_BLOB>;
#[derive(
Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, serde::Serialize, serde::Deserialize,
)]
pub struct BlobSidecar<const BYTES_PER_BLOB: usize> {
pub block_root: Root,
pub struct BlobSidecar<
const BYTES_PER_BLOB: usize,
const KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: usize,
> {
#[serde(with = "crate::serde::as_str")]
pub index: BlobIndex,
#[serde(with = "crate::serde::as_str")]
pub slot: Slot,
pub block_parent_root: Root,
#[serde(with = "crate::serde::as_str")]
pub proposer_index: ValidatorIndex,
pub blob: Blob<BYTES_PER_BLOB>,
pub kzg_commitment: KzgCommitment,
pub kzg_proof: KzgProof,
}

#[derive(
Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, serde::Serialize, serde::Deserialize,
)]
pub struct SignedBlobSidecar<const BYTES_PER_BLOB: usize> {
pub message: BlobSidecar<BYTES_PER_BLOB>,
pub signature: BlsSignature,
pub signed_block_header: SignedBeaconBlockHeader,
pub kzg_commitment_inclusion_proof: Vector<Bytes32, KZG_COMMITMENT_INCLUSION_PROOF_DEPTH>,
}

#[derive(
Expand Down
4 changes: 2 additions & 2 deletions ethereum-consensus/src/deneb/presets/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub use spec::*;
pub const FIELD_ELEMENTS_PER_BLOB: usize = 4096;
pub const MAX_BLOB_COMMITMENTS_PER_BLOCK: usize = 4096;
pub const MAX_BLOBS_PER_BLOCK: usize = 6;
pub const KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: usize = 17;

pub const BYTES_PER_BLOB: usize =
crate::deneb::polynomial_commitments::BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB;
Expand Down Expand Up @@ -149,5 +150,4 @@ pub type SignedBeaconBlock = spec::SignedBeaconBlock<
>;

pub type Blob = spec::Blob<BYTES_PER_BLOB>;
pub type BlobSidecar = spec::BlobSidecar<BYTES_PER_BLOB>;
pub type SignedBlobSidecar = spec::SignedBlobSidecar<BYTES_PER_BLOB>;
pub type BlobSidecar = spec::BlobSidecar<BYTES_PER_BLOB, KZG_COMMITMENT_INCLUSION_PROOF_DEPTH>;
4 changes: 2 additions & 2 deletions ethereum-consensus/src/deneb/presets/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub use spec::*;
pub const FIELD_ELEMENTS_PER_BLOB: usize = 4096;
pub const MAX_BLOB_COMMITMENTS_PER_BLOCK: usize = 16;
pub const MAX_BLOBS_PER_BLOCK: usize = 6;
pub const KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: usize = 9;

pub const BYTES_PER_BLOB: usize =
crate::deneb::polynomial_commitments::BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB;
Expand Down Expand Up @@ -149,5 +150,4 @@ pub type SignedBeaconBlock = spec::SignedBeaconBlock<
>;

pub type Blob = spec::Blob<BYTES_PER_BLOB>;
pub type BlobSidecar = spec::BlobSidecar<BYTES_PER_BLOB>;
pub type SignedBlobSidecar = spec::SignedBlobSidecar<BYTES_PER_BLOB>;
pub type BlobSidecar = spec::BlobSidecar<BYTES_PER_BLOB, KZG_COMMITMENT_INCLUSION_PROOF_DEPTH>;
3 changes: 1 addition & 2 deletions ethereum-consensus/src/deneb/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ pub use crate::{
},
blinded_blob_sidecar::{BlindedBlobSidecar, SignedBlindedBlobSidecar},
blob_sidecar::{
Blob, BlobIdentifier, BlobSidecar, SignedBlobSidecar, BLOB_TX_TYPE,
VERSIONED_HASH_VERSION_KZG,
Blob, BlobIdentifier, BlobSidecar, BLOB_TX_TYPE, VERSIONED_HASH_VERSION_KZG,
},
block_processing::{
process_attestation, process_block, process_execution_payload, process_voluntary_exit,
Expand Down

0 comments on commit 70ed563

Please sign in to comment.