diff --git a/nodes/nomos-node/src/api.rs b/nodes/nomos-node/src/api.rs index 20e65903..705c47a3 100644 --- a/nodes/nomos-node/src/api.rs +++ b/nodes/nomos-node/src/api.rs @@ -61,7 +61,6 @@ pub struct AxumBackend { )] struct ApiDoc; -#[async_trait::async_trait] impl Backend for AxumBackend where T: Transaction diff --git a/nodes/nomos-node/src/lib.rs b/nodes/nomos-node/src/lib.rs index cebd8886..63b2de68 100644 --- a/nodes/nomos-node/src/lib.rs +++ b/nodes/nomos-node/src/lib.rs @@ -7,8 +7,6 @@ use carnot_engine::overlay::{RandomBeaconState, RoundRobin, TreeOverlay}; use color_eyre::eyre::Result; use full_replication::Certificate; use full_replication::{AbsoluteNumber, Attestation, Blob, FullReplication}; -#[cfg(feature = "metrics")] -use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService}; use api::AxumBackend; use bytes::Bytes; @@ -46,8 +44,7 @@ use nomos_core::{ }; use nomos_network::NetworkService; use nomos_system_sig::SystemSig; -use overwatch_derive::*; -use overwatch_rs::services::handle::ServiceHandle; +use overwatch_rs::{services::handle::ServiceHandle, Services}; use serde::{de::DeserializeOwned, Serialize}; pub use tx::Tx; diff --git a/nomos-cli/src/da/disseminate.rs b/nomos-cli/src/da/disseminate.rs index 5386496f..11212ea5 100644 --- a/nomos-cli/src/da/disseminate.rs +++ b/nomos-cli/src/da/disseminate.rs @@ -7,7 +7,6 @@ use nomos_core::{da::DaProtocol, wire}; use nomos_da::network::{adapters::libp2p::Libp2pAdapter, NetworkAdapter}; use nomos_log::Logger; use nomos_network::{backends::libp2p::Libp2p, NetworkService}; -use overwatch_derive::*; use overwatch_rs::{ services::{ handle::{ServiceHandle, ServiceStateHandle}, @@ -15,7 +14,7 @@ use overwatch_rs::{ state::*, ServiceCore, ServiceData, ServiceId, }, - DynError, + DynError, Services, }; use reqwest::Url; use serde::Serialize; @@ -139,7 +138,6 @@ impl ServiceData for DisseminateService { type Message = NoMessage; } -#[async_trait::async_trait] impl ServiceCore for DisseminateService { fn init(service_state: ServiceStateHandle) -> Result { Ok(Self { service_state }) diff --git a/nomos-metrics/src/lib.rs b/nomos-metrics/src/lib.rs index c9ec1277..61683102 100644 --- a/nomos-metrics/src/lib.rs +++ b/nomos-metrics/src/lib.rs @@ -82,7 +82,7 @@ impl ServiceCore for Metrics { let reg = registry.lock().unwrap(); // If encoding fails, we need to stop trying process subsequent metrics gather // requests. If it succeds, encode method returns empty unit type. - _ = encode(&mut buf, ®).map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; + encode(&mut buf, ®).map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; } reply_channel diff --git a/nomos-services/api/src/http/mempool.rs b/nomos-services/api/src/http/mempool.rs index 67e4bfb8..554f122f 100644 --- a/nomos-services/api/src/http/mempool.rs +++ b/nomos-services/api/src/http/mempool.rs @@ -15,7 +15,7 @@ where N: NetworkBackend, A: NetworkAdapter + Send + Sync + 'static, A::Settings: Send + Sync, - D: Discriminant, + D: Discriminant + Send, Item: Clone + Debug + Send + Sync + 'static + Hash, Key: Clone + Debug + Ord + Hash + 'static, { diff --git a/nomos-services/api/src/lib.rs b/nomos-services/api/src/lib.rs index a013f81f..d300b5f1 100644 --- a/nomos-services/api/src/lib.rs +++ b/nomos-services/api/src/lib.rs @@ -8,21 +8,22 @@ use overwatch_rs::{ }, DynError, }; +use std::future::Future; pub mod http; /// A simple abstraction so that we can easily /// change the underlying http server -#[async_trait::async_trait] pub trait Backend { type Error: std::error::Error + Send + Sync + 'static; type Settings: Clone + Send + Sync + 'static; - async fn new(settings: Self::Settings) -> Result + fn new(settings: Self::Settings) -> impl Future> + Send where Self: Sized; - async fn serve(self, handle: OverwatchHandle) -> Result<(), Self::Error>; + fn serve(self, handle: OverwatchHandle) + -> impl Future> + Send; } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] @@ -47,7 +48,6 @@ impl ServiceData for ApiService { type Message = NoMessage; } -#[async_trait::async_trait] impl ServiceCore for ApiService where B: Backend + Send + Sync + 'static, @@ -62,7 +62,7 @@ where } /// Service main loop - async fn run(mut self) -> Result<(), DynError> { + async fn run(self) -> Result<(), DynError> { let endpoint = B::new(self.settings.backend_settings).await?; endpoint.serve(self.handle).await?; Ok(()) diff --git a/nomos-services/api/tests/todo.rs b/nomos-services/api/tests/todo.rs index 845d684d..a1f14ce1 100644 --- a/nomos-services/api/tests/todo.rs +++ b/nomos-services/api/tests/todo.rs @@ -7,10 +7,10 @@ use std::{ use axum::{routing, Router, Server}; use hyper::Error; use nomos_api::{ApiService, ApiServiceSettings, Backend}; -use overwatch_derive::Services; use overwatch_rs::{ overwatch::{handle::OverwatchHandle, OverwatchRunner}, services::handle::ServiceHandle, + Services, }; use utoipa::{ openapi::security::{ApiKey, ApiKeyValue, SecurityScheme}, @@ -61,7 +61,6 @@ pub struct WebServer { addr: SocketAddr, } -#[async_trait::async_trait] impl Backend for WebServer { type Error = hyper::Error; diff --git a/nomos-services/carnot-consensus/src/test.rs b/nomos-services/carnot-consensus/src/test.rs index 2d863225..8254f25e 100644 --- a/nomos-services/carnot-consensus/src/test.rs +++ b/nomos-services/carnot-consensus/src/test.rs @@ -2,7 +2,6 @@ use crate::network::messages::*; use crate::overlay::committees::*; use crate::overlay::*; use crate::*; -use async_trait::async_trait; use bytes::Bytes; use futures::Stream; use nomos_core::fountain::FountainError; @@ -18,7 +17,6 @@ struct DummyOverlay; struct DummyAdapter; struct DummyBackend; -#[async_trait] impl Overlay for DummyOverlay { fn new(_: &View, _: NodeId) -> Self { DummyOverlay @@ -52,7 +50,6 @@ impl Overlay } } -#[async_trait] impl NetworkAdapter for DummyAdapter { type Backend = DummyBackend; async fn new( @@ -87,7 +84,6 @@ impl NetworkAdapter for DummyAdapter { } } -#[async_trait] impl NetworkBackend for DummyBackend { type Settings = (); type State = NoState<()>; diff --git a/nomos-services/mempool/tests/mock.rs b/nomos-services/mempool/tests/mock.rs index c86bed99..8af888c8 100644 --- a/nomos-services/mempool/tests/mock.rs +++ b/nomos-services/mempool/tests/mock.rs @@ -7,8 +7,7 @@ use nomos_network::{ backends::mock::{Mock, MockBackendMessage, MockConfig, MockMessage}, NetworkConfig, NetworkMsg, NetworkService, }; -use overwatch_derive::*; -use overwatch_rs::{overwatch::OverwatchRunner, services::handle::ServiceHandle}; +use overwatch_rs::{overwatch::OverwatchRunner, services::handle::ServiceHandle, Services}; use nomos_mempool::{ backend::mockpool::MockPool, diff --git a/tests/src/lib.rs b/tests/src/lib.rs index cbc6da5b..dfa5a017 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -1,4 +1,5 @@ pub mod nodes; +use futures::Future; use mixnet_node::MixnetNodeConfig; use mixnet_topology::MixnetTopology; pub use nodes::MixNode; @@ -38,11 +39,10 @@ pub fn adjust_timeout(d: Duration) -> Duration { } } -#[async_trait::async_trait] pub trait Node: Sized { type ConsensusInfo: Debug + Clone + PartialEq; - async fn spawn_nodes(config: SpawnConfig) -> Vec; - async fn consensus_info(&self) -> Self::ConsensusInfo; + fn spawn_nodes(config: SpawnConfig) -> impl Future> + Send; + fn consensus_info(&self) -> impl Future + Send; fn stop(&mut self); } diff --git a/tests/src/nodes/nomos.rs b/tests/src/nodes/nomos.rs index 984357a3..542ec63f 100644 --- a/tests/src/nodes/nomos.rs +++ b/tests/src/nodes/nomos.rs @@ -197,7 +197,6 @@ impl NomosNode { } } -#[async_trait::async_trait] impl Node for NomosNode { type ConsensusInfo = CarnotInfo; @@ -341,8 +340,6 @@ fn create_node_config( cors_origins: vec![], }, }, - #[cfg(feature = "metrics")] - metrics: Default::default(), da: nomos_da::Settings { da_protocol: full_replication::Settings { voter: id,