Skip to content

Commit

Permalink
use BlobTransactionSidecar type for BlobsBundleV1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Aug 29, 2023
1 parent 356905e commit c690fce
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions crates/rpc/rpc-types/src/eth/engine/payload.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::ops::Deref;

use reth_primitives::{
constants::{MAXIMUM_EXTRA_DATA_SIZE, MIN_PROTOCOL_BASE_FEE_U256},
proofs::{self, EMPTY_LIST_HASH},
Expand Down Expand Up @@ -53,7 +51,7 @@ pub struct ExecutionPayloadEnvelope {
pub block_value: U256,
/// The blobs, commitments, and proofs associated with the executed payload.
#[serde(rename = "blobsBundle", skip_serializing_if = "Option::is_none")]
pub blobs_bundle: Option<BlobsBundleV1>,
pub blobs_bundle: Option<BlobTransactionSidecar>,
/// Introduced in V3, this represents a suggestion from the execution layer if the payload
/// should be used instead of an externally provided one.
#[serde(rename = "shouldOverrideBuilder", skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -213,31 +211,6 @@ impl TryFrom<ExecutionPayload> for SealedBlock {
}
}

/// This includes all bundled blob related data of an executed payload.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BlobsBundleV1 {
pub commitments: Vec<Bytes>,
pub proofs: Vec<Bytes>,
pub blobs: Vec<Bytes>,
}

impl From<Vec<BlobTransactionSidecar>> for BlobsBundleV1 {
fn from(sidecars: Vec<BlobTransactionSidecar>) -> Self {
// TODO: either upstream a conversion or upstream QUANTITY serde impls
let (commitments, proofs, blobs) = sidecars.into_iter().fold(
(Vec::new(), Vec::new(), Vec::new()),
|(mut commitments, mut proofs, mut blobs), sidecar| {
commitments
.extend(sidecar.commitments.iter().map(|sidecar| Bytes::from(sidecar.deref())));
proofs.extend(sidecar.proofs.iter().map(|proof| Bytes::from(proof.deref())));
blobs.extend(sidecar.blobs.iter().map(|blob| Bytes::from(blob.deref())));
(commitments, proofs, blobs)
},
);
Self { commitments, proofs, blobs }
}
}

/// Error that can occur when handling payloads.
#[derive(thiserror::Error, Debug)]
pub enum PayloadError {
Expand Down

0 comments on commit c690fce

Please sign in to comment.