Skip to content
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
21 changes: 12 additions & 9 deletions mev-rs/src/blinded_block_provider/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
blinded_block_provider::BlindedBlockProvider,
error::Error,
types::{
bellatrix, capella, BidRequest, ExecutionPayload, SignedBlindedBeaconBlock,
bellatrix, capella, deneb, BidRequest, ExecutionPayload, SignedBlindedBeaconBlock,
SignedBuilderBid, SignedValidatorRegistration,
},
};
Expand Down Expand Up @@ -49,14 +49,17 @@ async fn handle_open_bid<B: BlindedBlockProvider>(
State(builder): State<B>,
Json(block): Json<serde_json::Value>,
) -> Result<Json<VersionedValue<ExecutionPayload>>, Error> {
let maybe_capella_block = capella::SignedBlindedBeaconBlock::deserialize(&block);
let mut block = match maybe_capella_block {
Ok(block) => SignedBlindedBeaconBlock::Capella(block),
Err(err) => match bellatrix::SignedBlindedBeaconBlock::deserialize(block) {
Ok(block) => SignedBlindedBeaconBlock::Bellatrix(block),
Err(_) => return Err(ApiClientError::from(err).into()),
},
};
let mut block = deneb::SignedBlindedBlockAndBlobSidecars::deserialize(&block)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is nice!

.map(SignedBlindedBeaconBlock::Deneb)
.or_else(|_| {
capella::SignedBlindedBeaconBlock::deserialize(&block)
.map(SignedBlindedBeaconBlock::Capella)
})
.or_else(|_| {
bellatrix::SignedBlindedBeaconBlock::deserialize(&block)
.map(SignedBlindedBeaconBlock::Bellatrix)
})
.map_err(ApiClientError::from)?;

let payload = builder.open_bid(&mut block).await?;
let block_hash = payload.block_hash();
Expand Down
14 changes: 7 additions & 7 deletions mev-rs/src/types/deneb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use ethereum_consensus::{builder::SignedValidatorRegistration, deneb::mainnet as spec};
use ethereum_consensus::{
deneb::mainnet::MAX_BLOBS_PER_BLOCK,
deneb::mainnet::{MAX_BLOBS_PER_BLOCK, MAX_BLOB_COMMITMENTS_PER_BLOCK},
kzg::{KzgCommitment, KzgProof},
primitives::{BlsPublicKey, BlsSignature, Root, U256},
};
Expand All @@ -26,9 +26,9 @@ pub struct BuilderBid {
#[derive(Debug, Default, Clone, SimpleSerialize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BlindedBlobsBundle {
pub commitments: List<KzgCommitment, MAX_BLOBS_PER_BLOCK>,
pub proofs: List<KzgProof, MAX_BLOBS_PER_BLOCK>,
pub blob_roots: List<Root, MAX_BLOBS_PER_BLOCK>,
pub commitments: List<KzgCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK>,
pub proofs: List<KzgProof, MAX_BLOB_COMMITMENTS_PER_BLOCK>,
pub blob_roots: List<Root, MAX_BLOB_COMMITMENTS_PER_BLOCK>,
}

#[derive(Debug, Default, Clone, SimpleSerialize)]
Expand All @@ -48,9 +48,9 @@ pub struct SignedBlindedBlockAndBlobSidecars {
#[derive(Debug, Default, Clone, SimpleSerialize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BlobsBundle {
pub commitments: List<KzgCommitment, MAX_BLOBS_PER_BLOCK>,
pub proofs: List<KzgProof, MAX_BLOBS_PER_BLOCK>,
pub blobs: List<Blob, MAX_BLOBS_PER_BLOCK>,
pub commitments: List<KzgCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK>,
pub proofs: List<KzgProof, MAX_BLOB_COMMITMENTS_PER_BLOCK>,
pub blobs: List<Blob, MAX_BLOB_COMMITMENTS_PER_BLOCK>,
}

#[derive(Debug, Default, Clone, SimpleSerialize)]
Expand Down