Skip to content

Commit

Permalink
Merge branch 'master' into my-codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzac committed Aug 22, 2024
2 parents 43e0a31 + 3671376 commit 02946b7
Show file tree
Hide file tree
Showing 65 changed files with 2,474 additions and 233 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ members = [
"nomos-services/metrics",
"nomos-services/system-sig",
"nomos-services/data-availability/indexer",
"nomos-services/data-availability/network",
"nomos-services/data-availability/verifier",
"nomos-services/data-availability/tests",
"nomos-da/full-replication",
# TODO: add it again and reimplement full replication
# "nomos-cli",
"nomos-cli",
"nomos-utils",
"nodes/nomos-node",
"mixnet",
Expand Down
2 changes: 2 additions & 0 deletions nodes/nomos-node/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ where
A: Serialize + DeserializeOwned + Clone + Send + Sync + 'static,
B: Blob + Serialize + DeserializeOwned + Clone + Send + Sync + 'static,
<B as Blob>::BlobId: AsRef<[u8]> + Send + Sync + 'static,
<B as Blob>::ColumnIndex: AsRef<[u8]> + Send + Sync + 'static,
C: DispersedBlobInfo<BlobId = [u8; 32]>
+ Clone
+ Debug
Expand Down Expand Up @@ -327,6 +328,7 @@ where
A: Serialize + DeserializeOwned + Clone + Send + Sync + 'static,
B: Blob + Serialize + DeserializeOwned + Clone + Send + Sync + 'static,
<B as Blob>::BlobId: AsRef<[u8]> + Send + Sync + 'static,
<B as Blob>::ColumnIndex: AsRef<[u8]> + Send + Sync + 'static,
VB: VerifierBackend + CoreDaVerifier<DaBlob = B>,
<VB as VerifierBackend>::Settings: Clone,
<VB as CoreDaVerifier>::Error: Error,
Expand Down
5 changes: 3 additions & 2 deletions nomos-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ futures = "0.3"
tokio = { version = "1", features = ["sync"] }
overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806" }
overwatch-derive = { git = "https://github.com/logos-co/Overwatch", rev = "ac28d01" }
nomos-network = { path = "../nomos-services/network", features = ["libp2p"] }
nomos-da-network-service = { path = "../nomos-services/data-availability/network" }
cryptarchia-consensus = { path = "../nomos-services/cryptarchia-consensus" }
kzgrs-backend = { path = "../nomos-da/kzgrs-backend" }
nomos-log = { path = "../nomos-services/log" }
nomos-libp2p = { path = "../nomos-libp2p" }
nomos-core = { path = "../nomos-core" }
nomos-node = { path = "../nodes/nomos-node" }
full-replication = { path = "../nomos-da/full-replication" }
reqwest = "0.11"
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions nomos-cli/src/api/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use super::CLIENT;
use reqwest::{Error, Response, Url};
use serde::Serialize;

pub async fn send_certificate<C>(node: &Url, cert: &C) -> Result<Response, Error>
pub async fn send_blob_info<I>(node: &Url, info: &I) -> Result<Response, Error>
where
C: Serialize,
I: Serialize,
{
const NODE_CERT_PATH: &str = "mempool/add/cert";
CLIENT
.post(node.join(NODE_CERT_PATH).unwrap())
.json(cert)
.json(info)
.send()
.await
}
22 changes: 14 additions & 8 deletions nomos-cli/src/cmds/disseminate/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::da::disseminate::{
DaProtocolChoice, DisseminateApp, DisseminateAppServiceSettings, Settings, Status,
DisseminateApp, DisseminateAppServiceSettings, KzgrsSettings, Settings, Status,
};
use clap::Args;
use kzgrs_backend::dispersal::Metadata;
use nomos_da_network_service::backends::mock::executor::MockExecutorBackend as NetworkBackend;
use nomos_da_network_service::NetworkService;
use nomos_log::{LoggerBackend, LoggerSettings};
use nomos_network::backends::libp2p::Libp2p as NetworkBackend;
use nomos_network::NetworkService;
use overwatch_rs::{overwatch::OverwatchRunner, services::ServiceData};
use reqwest::Url;
use std::{path::PathBuf, sync::Arc, time::Duration};
Expand All @@ -18,16 +19,17 @@ pub struct Disseminate {
/// Path to the network config file
#[clap(short, long)]
pub network_config: PathBuf,
/// The data availability protocol to use. Defaults to full replication.
#[clap(flatten)]
pub da_protocol: DaProtocolChoice,
/// Timeout in seconds. Defaults to 120 seconds.
#[clap(short, long, default_value = "120")]
pub timeout: u64,
/// Address of the node to send the certificate to
/// for block inclusion, if present.
#[clap(long)]
pub node_addr: Option<Url>,
#[clap(long)]
pub app_id: String,
#[clap(long)]
pub index: u64,
/// File to write the certificate to, if present.
#[clap(long)]
pub output: Option<PathBuf>,
Expand All @@ -54,8 +56,11 @@ impl Disseminate {
file_bytes.into_boxed_slice()
};

let app_id: [u8; 32] = hex::decode(&self.app_id)?
.try_into()
.map_err(|_| "Invalid app_id")?;
let metadata = Metadata::new(app_id, self.index.into());
let timeout = Duration::from_secs(self.timeout);
let da_protocol = self.da_protocol.clone();
let node_addr = self.node_addr.clone();
let output = self.output.clone();
let (payload_sender, payload_rx) = tokio::sync::mpsc::unbounded_channel();
Expand All @@ -67,7 +72,8 @@ impl Disseminate {
send_blob: Settings {
payload: Arc::new(Mutex::new(payload_rx)),
timeout,
da_protocol,
kzgrs_settings: KzgrsSettings::default(),
metadata,
status_updates,
node_addr,
output,
Expand Down
14 changes: 7 additions & 7 deletions nomos-cli/src/cmds/mod.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
use clap::Subcommand;

// pub mod chat;
// pub mod disseminate;
pub mod disseminate;

#[derive(Debug, Subcommand)]
pub enum Command {
// /// Send a blob to the network and collect attestations to create a DA proof
// Disseminate(disseminate::Disseminate),
/// Send a blob to the network and collect attestations to create a DA proof
Disseminate(disseminate::Disseminate),
// /// (Almost) Instant messaging protocol on top of the Nomos network
// Chat(chat::NomosChat),
}

impl Command {
pub fn run(&self) -> Result<(), Box<dyn std::error::Error>> {
// match self {
// Command::Disseminate(cmd) => cmd.run(),
// Command::Chat(cmd) => cmd.run(),
// }
match self {
Command::Disseminate(cmd) => cmd.run(),
// Command::Chat(cmd) => cmd.run(),
}?;
Ok(())
}
}
Loading

0 comments on commit 02946b7

Please sign in to comment.