Skip to content

Commit 862c84c

Browse files
committed
fallback
1 parent 8e88e1f commit 862c84c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

crates/common/src/pbs/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ impl PbsError {
4747
_ => false,
4848
}
4949
}
50+
51+
pub fn is_not_found(&self) -> bool {
52+
matches!(&self, PbsError::RelayResponse { code: 404, .. })
53+
}
5054
}
5155

5256
#[derive(Debug, Error, PartialEq, Eq)]

crates/pbs/src/mev_boost/submit_block.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async fn submit_block_with_timeout(
8888
api_version: &BuilderApiVersion,
8989
fork_name: ForkName,
9090
) -> Result<Option<SubmitBlindedBlockResponse>, PbsError> {
91-
let url = relay.submit_block_url(*api_version)?;
91+
let mut url = relay.submit_block_url(*api_version)?;
9292
let mut remaining_timeout_ms = timeout_ms;
9393
let mut retry = 0;
9494
let mut backoff = Duration::from_millis(250);
@@ -121,6 +121,11 @@ async fn submit_block_with_timeout(
121121
}
122122
}
123123

124+
Err(err) if err.is_not_found() && matches!(api_version, BuilderApiVersion::V2) => {
125+
warn!("relay does not support v2 endpoint, retrying with v1");
126+
url = relay.submit_block_url(BuilderApiVersion::V1)?;
127+
}
128+
124129
Err(err) => return Err(err),
125130
};
126131

@@ -184,6 +189,7 @@ async fn send_submit_block(
184189
warn!(relay_id = relay.id.as_ref(), retry, %err, "failed to get payload (this might be ok if other relays have it)");
185190
return Err(err);
186191
};
192+
187193
if api_version != &BuilderApiVersion::V1 {
188194
// v2 response is going to be empty, so just break here
189195
return Ok(None);

0 commit comments

Comments
 (0)