From 5ac37bd48150ea7de308cf1e868c03895b6a1bc6 Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:58:23 +0200 Subject: [PATCH] chore: minor changes --- Justfile | 8 +++--- bolt-sidecar/bin/sidecar.rs | 11 ++------ bolt-sidecar/src/builder/payload_builder.rs | 4 --- bolt-sidecar/src/config.rs | 15 +++++++++-- bolt-sidecar/src/primitives/mod.rs | 28 ++++----------------- 5 files changed, 24 insertions(+), 42 deletions(-) diff --git a/Justfile b/Justfile index 0ae5d272..43fc8063 100644 --- a/Justfile +++ b/Justfile @@ -109,19 +109,19 @@ build-images: # build the docker image for the bolt builder _build-builder: - cd builder && docker build -t ghcr.io/chainbound/bolt-builder:0.1.0 . + cd builder && docker buildx build -t ghcr.io/chainbound/bolt-builder:0.1.0 . # build the docker image for the bolt relay _build-relay: - cd mev-boost-relay && docker build -t ghcr.io/chainbound/bolt-relay:0.1.0 . + cd mev-boost-relay && docker buildx build -t ghcr.io/chainbound/bolt-relay:0.1.0 . # build the docker image for the bolt sidecar _build-sidecar: - cd bolt-sidecar && docker build -t ghcr.io/chainbound/bolt-sidecar:0.1.0 . + cd bolt-sidecar && docker buildx build -t ghcr.io/chainbound/bolt-sidecar:0.1.0 . # build the docker image for the bolt mev-boost sidecar _build-mevboost: - cd mev-boost && docker build -t ghcr.io/chainbound/bolt-mev-boost:0.1.0 . + cd mev-boost && docker buildx build -t ghcr.io/chainbound/bolt-mev-boost:0.1.0 . # push all the docker images to the private github container registry _push-images: diff --git a/bolt-sidecar/bin/sidecar.rs b/bolt-sidecar/bin/sidecar.rs index 37af2489..f80660dc 100644 --- a/bolt-sidecar/bin/sidecar.rs +++ b/bolt-sidecar/bin/sidecar.rs @@ -53,8 +53,6 @@ async fn main() -> eyre::Result<()> { let (payload_tx, mut payload_rx) = mpsc::channel(16); let payload_fetcher = LocalPayloadFetcher::new(payload_tx); - tracing::info!("JWT secret: {}", config.jwt_hex); - let mut local_builder = LocalBuilder::new( BlsSecretKey::try_from(config.builder_private_key.to_bytes().as_ref())?, &config.execution_api_url, @@ -65,13 +63,8 @@ async fn main() -> eyre::Result<()> { ); tokio::spawn(async move { - loop { - if let Err(e) = - start_builder_proxy(payload_fetcher.clone(), builder_proxy_config.clone()).await - { - tracing::error!("Builder API proxy failed: {:?}", e); - tokio::time::sleep(Duration::from_secs(5)).await; - } + if let Err(e) = start_builder_proxy(payload_fetcher, builder_proxy_config).await { + tracing::error!("Builder API proxy failed: {:?}", e); } }); diff --git a/bolt-sidecar/src/builder/payload_builder.rs b/bolt-sidecar/src/builder/payload_builder.rs index 10707e85..3f539e79 100644 --- a/bolt-sidecar/src/builder/payload_builder.rs +++ b/bolt-sidecar/src/builder/payload_builder.rs @@ -201,12 +201,10 @@ impl FallbackPayloadBuilder { let hinted_hash = hints.block_hash.unwrap_or(sealed_block.hash()); let exec_payload = to_alloy_execution_payload(&sealed_block, hinted_hash); - tracing::info!("pre hint fetch"); let engine_hint = self .engine_hinter .fetch_next_payload_hint(&exec_payload, &versioned_hashes, parent_beacon_block_root) .await?; - tracing::info!(hint = ?engine_hint, "post hint fetch"); match engine_hint { EngineApiHint::BlockHash(hash) => hints.block_hash = Some(hash), @@ -278,8 +276,6 @@ impl EngineHinter { let auth_jwt = secret_to_bearer_header(&JwtSecret::from_hex(&self.jwt_hex)?); - tracing::info!("auth_jwt: {:?}", auth_jwt); - let body = format!( r#"{{"id":1,"jsonrpc":"2.0","method":"engine_newPayloadV3","params":[{}, {}, "{:?}"]}}"#, serde_json::to_string(&exec_payload)?, diff --git a/bolt-sidecar/src/config.rs b/bolt-sidecar/src/config.rs index 15f56e4c..74a7aecc 100644 --- a/bolt-sidecar/src/config.rs +++ b/bolt-sidecar/src/config.rs @@ -151,11 +151,22 @@ impl TryFrom for Config { } config.jwt_hex = if opts.jwt_hex.starts_with("0x") { - opts.jwt_hex[2..].to_string() - } else { + opts.jwt_hex.trim_start_matches("0x").to_string() + } else if std::path::Path::new(&opts.jwt_hex).exists() { std::fs::read_to_string(opts.jwt_hex)? + .trim_start_matches("0x") + .to_string() + } else { + opts.jwt_hex }; + // Validate the JWT secret + if config.jwt_hex.len() != 64 { + eyre::bail!("JWT secret must be a 32 byte hex string"); + } else { + tracing::info!("JWT secret loaded successfully"); + } + config.mevboost_proxy_port = opts.mevboost_proxy_port; config.engine_api_url = opts.engine_api_url.trim_end_matches('/').to_string(); config.execution_api_url = opts.execution_api_url.trim_end_matches('/').to_string(); diff --git a/bolt-sidecar/src/primitives/mod.rs b/bolt-sidecar/src/primitives/mod.rs index 0d99277b..56ff1320 100644 --- a/bolt-sidecar/src/primitives/mod.rs +++ b/bolt-sidecar/src/primitives/mod.rs @@ -110,33 +110,15 @@ impl LocalPayloadFetcher { #[async_trait::async_trait] impl PayloadFetcher for LocalPayloadFetcher { async fn fetch_payload(&self, slot: u64) -> Option { - let (tx, rx) = oneshot::channel(); - - let fetch_params = FetchPayloadRequest { - slot, - response_tx: tx, - }; + let (response_tx, response_rx) = oneshot::channel(); + let fetch_params = FetchPayloadRequest { response_tx, slot }; self.tx.send(fetch_params).await.ok()?; - match rx.await { - Ok(Some(payload_and_bid)) => { - tracing::debug!("LocalPayloadFetcher -- fetched payload for slot {}", slot); - Some(payload_and_bid) - } - Ok(None) => { - tracing::warn!( - "LocalPayloadFetcher -- no payload fetched for slot {}", - slot - ); - None - } + match response_rx.await { + Ok(res) => res, Err(e) => { - tracing::error!( - "LocalPayloadFetcher -- error fetching payload for slot {}: {:?}", - slot, - e - ); + tracing::error!(err = ?e, "Failed to fetch payload"); None } }