Skip to content

Commit

Permalink
fix(builder): fix flashbots auth signature (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs authored Nov 5, 2024
1 parent da102ee commit cb186ec
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/builder/src/sender/flashbots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,11 @@ impl FlashbotsClient {
}

async fn sign_send_request(&self, body: Value) -> anyhow::Result<Response> {
let to_sign = format!("0x{:x}", utils::keccak256(body.to_string()));

let signature = self
.signer
.sign_hash_sync(&utils::keccak256(body.to_string()))
.sign_message_sync(to_sign.as_bytes())
.expect("Signature failed");
let header_val = HeaderValue::from_str(&format!(
"{:?}:0x{}",
Expand All @@ -340,13 +342,18 @@ impl FlashbotsClient {
headers.insert("x-flashbots-signature", header_val);

// Send the request
self.http_client
let response = self
.http_client
.post(&self.relay_url)
.headers(headers)
.body(body.to_string())
.send()
.await
.map_err(|e| anyhow!("failed to send request to Flashbots: {:?}", e))
.map_err(|e| anyhow!("failed to send request to Flashbots: {:?}", e))?;

response
.error_for_status()
.map_err(|e| anyhow!("Flashbots request failed: {:?}", e))
}
}

Expand Down

0 comments on commit cb186ec

Please sign in to comment.