Rename mockpool-node to nomos-node (#203)

This commit is contained in:
Giacomo Pasini 2023-06-20 17:04:52 +02:00 committed by GitHub
parent f02234f9d1
commit 2fc10f94f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 83 additions and 150 deletions

View File

@ -9,7 +9,6 @@ members = [
"nomos-services/mempool",
"nomos-services/http",
"nodes/nomos-node",
"nodes/mockpool-node",
"simulations",
"consensus-engine"
]

View File

@ -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"

View File

@ -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<Tx>,
MempoolWakuAdapter<Tx>,
MockFountain,
FlatOverlay<RoundRobin>,
>;
#[derive(Deserialize)]
struct Config {
log: <Logger as ServiceData>::Settings,
network: <NetworkService<Waku> as ServiceData>::Settings,
http: <HttpService<AxumBackend> as ServiceData>::Settings,
consensus: <Carnot as ServiceData>::Settings,
}
#[derive(Services)]
struct MockPoolNode {
logging: ServiceHandle<Logger>,
network: ServiceHandle<NetworkService<Waku>>,
mockpool: ServiceHandle<MempoolService<MempoolWakuAdapter<Tx>, MockPool<Tx>>>,
consensus: ServiceHandle<Carnot>,
http: ServiceHandle<HttpService<AxumBackend>>,
bridges: ServiceHandle<HttpBridgeService>,
}
/// 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<HttpBridge> = 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::<MockPoolNode>::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(())
}

View File

@ -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"]

View File

@ -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"

View File

@ -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: []

View File

@ -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<Tx>,
MempoolWakuAdapter<Tx>,
MockFountain,
FlatOverlay<RoundRobin>,
>;
#[derive(Deserialize)]
struct Config {
log: <Logger as ServiceData>::Settings,
network: <NetworkService<Waku> as ServiceData>::Settings,
http: <HttpService<AxumBackend> as ServiceData>::Settings,
consensus: <Carnot as ServiceData>::Settings,
#[cfg(feature = "metrics")]
metrics: <MetricsService<MapMetricsBackend<MetricsData>> as ServiceData>::Settings,
}
@ -32,6 +58,10 @@ struct Config {
struct Nomos {
logging: ServiceHandle<Logger>,
network: ServiceHandle<NetworkService<Waku>>,
mockpool: ServiceHandle<MempoolService<MempoolWakuAdapter<Tx>, MockPool<Tx>>>,
consensus: ServiceHandle<Carnot>,
http: ServiceHandle<HttpService<AxumBackend>>,
bridges: ServiceHandle<HttpBridgeService>,
#[cfg(feature = "metrics")]
metrics: ServiceHandle<MetricsService<MapMetricsBackend<MetricsData>>>,
}
@ -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<HttpBridge> = 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::<Nomos>::run(
NomosServiceSettings {
network: config.network,
logging: config.log,
http: config.http,
mockpool: (),
consensus: config.consensus,
bridges: HttpBridgeSettings { bridges },
#[cfg(feature = "metrics")]
metrics: config.metrics,
},