Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update blob_sidecar type #307

Merged
merged 6 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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