Skip to content

Commit e1d431e

Browse files
authored
Merge pull request #241 from flashbots/msozin/flashblocks-rebase-withdrawals_root-fix
Make withdrawals_root optional
2 parents a010527 + 6945842 commit e1d431e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/flashblocks/inbound.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ impl FlashblocksReceiverService {
4646
let msg = msg?;
4747
match msg {
4848
Message::Text(text) => {
49-
if let Ok(flashblocks_msg) = serde_json::from_str::<FlashblocksPayloadV1>(&text)
50-
// TODO: Version this
51-
{
52-
self.sender.send(flashblocks_msg).await?;
49+
match serde_json::from_str::<FlashblocksPayloadV1>(&text) {
50+
// TODO: Version this
51+
Ok(flashblocks_msg) => self.sender.send(flashblocks_msg).await?,
52+
Err(e) => error!("Failed to parse inbound flashblock: {}", e),
5353
}
5454
}
5555
_ => continue,

src/flashblocks/primitives.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ pub struct ExecutionPayloadFlashblockDeltaV1 {
2626
pub transactions: Vec<Bytes>,
2727
/// Array of [`Withdrawal`] enabled with V2
2828
pub withdrawals: Vec<Withdrawal>,
29+
#[serde(skip_serializing_if = "Option::is_none")]
2930
/// The withdrawals root of the block.
30-
pub withdrawals_root: B256,
31+
pub withdrawals_root: Option<B256>,
3132
}
3233

3334
/// Represents the base configuration of an execution payload that remains constant

src/flashblocks/service.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use thiserror::Error;
1717
use tokio::sync::RwLock;
1818
use tokio::sync::mpsc;
1919
use tracing::error;
20+
2021
#[derive(Debug, Error)]
2122
pub enum FlashblocksError {
2223
#[error("Missing base payload for initial flashblock")]
@@ -29,6 +30,8 @@ pub enum FlashblocksError {
2930
InvalidIndex,
3031
#[error("Missing payload")]
3132
MissingPayload,
33+
#[error("Malformed flashblock")]
34+
MalformedFlashblock,
3235
}
3336

3437
#[derive(Debug, Deserialize, Serialize)]
@@ -158,7 +161,9 @@ impl FlashblockBuilder {
158161
},
159162
should_override_builder: false,
160163
execution_payload: OpExecutionPayloadV4 {
161-
withdrawals_root,
164+
// In version 4 withdrawals_root should be present
165+
withdrawals_root: withdrawals_root
166+
.ok_or(FlashblocksError::MalformedFlashblock)?,
162167
payload_inner: execution_payload,
163168
},
164169
execution_requests: vec![],

0 commit comments

Comments
 (0)