From 42e1f7be2b2b537a4b4bbd6c02ccf293d3cfbdc4 Mon Sep 17 00:00:00 2001 From: nicolas <48695862+merklefruit@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:26:07 +0200 Subject: [PATCH] chore(sidecar): import tracing macros in files --- bolt-client/src/registry.rs | 8 ++--- bolt-kurtosis-client/src/main.rs | 2 +- bolt-sidecar/src/api/builder.rs | 39 +++++++++++---------- bolt-sidecar/src/api/commitments/server.rs | 18 +++++----- bolt-sidecar/src/builder/payload_builder.rs | 20 ++++++----- bolt-sidecar/src/builder/template.rs | 3 +- bolt-sidecar/src/client/commit_boost.rs | 11 +++--- bolt-sidecar/src/client/mevboost.rs | 3 +- bolt-sidecar/src/config/mod.rs | 16 +++++---- bolt-sidecar/src/primitives/mod.rs | 5 +-- bolt-sidecar/src/state/execution.rs | 17 ++++----- bolt-sidecar/src/state/fetcher.rs | 3 +- bolt-sidecar/src/state/head_tracker.rs | 12 ++++--- bolt-sidecar/src/test_util.rs | 3 +- 14 files changed, 86 insertions(+), 74 deletions(-) diff --git a/bolt-client/src/registry.rs b/bolt-client/src/registry.rs index 6e4189f8..429389de 100644 --- a/bolt-client/src/registry.rs +++ b/bolt-client/src/registry.rs @@ -10,6 +10,7 @@ use alloy::{ }; use beacon_api_client::ProposerDuty; use reqwest::Client; +use tracing::info; use url::Url; use BoltRegistryContract::{BoltRegistryContractErrors, BoltRegistryContractInstance, Registrant}; @@ -87,7 +88,7 @@ impl BoltRegistry { Ok(Some(token_raw)) => { next_preconfer_slot = duty.slot; proposer_rpc = token_raw.metadata.rpc; - tracing::info!( + info!( "pre-confirmation will be sent for slot {} to validator with index {} at url {}", duty.slot, duty.validator_index, @@ -99,10 +100,7 @@ impl BoltRegistry { // Handle the case where the result is Ok but contains None. // You might want to continue to the next iteration, log something, or handle it // in another way. - tracing::info!( - "No registrant found for validator index {}", - duty.validator_index - ); + info!("No registrant found for validator index {}", duty.validator_index); continue; } Err(e) => { diff --git a/bolt-kurtosis-client/src/main.rs b/bolt-kurtosis-client/src/main.rs index 36a90d7d..5c2c925f 100644 --- a/bolt-kurtosis-client/src/main.rs +++ b/bolt-kurtosis-client/src/main.rs @@ -40,7 +40,7 @@ struct Opts { #[tokio::main] async fn main() -> Result<()> { tracing_subscriber::fmt::init(); - tracing::info!("starting bolt-spammer"); + info!("starting bolt-spammer"); let opts = Opts::parse(); diff --git a/bolt-sidecar/src/api/builder.rs b/bolt-sidecar/src/api/builder.rs index 791bab5c..b80fe726 100644 --- a/bolt-sidecar/src/api/builder.rs +++ b/bolt-sidecar/src/api/builder.rs @@ -19,6 +19,7 @@ use serde::Deserialize; use std::{sync::Arc, time::Duration}; use thiserror::Error; use tokio::net::TcpListener; +use tracing::{debug, error, info, warn}; use super::spec::{ BuilderApiError, ConstraintsApi, GET_HEADER_PATH, GET_PAYLOAD_PATH, REGISTER_VALIDATORS_PATH, @@ -64,18 +65,18 @@ where /// Gets the status. Just forwards the request to mev-boost and returns the status. pub async fn status(State(server): State>>) -> StatusCode { let start = std::time::Instant::now(); - tracing::debug!("Received status request"); + debug!("Received status request"); let status = match server.proxy_target.status().await { Ok(status) => status, Err(error) => { - tracing::error!(%error, "Failed to get status from mev-boost"); + error!(%error, "Failed to get status from mev-boost"); StatusCode::INTERNAL_SERVER_ERROR } }; let elapsed = start.elapsed(); - tracing::debug!(?elapsed, "Returning status: {:?}", status); + debug!(?elapsed, "Returning status: {:?}", status); status } @@ -89,12 +90,12 @@ where Json(registrations): Json>, ) -> Result { let start = std::time::Instant::now(); - tracing::debug!("Received register validators request"); + debug!("Received register validators request"); let response = server.proxy_target.register_validators(registrations).await; let elapsed = start.elapsed(); - tracing::debug!(?elapsed, "Returning response: {:?}", response); + debug!(?elapsed, "Returning response: {:?}", response); response.map(|_| StatusCode::OK) } @@ -110,7 +111,7 @@ where ) -> Result>, BuilderApiError> { let start = std::time::Instant::now(); - tracing::debug!("Received get_header request"); + debug!("Received get_header request"); let slot = params.slot; let err = match tokio::time::timeout( @@ -128,7 +129,7 @@ where let mut local_payload = server.local_payload.lock(); *local_payload = None; - tracing::debug!(elapsed = ?start.elapsed(), "Returning signed builder bid"); + debug!(elapsed = ?start.elapsed(), "Returning signed builder bid"); return Ok(Json(header)); } }, @@ -136,19 +137,19 @@ where }; // On ANY error, we fall back to locally built block - tracing::warn!(slot, elapsed = ?start.elapsed(), err = ?err, "Proxy error, fetching local payload instead"); + warn!(slot, elapsed = ?start.elapsed(), err = ?err, "Proxy error, fetching local payload instead"); let Some(payload_and_bid) = server.payload_fetcher.fetch_payload(slot).await else { // TODO: handle failure? In this case, we don't have a fallback block // which means we haven't made any commitments. This means the EL should // fallback to local block building. - tracing::debug!("No local payload with commitments produced for slot {slot}"); + debug!("No local payload with commitments produced for slot {slot}"); return Err(BuilderApiError::FailedToFetchLocalPayload(slot)); }; let hash = payload_and_bid.bid.message.header.block_hash.clone(); let number = payload_and_bid.bid.message.header.block_number; - tracing::info!(elapsed = ?start.elapsed(), %hash, "Fetched local payload for slot {slot}"); + info!(elapsed = ?start.elapsed(), %hash, "Fetched local payload for slot {slot}"); { // Since we've signed a local header, set the payload for @@ -163,7 +164,7 @@ where meta: Default::default(), }; - tracing::info!(elapsed = ?start.elapsed(), %hash, number, ?versioned_bid, "Returning locally built header"); + info!(elapsed = ?start.elapsed(), %hash, number, ?versioned_bid, "Returning locally built header"); Ok(Json(versioned_bid)) } @@ -172,18 +173,18 @@ where req: Request, ) -> Result, BuilderApiError> { let start = std::time::Instant::now(); - tracing::debug!("Received get_payload request"); + debug!("Received get_payload request"); let body_bytes = body::to_bytes(req.into_body(), MAX_BLINDED_BLOCK_LENGTH).await.map_err(|e| { - tracing::error!(error = %e, "Failed to read request body"); + error!(error = %e, "Failed to read request body"); e })?; // Convert to signed blinded beacon block let signed_blinded_block = serde_json::from_slice::(&body_bytes) .map_err(|e| { - tracing::error!(error = %e, "Failed to parse signed blinded block"); + error!(error = %e, "Failed to parse signed blinded block"); e })?; @@ -192,7 +193,7 @@ where if let Some(local_payload) = server.local_payload.lock().take() { check_locally_built_payload_integrity(&signed_blinded_block, &local_payload)?; - tracing::debug!("Valid local block found, returning: {local_payload:?}"); + debug!("Valid local block found, returning: {local_payload:?}"); return Ok(Json(local_payload)); } @@ -205,11 +206,11 @@ where .await .map(Json) .map_err(|e| { - tracing::error!(elapsed = ?start.elapsed(), error = %e, "Failed to get payload from mev-boost"); + error!(elapsed = ?start.elapsed(), error = %e, "Failed to get payload from mev-boost"); e })?; - tracing::debug!(elapsed = ?start.elapsed(), "Returning payload"); + debug!(elapsed = ?start.elapsed(), "Returning payload"); Ok(payload) } @@ -232,7 +233,7 @@ pub async fn start_builder_proxy_server

( where P: PayloadFetcher + Send + Sync + 'static, { - tracing::info!( + info!( port = config.server_port, target = config.mevboost_url.to_string(), "Starting builder proxy..." @@ -273,7 +274,7 @@ pub enum LocalPayloadIntegrityError { macro_rules! assert_payload_fields_eq { ($expected:expr, $have:expr, $field_name:ident) => { if $expected != $have { - tracing::error!( + error!( field_name = stringify!($field_name), expected = %$expected, have = %$have, diff --git a/bolt-sidecar/src/api/commitments/server.rs b/bolt-sidecar/src/api/commitments/server.rs index ffd1639e..3894cfe6 100644 --- a/bolt-sidecar/src/api/commitments/server.rs +++ b/bolt-sidecar/src/api/commitments/server.rs @@ -16,7 +16,7 @@ use tokio::{ net::TcpListener, sync::{mpsc, oneshot}, }; -use tracing::error; +use tracing::{debug, error, info, instrument}; use crate::{ common::CARGO_PKG_VERSION, @@ -135,13 +135,13 @@ impl CommitmentsApiServer { let addr = listener.local_addr().expect("Failed to get local address"); self.addr = addr; - tracing::info!("Commitments RPC server bound to {addr}"); + info!("Commitments RPC server bound to {addr}"); let signal = self.signal.take().expect("Signal not set"); tokio::spawn(async move { if let Err(err) = axum::serve(listener, router).with_graceful_shutdown(signal).await { - tracing::error!(?err, "Commitments API Server error"); + error!(?err, "Commitments API Server error"); } }); } @@ -152,16 +152,16 @@ impl CommitmentsApiServer { } /// Handler function for the root JSON-RPC path. - #[tracing::instrument(skip_all, name = "RPC", fields(method = %payload.method))] + #[instrument(skip_all, name = "RPC", fields(method = %payload.method))] async fn handle_rpc( headers: HeaderMap, State(api): State>, WithRejection(Json(payload), _): WithRejection, Error>, ) -> Result, Error> { - tracing::debug!("Received new request"); + debug!("Received new request"); let (signer, signature) = auth_from_headers(&headers).inspect_err(|e| { - tracing::error!("Failed to extract signature from headers: {:?}", e); + error!("Failed to extract signature from headers: {:?}", e); })?; match payload.method.as_str() { @@ -190,7 +190,7 @@ impl CommitmentsApiServer { let recovered_signer = signature.recover_address_from_prehash(&digest)?; if recovered_signer != signer { - tracing::error!( + error!( ?recovered_signer, ?signer, "Recovered signer does not match the provided signer" @@ -202,7 +202,7 @@ impl CommitmentsApiServer { // Set the request signer inclusion_request.set_signer(recovered_signer); - tracing::info!(signer = ?recovered_signer, %digest, "New valid inclusion request received"); + info!(signer = ?recovered_signer, %digest, "New valid inclusion request received"); let inclusion_commitment = api.request_inclusion(inclusion_request).await?; // Create the JSON-RPC response @@ -215,7 +215,7 @@ impl CommitmentsApiServer { Ok(Json(response)) } other => { - tracing::error!("Unknown method: {}", other); + error!("Unknown method: {}", other); Err(Error::UnknownMethod) } } diff --git a/bolt-sidecar/src/builder/payload_builder.rs b/bolt-sidecar/src/builder/payload_builder.rs index 180b4da4..a904605c 100644 --- a/bolt-sidecar/src/builder/payload_builder.rs +++ b/bolt-sidecar/src/builder/payload_builder.rs @@ -15,6 +15,7 @@ use reth_primitives::{ }; use reth_rpc_layer::{secret_to_bearer_header, JwtSecret}; use serde_json::Value; +use tracing::{debug, info, trace, warn}; use super::{ compat::{to_alloy_execution_payload, to_reth_withdrawal}, @@ -106,7 +107,7 @@ impl FallbackPayloadBuilder { ) -> Result { // TODO: what if the latest block ends up being reorged out? let latest_block = self.execution_rpc_client.get_block(None, true).await?; - tracing::debug!(num = ?latest_block.header.number, "got latest block"); + debug!(num = ?latest_block.header.number, "got latest block"); let withdrawals = self .beacon_api_client @@ -117,7 +118,7 @@ impl FallbackPayloadBuilder { .map(to_reth_withdrawal) .collect::>(); - tracing::debug!(amount = ?withdrawals.len(), "got withdrawals"); + debug!(amount = ?withdrawals.len(), "got withdrawals"); // let prev_randao = self // .beacon_api_client @@ -138,18 +139,18 @@ impl FallbackPayloadBuilder { .unwrap(); let prev_randao = prev_randao.pointer("/data/randao").unwrap().as_str().unwrap(); let prev_randao = B256::from_hex(prev_randao).unwrap(); - tracing::debug!("got prev_randao"); + debug!("got prev_randao"); let parent_beacon_block_root = self.beacon_api_client.get_beacon_block_root(BlockId::Head).await?; - tracing::debug!(parent = ?parent_beacon_block_root, "got parent_beacon_block_root"); + debug!(parent = ?parent_beacon_block_root, "got parent_beacon_block_root"); let versioned_hashes = transactions .iter() .flat_map(|tx| tx.blob_versioned_hashes()) .flatten() .collect::>(); - tracing::info!(amount = ?versioned_hashes.len(), "got versioned_hashes"); + info!(amount = ?versioned_hashes.len(), "got versioned_hashes"); let base_fee = calc_next_block_base_fee( latest_block.header.gas_used, @@ -204,11 +205,11 @@ impl FallbackPayloadBuilder { .fetch_next_payload_hint(&exec_payload, &versioned_hashes, parent_beacon_block_root) .await?; - tracing::debug!("engine_hint: {:?}", engine_hint); + debug!("engine_hint: {:?}", engine_hint); match engine_hint { EngineApiHint::BlockHash(hash) => { - tracing::warn!("Should not receive block hash hint {:?}", hash); + warn!("Should not receive block hash hint {:?}", hash); hints.block_hash = Some(hash) } @@ -306,7 +307,7 @@ impl EngineHinter { } }; - tracing::trace!("raw hint: {:?}", raw_hint); + trace!("raw hint: {:?}", raw_hint); // Match the hint value to the corresponding header field and return it if raw_hint.contains("blockhash mismatch") { @@ -401,6 +402,7 @@ mod tests { signers::{k256::ecdsa::SigningKey, local::PrivateKeySigner}, }; use reth_primitives::TransactionSigned; + use tracing::warn; use crate::{ builder::payload_builder::FallbackPayloadBuilder, @@ -412,7 +414,7 @@ mod tests { let _ = tracing_subscriber::fmt::try_init(); let Some(cfg) = get_test_config().await else { - tracing::warn!("Skipping test: missing test config"); + warn!("Skipping test: missing test config"); return Ok(()); }; diff --git a/bolt-sidecar/src/builder/template.rs b/bolt-sidecar/src/builder/template.rs index 81ab0576..4b396081 100644 --- a/bolt-sidecar/src/builder/template.rs +++ b/bolt-sidecar/src/builder/template.rs @@ -12,6 +12,7 @@ use ethereum_consensus::{ deneb::mainnet::{Blob, BlobsBundle}, }; use reth_primitives::TransactionSigned; +use tracing::warn; use crate::{ common::max_transaction_cost, @@ -188,7 +189,7 @@ impl BlockTemplate { if state.balance < max_total_cost || state.transaction_count > min_nonce { // Remove invalidated constraints due to balance / nonce of chain state - tracing::warn!( + warn!( %address, "Removing invalidated constraints for address" ); diff --git a/bolt-sidecar/src/client/commit_boost.rs b/bolt-sidecar/src/client/commit_boost.rs index 43da721e..42168b4a 100644 --- a/bolt-sidecar/src/client/commit_boost.rs +++ b/bolt-sidecar/src/client/commit_boost.rs @@ -6,6 +6,7 @@ use cb_crypto::types::SignRequest; use ethereum_consensus::ssz::prelude::ssz_rs; use parking_lot::RwLock; use thiserror::Error; +use tracing::{debug, error, info}; use crate::crypto::bls::SignerBLSAsync; @@ -53,12 +54,12 @@ impl CommitBoostClient { loop { let url = self.url_from_path(PUBKEYS_PATH); - tracing::info!(url, "Loading public keys from commit-boost"); + info!(url, "Loading public keys from commit-boost"); let response = match self.client.get(url).send().await { Ok(res) => res, Err(e) => { - tracing::error!(err = ?e, "failed to get public keys from commit-boost, retrying..."); + error!(err = ?e, "failed to get public keys from commit-boost, retrying..."); tokio::time::sleep(std::time::Duration::from_secs(5)).await; continue; } @@ -69,7 +70,7 @@ impl CommitBoostClient { if !status.is_success() { let err = String::from_utf8_lossy(&response_bytes).into_owned(); - tracing::error!(err, ?status, "failed to get public keys, retrying..."); + error!(err, ?status, "failed to get public keys, retrying..."); tokio::time::sleep(std::time::Duration::from_secs(5)).await; continue; } @@ -112,7 +113,7 @@ impl SignerBLSAsync for CommitBoostClient { let url = self.url_from_path(SIGN_REQUEST_PATH); - tracing::debug!(url, ?request, "Requesting signature from commit_boost"); + debug!(url, ?request, "Requesting signature from commit_boost"); let response = reqwest::Client::new().post(url).json(&request).send().await?; @@ -121,7 +122,7 @@ impl SignerBLSAsync for CommitBoostClient { if !status.is_success() { let err = String::from_utf8_lossy(&response_bytes).into_owned(); - tracing::error!(err, "failed to get signature"); + error!(err, "failed to get signature"); return Err(eyre::eyre!(CommitBoostError::NoSignature(err))); } diff --git a/bolt-sidecar/src/client/mevboost.rs b/bolt-sidecar/src/client/mevboost.rs index 9c77c48e..ae7ce070 100644 --- a/bolt-sidecar/src/client/mevboost.rs +++ b/bolt-sidecar/src/client/mevboost.rs @@ -8,6 +8,7 @@ use ethereum_consensus::{ builder::SignedValidatorRegistration, deneb::mainnet::SignedBlindedBeaconBlock, Fork, }; use reqwest::Url; +use tracing::error; use crate::{ api::{ @@ -38,7 +39,7 @@ impl MevBoostClient { fn endpoint(&self, path: &str) -> Url { self.url.join(path).unwrap_or_else(|e| { - tracing::error!(err = ?e, "Failed to join path: {} with url: {}", path, self.url); + error!(err = ?e, "Failed to join path: {} with url: {}", path, self.url); self.url.clone() }) } diff --git a/bolt-sidecar/src/config/mod.rs b/bolt-sidecar/src/config/mod.rs index e2733630..7951aaa1 100644 --- a/bolt-sidecar/src/config/mod.rs +++ b/bolt-sidecar/src/config/mod.rs @@ -3,8 +3,10 @@ use std::{fs::read_to_string, path::Path, str::FromStr}; use alloy::primitives::Address; use blst::min_pk::SecretKey; use clap::Parser; +use eyre::{bail, eyre, Report, Result}; use reqwest::Url; use std::num::NonZero; +use tracing::info; use crate::crypto::bls::random_bls_secret; @@ -154,14 +156,14 @@ impl Default for Limits { impl Config { /// Parse the command-line options and return a new [`Config`] instance - pub fn parse_from_cli() -> eyre::Result { + pub fn parse_from_cli() -> Result { let opts = Opts::parse(); Self::try_from(opts) } } impl TryFrom for Config { - type Error = eyre::Report; + type Error = Report; fn try_from(opts: Opts) -> Result { let mut config = Config::default(); @@ -184,7 +186,7 @@ impl TryFrom for Config { config.private_key = if let Some(sk) = opts.signing.private_key { let hex_sk = sk.strip_prefix("0x").unwrap_or(&sk); let sk = SecretKey::from_bytes(&hex::decode(hex_sk)?) - .map_err(|e| eyre::eyre!("Failed decoding BLS signer secret key: {:?}", e))?; + .map_err(|e| eyre!("Failed decoding BLS signer secret key: {:?}", e))?; Some(sk) } else { None @@ -193,7 +195,7 @@ impl TryFrom for Config { if let Some(builder_sk) = opts.builder_private_key { let hex_sk = builder_sk.strip_prefix("0x").unwrap_or(&builder_sk); let sk = SecretKey::from_bytes(&hex::decode(hex_sk)?) - .map_err(|e| eyre::eyre!("Failed decoding BLS builder secret key: {:?}", e))?; + .map_err(|e| eyre!("Failed decoding BLS builder secret key: {:?}", e))?; config.builder_private_key = sk; } @@ -201,7 +203,7 @@ impl TryFrom for Config { opts.jwt_hex.trim_start_matches("0x").to_string() } else if Path::new(&opts.jwt_hex).exists() { read_to_string(opts.jwt_hex) - .map_err(|e| eyre::eyre!("Failed reading JWT secret file: {:?}", e))? + .map_err(|e| eyre!("Failed reading JWT secret file: {:?}", e))? .trim_start_matches("0x") .to_string() } else { @@ -210,9 +212,9 @@ impl TryFrom for Config { // Validate the JWT secret if config.jwt_hex.len() != 64 { - eyre::bail!("Engine JWT secret must be a 32 byte hex string"); + bail!("Engine JWT secret must be a 32 byte hex string"); } else { - tracing::info!("Engine JWT secret loaded successfully"); + info!("Engine JWT secret loaded successfully"); } config.mevboost_proxy_port = opts.mevboost_proxy_port; diff --git a/bolt-sidecar/src/primitives/mod.rs b/bolt-sidecar/src/primitives/mod.rs index 85b2a2b1..990f3936 100644 --- a/bolt-sidecar/src/primitives/mod.rs +++ b/bolt-sidecar/src/primitives/mod.rs @@ -31,6 +31,7 @@ pub use commitment::{CommitmentRequest, InclusionRequest}; /// for validation. pub mod constraint; pub use constraint::{BatchedSignedConstraints, ConstraintsMessage, SignedConstraints}; +use tracing::{error, info}; /// An alias for a Beacon Chain slot number pub type Slot = u64; @@ -125,7 +126,7 @@ impl PayloadFetcher for LocalPayloadFetcher { match response_rx.await { Ok(res) => res, Err(e) => { - tracing::error!(err = ?e, "Failed to fetch payload"); + error!(err = ?e, "Failed to fetch payload"); None } } @@ -143,7 +144,7 @@ pub struct NoopPayloadFetcher; #[async_trait::async_trait] impl PayloadFetcher for NoopPayloadFetcher { async fn fetch_payload(&self, slot: u64) -> Option { - tracing::info!(slot, "Fetch payload called"); + info!(slot, "Fetch payload called"); None } } diff --git a/bolt-sidecar/src/state/execution.rs b/bolt-sidecar/src/state/execution.rs index 0de53fed..3c3b60b5 100644 --- a/bolt-sidecar/src/state/execution.rs +++ b/bolt-sidecar/src/state/execution.rs @@ -8,6 +8,7 @@ use reth_primitives::{ }; use std::{collections::HashMap, ops::Deref}; use thiserror::Error; +use tracing::{debug, trace}; use crate::{ builder::BlockTemplate, @@ -255,7 +256,7 @@ impl ExecutionState { let max_basefee = calculate_max_basefee(self.basefee, slot_diff) .ok_or(ValidationError::MaxBaseFeeCalcOverflow)?; - tracing::debug!(%slot_diff, basefee = self.basefee, %max_basefee, "Validating basefee"); + debug!(%slot_diff, basefee = self.basefee, %max_basefee, "Validating basefee"); // Validate the base fee if !req.validate_basefee(max_basefee) { @@ -263,7 +264,7 @@ impl ExecutionState { } if target_slot < self.slot { - tracing::debug!(%target_slot, %self.slot, "Target slot lower than current slot"); + debug!(%target_slot, %self.slot, "Target slot lower than current slot"); return Err(ValidationError::SlotTooLow(self.slot)); } @@ -306,11 +307,11 @@ impl ExecutionState { ); if target_slot < highest_slot_for_account { - tracing::debug!(%target_slot, %highest_slot_for_account, "There is a request for a higher slot"); + debug!(%target_slot, %highest_slot_for_account, "There is a request for a higher slot"); return Err(ValidationError::SlotTooLow(highest_slot_for_account)); } - tracing::trace!(?signer, nonce_diff, %balance_diff, "Applying diffs to account state"); + trace!(?signer, nonce_diff, %balance_diff, "Applying diffs to account state"); let account_state = match self.account_state(&sender).copied() { Some(account) => account, @@ -331,7 +332,7 @@ impl ExecutionState { } }; - tracing::debug!(?account_state, ?nonce_diff, ?balance_diff, "Validating transaction"); + debug!(?account_state, ?nonce_diff, ?balance_diff, "Validating transaction"); let sender_nonce_diff = bundle_nonce_diff_map.entry(sender).or_insert(0); let sender_balance_diff = bundle_balance_diff_map.entry(sender).or_insert(U256::ZERO); @@ -372,7 +373,7 @@ impl ExecutionState { let max_blob_basefee = calculate_max_basefee(self.blob_basefee, slot_diff) .ok_or(ValidationError::MaxBaseFeeCalcOverflow)?; - tracing::debug!(%max_blob_basefee, blob_basefee = blob_transaction.transaction.max_fee_per_blob_gas, "Validating blob basefee"); + debug!(%max_blob_basefee, blob_basefee = blob_transaction.transaction.max_fee_per_blob_gas, "Validating blob basefee"); if blob_transaction.transaction.max_fee_per_blob_gas < max_blob_basefee { return Err(ValidationError::BlobBaseFeeTooLow(max_blob_basefee)); } @@ -414,7 +415,7 @@ impl ExecutionState { let accounts = self.account_states.keys().collect::>(); let update = self.client.get_state_update(accounts, block_number).await?; - tracing::trace!(%slot, ?update, "Applying execution state update"); + trace!(%slot, ?update, "Applying execution state update"); self.apply_state_update(update); @@ -440,7 +441,7 @@ impl ExecutionState { /// diffs. fn refresh_templates(&mut self) { for (address, account_state) in self.account_states.iter_mut() { - tracing::trace!(%address, ?account_state, "Refreshing template..."); + trace!(%address, ?account_state, "Refreshing template..."); // Iterate over all block templates and apply the state diff for (_, template) in self.block_templates.iter_mut() { // Retain only signed constraints where transactions are still valid based on the diff --git a/bolt-sidecar/src/state/fetcher.rs b/bolt-sidecar/src/state/fetcher.rs index 114a143b..4576296c 100644 --- a/bolt-sidecar/src/state/fetcher.rs +++ b/bolt-sidecar/src/state/fetcher.rs @@ -11,6 +11,7 @@ use alloy::{ }; use futures::{stream::FuturesOrdered, StreamExt}; use reqwest::Url; +use tracing::error; use crate::{client::rpc::RpcClient, primitives::AccountState}; @@ -197,7 +198,7 @@ impl StateFetcher for StateClient { return Err(e); } - tracing::error!(error = ?e, "Error getting account state, retrying..."); + error!(error = ?e, "Error getting account state, retrying..."); tokio::time::sleep(self.retry_backoff).await; } } diff --git a/bolt-sidecar/src/state/head_tracker.rs b/bolt-sidecar/src/state/head_tracker.rs index c828237c..3ca48ff5 100644 --- a/bolt-sidecar/src/state/head_tracker.rs +++ b/bolt-sidecar/src/state/head_tracker.rs @@ -4,6 +4,7 @@ use alloy::rpc::types::beacon::events::HeadEvent; use beacon_api_client::Topic; use futures::StreamExt; use tokio::{sync::broadcast, task::AbortHandle}; +use tracing::warn; use crate::BeaconClient; @@ -42,7 +43,7 @@ impl HeadTracker { let mut event_stream = match beacon_client.get_events::().await { Ok(events) => events, Err(err) => { - tracing::warn!(?err, "failed to subscribe to new heads topic, retrying..."); + warn!(?err, "failed to subscribe to new heads topic, retrying..."); tokio::time::sleep(Duration::from_secs(1)).await; continue; } @@ -51,19 +52,19 @@ impl HeadTracker { let event = match event_stream.next().await { Some(Ok(event)) => event, Some(Err(err)) => { - tracing::warn!(?err, "error reading new head event stream, retrying..."); + warn!(?err, "error reading new head event stream, retrying..."); tokio::time::sleep(Duration::from_secs(1)).await; continue; } None => { - tracing::warn!("new head event stream ended, retrying..."); + warn!("new head event stream ended, retrying..."); tokio::time::sleep(Duration::from_secs(1)).await; continue; } }; if let Err(err) = new_heads_tx.send(event) { - tracing::warn!(?err, "failed to broadcast new head event to subscribers"); + warn!(?err, "failed to broadcast new head event to subscribers"); } } }); @@ -93,6 +94,7 @@ impl HeadTracker { #[cfg(test)] mod tests { use reqwest::Url; + use tracing::warn; use crate::{ state::head_tracker::HeadTracker, test_util::try_get_beacon_api_url, BeaconClient, @@ -103,7 +105,7 @@ mod tests { let _ = tracing_subscriber::fmt::try_init(); let Some(url) = try_get_beacon_api_url().await else { - tracing::warn!("skipping test: beacon API URL is not reachable"); + warn!("skipping test: beacon API URL is not reachable"); return Ok(()); }; diff --git a/bolt-sidecar/src/test_util.rs b/bolt-sidecar/src/test_util.rs index 9765cefe..59660ab7 100644 --- a/bolt-sidecar/src/test_util.rs +++ b/bolt-sidecar/src/test_util.rs @@ -13,6 +13,7 @@ use alloy_node_bindings::{Anvil, AnvilInstance}; use blst::min_pk::SecretKey; use reth_primitives::PooledTransactionsElement; use secp256k1::Message; +use tracing::warn; use crate::{ crypto::{ecdsa::SignableECDSA, SignableBLS}, @@ -74,7 +75,7 @@ pub(crate) async fn get_test_config() -> Option { let _ = dotenvy::dotenv(); let Some(jwt) = std::env::var("ENGINE_JWT").ok() else { - tracing::warn!("ENGINE_JWT not found in environment variables"); + warn!("ENGINE_JWT not found in environment variables"); return None; };