From cb186ec5e20f0f119dc95cb670ec01bedc92cbb0 Mon Sep 17 00:00:00 2001 From: Dan Coombs Date: Tue, 5 Nov 2024 09:25:49 -0600 Subject: [PATCH] fix(builder): fix flashbots auth signature (#899) --- crates/builder/src/sender/flashbots.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/builder/src/sender/flashbots.rs b/crates/builder/src/sender/flashbots.rs index 9ebf966e5..fe2669778 100644 --- a/crates/builder/src/sender/flashbots.rs +++ b/crates/builder/src/sender/flashbots.rs @@ -324,9 +324,11 @@ impl FlashbotsClient { } async fn sign_send_request(&self, body: Value) -> anyhow::Result { + 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{}", @@ -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)) } }