diff --git a/Cargo.lock b/Cargo.lock index 5632ee8498..7412cef79c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10379,6 +10379,7 @@ version = "0.0.0" dependencies = [ "async-trait", "futures", + "infra_utils", "papyrus_config", "papyrus_consensus", "papyrus_consensus_orchestrator", @@ -10456,6 +10457,7 @@ version = "0.0.0" dependencies = [ "axum", "hyper 0.14.30", + "infra_utils", "papyrus_config", "reqwest 0.11.27", "serde", @@ -10667,6 +10669,7 @@ dependencies = [ "assert_matches", "async-trait", "hyper 0.14.30", + "infra_utils", "papyrus_config", "pretty_assertions", "rstest", diff --git a/crates/starknet_consensus_manager/Cargo.toml b/crates/starknet_consensus_manager/Cargo.toml index a6a4c8b16a..7bc5670fa9 100644 --- a/crates/starknet_consensus_manager/Cargo.toml +++ b/crates/starknet_consensus_manager/Cargo.toml @@ -11,6 +11,7 @@ workspace = true [dependencies] async-trait.workspace = true futures.workspace = true +infra_utils.workspace = true papyrus_config.workspace = true papyrus_consensus.workspace = true papyrus_consensus_orchestrator.workspace = true diff --git a/crates/starknet_consensus_manager/src/consensus_manager.rs b/crates/starknet_consensus_manager/src/consensus_manager.rs index 9a6991e797..18a1cb8b99 100644 --- a/crates/starknet_consensus_manager/src/consensus_manager.rs +++ b/crates/starknet_consensus_manager/src/consensus_manager.rs @@ -1,7 +1,7 @@ -use std::any::type_name; use std::sync::Arc; use async_trait::async_trait; +use infra_utils::type_name::short_type_name; use papyrus_consensus::stream_handler::StreamHandler; use papyrus_consensus::types::ConsensusError; use papyrus_consensus_orchestrator::sequencer_consensus_context::SequencerConsensusContext; @@ -113,7 +113,7 @@ pub fn create_consensus_manager( #[async_trait] impl ComponentStarter for ConsensusManager { async fn start(&mut self) -> Result<(), ComponentError> { - info!("Starting component {}.", type_name::()); + info!("Starting component {}.", short_type_name::()); self.run().await.map_err(|e| { error!("Error running component ConsensusManager: {:?}", e); ComponentError::InternalComponentError diff --git a/crates/starknet_http_server/Cargo.toml b/crates/starknet_http_server/Cargo.toml index aab5cfec01..056eead0af 100644 --- a/crates/starknet_http_server/Cargo.toml +++ b/crates/starknet_http_server/Cargo.toml @@ -14,6 +14,7 @@ workspace = true [dependencies] axum.workspace = true hyper.workspace = true +infra_utils.workspace = true papyrus_config.workspace = true reqwest = { workspace = true, optional = true } serde.workspace = true diff --git a/crates/starknet_http_server/src/http_server.rs b/crates/starknet_http_server/src/http_server.rs index 5ebd88c26b..fe70577a1a 100644 --- a/crates/starknet_http_server/src/http_server.rs +++ b/crates/starknet_http_server/src/http_server.rs @@ -1,10 +1,10 @@ -use std::any::type_name; use std::clone::Clone; use std::net::SocketAddr; use axum::extract::State; use axum::routing::post; use axum::{async_trait, Json, Router}; +use infra_utils::type_name::short_type_name; use starknet_api::rpc_transaction::RpcTransaction; use starknet_api::transaction::TransactionHash; use starknet_gateway_types::communication::SharedGatewayClient; @@ -89,7 +89,7 @@ pub fn create_http_server( #[async_trait] impl ComponentStarter for HttpServer { async fn start(&mut self) -> Result<(), ComponentError> { - info!("Starting component {}.", type_name::()); + info!("Starting component {}.", short_type_name::()); self.run().await.map_err(|_| ComponentError::InternalComponentError) } } diff --git a/crates/starknet_monitoring_endpoint/Cargo.toml b/crates/starknet_monitoring_endpoint/Cargo.toml index 7c6f05a905..4bc35f0fb5 100644 --- a/crates/starknet_monitoring_endpoint/Cargo.toml +++ b/crates/starknet_monitoring_endpoint/Cargo.toml @@ -6,7 +6,7 @@ repository.workspace = true license-file.workspace = true [features] -testing = ["infra_utils", "tokio", "tower"] +testing = ["tokio", "tower"] [lints] workspace = true @@ -14,7 +14,7 @@ workspace = true [dependencies] axum.workspace = true hyper = { workspace = true } -infra_utils = { workspace = true, optional = true } +infra_utils.workspace = true metrics-exporter-prometheus.workspace = true papyrus_config.workspace = true serde.workspace = true diff --git a/crates/starknet_monitoring_endpoint/src/monitoring_endpoint.rs b/crates/starknet_monitoring_endpoint/src/monitoring_endpoint.rs index ff92ca0a54..19f284d963 100644 --- a/crates/starknet_monitoring_endpoint/src/monitoring_endpoint.rs +++ b/crates/starknet_monitoring_endpoint/src/monitoring_endpoint.rs @@ -1,4 +1,3 @@ -use std::any::type_name; use std::net::SocketAddr; use axum::http::StatusCode; @@ -6,6 +5,7 @@ use axum::response::{IntoResponse, Response}; use axum::routing::get; use axum::{async_trait, Router, Server}; use hyper::Error; +use infra_utils::type_name::short_type_name; use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle}; use starknet_sequencer_infra::component_definitions::ComponentStarter; use starknet_sequencer_infra::errors::ComponentError; @@ -95,7 +95,7 @@ pub fn create_monitoring_endpoint( #[async_trait] impl ComponentStarter for MonitoringEndpoint { async fn start(&mut self) -> Result<(), ComponentError> { - info!("Starting component {}.", type_name::()); + info!("Starting component {}.", short_type_name::()); self.run().await.map_err(|_| ComponentError::InternalComponentError) } } diff --git a/crates/starknet_sequencer_infra/Cargo.toml b/crates/starknet_sequencer_infra/Cargo.toml index 6b44f2be4d..7c9a8daf96 100644 --- a/crates/starknet_sequencer_infra/Cargo.toml +++ b/crates/starknet_sequencer_infra/Cargo.toml @@ -15,6 +15,7 @@ workspace = true [dependencies] async-trait.workspace = true hyper = { workspace = true, features = ["client", "http2", "server", "tcp"] } +infra_utils.workspace = true papyrus_config.workspace = true rstest.workspace = true serde = { workspace = true, features = ["derive"] } diff --git a/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs b/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs index 4724f85b05..f5a3bede15 100644 --- a/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs +++ b/crates/starknet_sequencer_infra/src/component_client/local_component_client.rs @@ -1,6 +1,5 @@ -use std::any::type_name; - use async_trait::async_trait; +use infra_utils::type_name::short_type_name; use serde::de::DeserializeOwned; use serde::Serialize; use tokio::sync::mpsc::{channel, Sender}; @@ -103,7 +102,7 @@ where Response: Send + Sync, { fn drop(&mut self) { - info!("Dropping LocalComponentClient {}.", type_name::()); + info!("Dropping local client {}.", short_type_name::()); } } diff --git a/crates/starknet_sequencer_infra/src/component_definitions.rs b/crates/starknet_sequencer_infra/src/component_definitions.rs index 6fd199b08c..818635ffdf 100644 --- a/crates/starknet_sequencer_infra/src/component_definitions.rs +++ b/crates/starknet_sequencer_infra/src/component_definitions.rs @@ -1,9 +1,9 @@ -use std::any::type_name; use std::collections::BTreeMap; use std::fmt::Debug; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use async_trait::async_trait; +use infra_utils::type_name::short_type_name; use papyrus_config::dumping::{ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::de::DeserializeOwned; @@ -39,7 +39,7 @@ where #[async_trait] pub trait ComponentStarter { async fn start(&mut self) -> Result<(), ComponentError> { - info!("Starting component {} with the default starter.", type_name::()); + info!("Starting component {} with the default starter.", short_type_name::()); Ok(()) } } diff --git a/crates/starknet_sequencer_infra/src/component_server/empty_component_server.rs b/crates/starknet_sequencer_infra/src/component_server/empty_component_server.rs index aa4e9cd2d3..70675a0154 100644 --- a/crates/starknet_sequencer_infra/src/component_server/empty_component_server.rs +++ b/crates/starknet_sequencer_infra/src/component_server/empty_component_server.rs @@ -1,6 +1,5 @@ -use std::any::type_name; - use async_trait::async_trait; +use infra_utils::type_name::short_type_name; use tracing::info; use crate::component_definitions::ComponentStarter; @@ -20,9 +19,9 @@ impl WrapperServer { #[async_trait] impl ComponentServerStarter for WrapperServer { async fn start(&mut self) -> Result<(), ComponentServerError> { - info!("Starting WrapperServer for {}.", type_name::()); + info!("Starting WrapperServer for {}.", short_type_name::()); let res = self.component.start().await.map_err(ComponentServerError::ComponentError); - info!("Finished running WrapperServer for {}.", type_name::()); + info!("Finished running WrapperServer for {}.", short_type_name::()); res } } diff --git a/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs b/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs index eeb4f02597..4cc49d0920 100644 --- a/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs +++ b/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs @@ -1,8 +1,8 @@ -use std::any::type_name; use std::fmt::Debug; use std::marker::PhantomData; use async_trait::async_trait; +use infra_utils::type_name::short_type_name; use tokio::sync::mpsc::Receiver; use tracing::{debug, error, info}; @@ -126,10 +126,10 @@ where Response: Send + Sync + Debug, { async fn start(&mut self) -> Result<(), ComponentServerError> { - info!("Starting LocalComponentServer for {}.", type_name::()); + info!("Starting LocalComponentServer for {}.", short_type_name::()); self.component.start().await?; request_response_loop(&mut self.rx, &mut self.component).await; - info!("Finished LocalComponentServer for {}.", type_name::()); + info!("Finished LocalComponentServer for {}.", short_type_name::()); Ok(()) } } @@ -211,20 +211,20 @@ async fn request_response_loop( Request: Send + Sync + Debug, Response: Send + Sync + Debug, { - info!("Starting server for component {}", type_name::()); + info!("Starting server for component {}", short_type_name::()); while let Some(request_and_res_tx) = rx.recv().await { let request = request_and_res_tx.request; let tx = request_and_res_tx.tx; - debug!("Component {} received request {:?}", type_name::(), request); + debug!("Component {} received request {:?}", short_type_name::(), request); let response = component.handle_request(request).await; - debug!("Component {} is sending response {:?}", type_name::(), response); + debug!("Component {} is sending response {:?}", short_type_name::(), response); // Send the response to the client. This might result in a panic if the client has closed // the response channel, which is considered a bug. tx.send(response).await.expect("Response connection should be open."); } - info!("Stopping server for component {}", type_name::()); + info!("Stopping server for component {}", short_type_name::()); }