From fa1cfd0e5b86f41bb546ecd13e028bed6b9faf11 Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:27:57 +0200 Subject: [PATCH] chore: add sidecar url override --- bolt-cli/src/cli.rs | 7 +++++++ bolt-cli/src/commands/send.rs | 11 ++++++++++- bolt-cli/src/common/bolt_manager.rs | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bolt-cli/src/cli.rs b/bolt-cli/src/cli.rs index 287c14465..5657fcb96 100644 --- a/bolt-cli/src/cli.rs +++ b/bolt-cli/src/cli.rs @@ -74,6 +74,13 @@ pub struct SendCommand { /// The private key to sign the transaction with. #[clap(long, env = "PRIVATE_KEY", hide_env_values = true)] pub private_key: String, + + /// The Bolt Sidecar URL to send requests to. If provided, this will override + /// the canonical bolt RPC URL and disregard any registration information. + /// + /// This is useful for testing and development purposes. + #[clap(long, env = "OVERRIDE_BOLT_SIDECAR_URL")] + pub override_bolt_sidecar_url: Option, } /// The action to perform. diff --git a/bolt-cli/src/commands/send.rs b/bolt-cli/src/commands/send.rs index ecfc53134..a076cf474 100644 --- a/bolt-cli/src/commands/send.rs +++ b/bolt-cli/src/commands/send.rs @@ -54,11 +54,20 @@ impl SendCommand { }; let tx_hash = B256::from(keccak256(&raw_tx)); + // Note: it's possible for users to override the target sidecar URL + // for testing and development purposes. In most cases, the sidecar will + // reject a request for a slot that it is not responsible for. + let target_url = if let Some(sidecar_url) = self.override_bolt_sidecar_url { + sidecar_url.clone() + } else { + self.bolt_rpc_url.clone() + }; + send_rpc_request( vec![hex::encode(&raw_tx)], vec![tx_hash], next_preconfirmer_slot, - self.bolt_rpc_url, + target_url, &wallet, ) .await?; diff --git a/bolt-cli/src/common/bolt_manager.rs b/bolt-cli/src/common/bolt_manager.rs index 78550494b..ae4e0a720 100644 --- a/bolt-cli/src/common/bolt_manager.rs +++ b/bolt-cli/src/common/bolt_manager.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] // TODO: rm this + use std::str::FromStr; use alloy::{