diff --git a/Cargo.toml b/Cargo.toml index c95c1911..08643e59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ members = [ "nomos-services/mempool", "nomos-services/http", "nodes/nomos-node", - "nodes/mockpool-node", "simulations", "consensus-engine" ] diff --git a/nodes/mockpool-node/Cargo.toml b/nodes/mockpool-node/Cargo.toml deleted file mode 100644 index a3ecfa0b..00000000 --- a/nodes/mockpool-node/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "mockpool-node" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -blake2 = "0.10" -bincode = "2.0.0-rc.2" -bytes = "1.3" -clap = { version = "4", features = ["derive"] } -chrono = "0.4" -futures = "0.3" -http = "0.2.9" -overwatch-rs = { git = "https://github.com/logos-co/Overwatch", branch = "main" } -overwatch-derive = { git = "https://github.com/logos-co/Overwatch", branch = "main" } -tracing = "0.1" -multiaddr = "0.17" -nomos-core = { path = "../../nomos-core" } -nomos-network = { path = "../../nomos-services/network", features = ["waku"] } -nomos-log = { path = "../../nomos-services/log" } -nomos-mempool = { path = "../../nomos-services/mempool", features = ["waku", "mock"] } -nomos-http = { path = "../../nomos-services/http", features = ["http"] } -nomos-consensus = { path = "../../nomos-services/consensus", features = ["waku"] } -tracing-subscriber = "0.3" -consensus-engine = { path = "../../consensus-engine" } -tokio = {version = "1.24", features = ["sync"] } -serde_json = "1.0" -serde_yaml = "0.9" -color-eyre = "0.6.0" -serde = "1" -waku-bindings = "0.1.1" diff --git a/nodes/mockpool-node/src/main.rs b/nodes/mockpool-node/src/main.rs deleted file mode 100644 index bb9f960a..00000000 --- a/nodes/mockpool-node/src/main.rs +++ /dev/null @@ -1,108 +0,0 @@ -mod bridges; -mod tx; - -use clap::Parser; -use color_eyre::eyre::{eyre, Result}; -use consensus_engine::overlay::{FlatOverlay, RoundRobin}; -use nomos_consensus::{ - network::adapters::waku::WakuAdapter as ConsensusWakuAdapter, CarnotConsensus, -}; -use nomos_core::fountain::mock::MockFountain; -use nomos_http::backends::axum::AxumBackend; -use nomos_http::bridge::{HttpBridge, HttpBridgeService, HttpBridgeSettings}; -use nomos_http::http::HttpService; -use nomos_log::Logger; -use nomos_mempool::{ - backend::mockpool::MockPool, network::adapters::waku::WakuAdapter as MempoolWakuAdapter, - MempoolService, -}; -use nomos_network::{backends::waku::Waku, NetworkService}; -use overwatch_derive::*; -use overwatch_rs::{ - overwatch::*, - services::{handle::ServiceHandle, ServiceData}, -}; -use serde::Deserialize; -use std::sync::Arc; -use tx::Tx; - -/// Simple program to greet a person -#[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] -struct Args { - /// Path for a yaml-encoded network config file - config: std::path::PathBuf, -} - -type Carnot = CarnotConsensus< - ConsensusWakuAdapter, - MockPool, - MempoolWakuAdapter, - MockFountain, - FlatOverlay, ->; - -#[derive(Deserialize)] -struct Config { - log: ::Settings, - network: as ServiceData>::Settings, - http: as ServiceData>::Settings, - consensus: ::Settings, -} - -#[derive(Services)] -struct MockPoolNode { - logging: ServiceHandle, - network: ServiceHandle>, - mockpool: ServiceHandle, MockPool>>, - consensus: ServiceHandle, - http: ServiceHandle>, - bridges: ServiceHandle, -} -/// Mockpool node -/// Minimal configuration file: -/// -/// ```yaml -/// log: -/// backend: "Stdout" -/// format: "Json" -/// level: "debug" -/// network: -/// backend: -/// host: 0.0.0.0 -/// port: 3000 -/// log_level: "fatal" -/// nodeKey: null -/// discV5BootstrapNodes: [] -/// initial_peers: [] -/// http: -/// backend: -/// address: 0.0.0.0:8080 -/// cors_origins: [] -/// -/// ``` -fn main() -> Result<()> { - let Args { config } = Args::parse(); - let config = serde_yaml::from_reader::<_, Config>(std::fs::File::open(config)?)?; - let bridges: Vec = vec![ - Arc::new(Box::new(bridges::carnot_info_bridge)), - Arc::new(Box::new(bridges::mempool_add_tx_bridge)), - Arc::new(Box::new(bridges::mempool_metrics_bridge)), - Arc::new(Box::new(bridges::waku_add_conn_bridge)), - Arc::new(Box::new(bridges::waku_info_bridge)), - ]; - let app = OverwatchRunner::::run( - MockPoolNodeServiceSettings { - network: config.network, - logging: config.log, - http: config.http, - mockpool: (), - consensus: config.consensus, - bridges: HttpBridgeSettings { bridges }, - }, - None, - ) - .map_err(|e| eyre!("Error encountered: {}", e))?; - app.wait_finished(); - Ok(()) -} diff --git a/nodes/nomos-node/.cargo/config.toml b/nodes/nomos-node/.cargo/config.toml deleted file mode 100644 index 83eca5f7..00000000 --- a/nodes/nomos-node/.cargo/config.toml +++ /dev/null @@ -1,4 +0,0 @@ -[target.'cfg(target_os = "macos")'] -# when using osx, we need to link against some golang libraries, it did just work with this missing flags -# from: https://github.com/golang/go/issues/42459 -rustflags = ["-C", "link-args=-framework CoreFoundation -framework Security"] diff --git a/nodes/nomos-node/Cargo.toml b/nodes/nomos-node/Cargo.toml index 37a36264..dcd49ed2 100644 --- a/nodes/nomos-node/Cargo.toml +++ b/nodes/nomos-node/Cargo.toml @@ -6,14 +6,29 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +blake2 = "0.10" +bincode = "2.0.0-rc.2" +bytes = "1.3" clap = { version = "4", features = ["derive"] } +chrono = "0.4" +futures = "0.3" +http = "0.2.9" overwatch-rs = { git = "https://github.com/logos-co/Overwatch", branch = "main" } overwatch-derive = { git = "https://github.com/logos-co/Overwatch", branch = "main" } tracing = "0.1" +multiaddr = "0.17" +nomos-core = { path = "../../nomos-core" } nomos-network = { path = "../../nomos-services/network", features = ["waku"] } -metrics = { path = "../../nomos-services/metrics", optional = true } nomos-log = { path = "../../nomos-services/log" } +nomos-mempool = { path = "../../nomos-services/mempool", features = ["waku", "mock"] } +nomos-http = { path = "../../nomos-services/http", features = ["http"] } +nomos-consensus = { path = "../../nomos-services/consensus", features = ["waku"] } +metrics = { path = "../../nomos-services/metrics", optional = true } tracing-subscriber = "0.3" +consensus-engine = { path = "../../consensus-engine" } +tokio = {version = "1.24", features = ["sync"] } +serde_json = "1.0" serde_yaml = "0.9" color-eyre = "0.6.0" serde = "1" +waku-bindings = "0.1.1" diff --git a/nodes/nomos-node/config.yaml b/nodes/nomos-node/config.yaml new file mode 100644 index 00000000..dea24206 --- /dev/null +++ b/nodes/nomos-node/config.yaml @@ -0,0 +1,23 @@ +log: + backend: "Stdout" + format: "Json" + level: "debug" +consensus: + private_key: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + fountain_settings: null + overlay_settings: + nodes: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]] + leader: + cur: 0 +network: + backend: + host: 0.0.0.0 + port: 3000 + log_level: "fatal" + nodeKey: null + discV5BootstrapNodes: [] + initial_peers: [] +http: + backend: + address: 0.0.0.0:8080 + cors_origins: [] diff --git a/nodes/mockpool-node/src/bridges.rs b/nodes/nomos-node/src/bridges.rs similarity index 100% rename from nodes/mockpool-node/src/bridges.rs rename to nodes/nomos-node/src/bridges.rs diff --git a/nodes/nomos-node/src/main.rs b/nodes/nomos-node/src/main.rs index 24ab32dc..d258d942 100644 --- a/nodes/nomos-node/src/main.rs +++ b/nodes/nomos-node/src/main.rs @@ -1,6 +1,23 @@ +mod bridges; +mod tx; + use clap::Parser; use color_eyre::eyre::{eyre, Result}; +use consensus_engine::overlay::{FlatOverlay, RoundRobin}; +#[cfg(feature = "metrics")] +use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService}; +use nomos_consensus::{ + network::adapters::waku::WakuAdapter as ConsensusWakuAdapter, CarnotConsensus, +}; +use nomos_core::fountain::mock::MockFountain; +use nomos_http::backends::axum::AxumBackend; +use nomos_http::bridge::{HttpBridge, HttpBridgeService, HttpBridgeSettings}; +use nomos_http::http::HttpService; use nomos_log::Logger; +use nomos_mempool::{ + backend::mockpool::MockPool, network::adapters::waku::WakuAdapter as MempoolWakuAdapter, + MempoolService, +}; use nomos_network::{backends::waku::Waku, NetworkService}; use overwatch_derive::*; use overwatch_rs::{ @@ -8,9 +25,8 @@ use overwatch_rs::{ services::{handle::ServiceHandle, ServiceData}, }; use serde::Deserialize; - -#[cfg(feature = "metrics")] -use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService}; +use std::sync::Arc; +use tx::Tx; /// Simple program to greet a person #[derive(Parser, Debug)] @@ -20,10 +36,20 @@ struct Args { config: std::path::PathBuf, } +type Carnot = CarnotConsensus< + ConsensusWakuAdapter, + MockPool, + MempoolWakuAdapter, + MockFountain, + FlatOverlay, +>; + #[derive(Deserialize)] struct Config { log: ::Settings, network: as ServiceData>::Settings, + http: as ServiceData>::Settings, + consensus: ::Settings, #[cfg(feature = "metrics")] metrics: > as ServiceData>::Settings, } @@ -32,6 +58,10 @@ struct Config { struct Nomos { logging: ServiceHandle, network: ServiceHandle>, + mockpool: ServiceHandle, MockPool>>, + consensus: ServiceHandle, + http: ServiceHandle>, + bridges: ServiceHandle, #[cfg(feature = "metrics")] metrics: ServiceHandle>>, } @@ -39,10 +69,21 @@ struct Nomos { fn main() -> Result<()> { let Args { config } = Args::parse(); let config = serde_yaml::from_reader::<_, Config>(std::fs::File::open(config)?)?; + let bridges: Vec = vec![ + Arc::new(Box::new(bridges::carnot_info_bridge)), + Arc::new(Box::new(bridges::mempool_add_tx_bridge)), + Arc::new(Box::new(bridges::mempool_metrics_bridge)), + Arc::new(Box::new(bridges::waku_add_conn_bridge)), + Arc::new(Box::new(bridges::waku_info_bridge)), + ]; let app = OverwatchRunner::::run( NomosServiceSettings { network: config.network, logging: config.log, + http: config.http, + mockpool: (), + consensus: config.consensus, + bridges: HttpBridgeSettings { bridges }, #[cfg(feature = "metrics")] metrics: config.metrics, }, diff --git a/nodes/mockpool-node/src/tx.rs b/nodes/nomos-node/src/tx.rs similarity index 100% rename from nodes/mockpool-node/src/tx.rs rename to nodes/nomos-node/src/tx.rs