Skip to content

Commit

Permalink
chore: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit authored and thedevbirb committed Jul 1, 2024
1 parent 2a59aed commit 5ac37bd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 42 deletions.
8 changes: 4 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 2 additions & 9 deletions bolt-sidecar/bin/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
});

Expand Down
4 changes: 0 additions & 4 deletions bolt-sidecar/src/builder/payload_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)?,
Expand Down
15 changes: 13 additions & 2 deletions bolt-sidecar/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,22 @@ impl TryFrom<Opts> 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();
Expand Down
28 changes: 5 additions & 23 deletions bolt-sidecar/src/primitives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,33 +110,15 @@ impl LocalPayloadFetcher {
#[async_trait::async_trait]
impl PayloadFetcher for LocalPayloadFetcher {
async fn fetch_payload(&self, slot: u64) -> Option<PayloadAndBid> {
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
}
}
Expand Down

0 comments on commit 5ac37bd

Please sign in to comment.