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
4 changes: 4 additions & 0 deletions crates/common/src/pbs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ impl PbsError {
_ => false,
}
}

pub fn is_not_found(&self) -> bool {
matches!(&self, PbsError::RelayResponse { code: 404, .. })
}
}

#[derive(Debug, Error, PartialEq, Eq)]
Expand Down
18 changes: 17 additions & 1 deletion crates/pbs/src/mev_boost/submit_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async fn submit_block_with_timeout(
api_version: &BuilderApiVersion,
fork_name: ForkName,
) -> Result<Option<SubmitBlindedBlockResponse>, PbsError> {
let url = relay.submit_block_url(*api_version)?;
let mut url = relay.submit_block_url(*api_version)?;
let mut remaining_timeout_ms = timeout_ms;
let mut retry = 0;
let mut backoff = Duration::from_millis(250);
Expand Down Expand Up @@ -121,6 +121,14 @@ async fn submit_block_with_timeout(
}
}

Err(err) if err.is_not_found() && matches!(api_version, BuilderApiVersion::V2) => {
warn!(
relay_id = relay.id.as_ref(),
"relay does not support v2 endpoint, retrying with v1"
);
url = relay.submit_block_url(BuilderApiVersion::V1)?;
}

Err(err) => return Err(err),
};

Expand Down Expand Up @@ -184,8 +192,16 @@ async fn send_submit_block(
warn!(relay_id = relay.id.as_ref(), retry, %err, "failed to get payload (this might be ok if other relays have it)");
return Err(err);
};

if api_version != &BuilderApiVersion::V1 {
// v2 response is going to be empty, so just break here
debug!(
relay_id = relay.id.as_ref(),
retry,
latency = ?request_latency,
"successful request"
);

return Ok(None);
}

Expand Down