Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
722 changes: 346 additions & 376 deletions content-discovery/Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions content-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ missing_debug_implementations = "warn"
unused-async = "warn"

[workspace.dependencies]
iroh = { version ="0.91", features = ["discovery-pkarr-dht"] }
iroh-base = "0.91"
iroh-blobs = { version = "0.93" }
iroh = { version ="0.93", features = ["discovery-pkarr-dht"] }
iroh-base = "0.93"
iroh-blobs = { version = "0.95" }
# explicitly specified until iroh minimal crates issues are solved, see https://github.com/n0-computer/iroh/pull/3255
tokio = { version = "1.44.1" }
tokio-stream = { version = "0.1.17" }
Expand Down
3 changes: 1 addition & 2 deletions content-discovery/iroh-content-discovery-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ async fn query(args: QueryArgs) -> anyhow::Result<()> {
async fn create_client_endpoint() -> Result<endpoint::Endpoint, BindError> {
let discovery = iroh::discovery::pkarr::dht::DhtDiscovery::builder()
.dht(true)
.n0_dns_pkarr_relay()
.build()?;
.n0_dns_pkarr_relay();
endpoint::Endpoint::builder()
.discovery(discovery)
.bind()
Expand Down
2 changes: 1 addition & 1 deletion content-discovery/iroh-content-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tokio-stream = { workspace = true }
n0-future = { workspace = true, optional = true }
futures-buffered = { workspace = true, optional = true }
snafu = "0.8.6"
ed25519-dalek = "2.1.1"
ed25519-dalek = "3.0.0-pre.1"

[features]
client = [
Expand Down
4 changes: 2 additions & 2 deletions content-discovery/iroh-content-tracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ humantime = "2.1.0"
iroh = { workspace = true }
iroh-blobs = { workspace = true }
postcard = { workspace = true, features = ["alloc", "use-std"] }
rand = "0.8"
rand = "0.9.2"
rcgen = "0.12.0"
redb = "1.5.0"
serde = { version = "1", features = ["derive"] }
Expand All @@ -37,7 +37,7 @@ iroh-content-discovery = { path = "../iroh-content-discovery", features = ["clie

clap = { version = "4", features = ["derive"], optional = true }
serde-big-array = "0.5.1"
ssh-key = { version = "0.6", features = ["ed25519"] }
ssh-key = { version = "0.7.0-rc.3", features = ["ed25519"] }

[features]
cli = ["clap"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub fn random_hash_seq_ranges(sizes: &[u64], mut rng: impl Rng) -> ChunkRangesSe
.iter()
.map(|size| ChunkNum::full_chunks(*size).0)
.sum::<u64>();
let random_chunk = rng.gen_range(0..total_chunks);
let random_chunk = rng.random_range(0..total_chunks);
let mut remaining = random_chunk;
let mut ranges = vec![];
ranges.push(ChunkRanges::empty());
Expand Down
25 changes: 4 additions & 21 deletions content-discovery/iroh-content-tracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use std::{
net::{SocketAddrV4, SocketAddrV6},
path::PathBuf,
sync::atomic::{AtomicBool, Ordering},
time::{Duration, Instant},
};

use clap::Parser;
use iroh::{endpoint::BindError, Endpoint, Watcher};
use iroh::{endpoint::BindError, Endpoint};
use iroh_content_discovery::protocol::ALPN;
use iroh_content_tracker::{
io::{
Expand Down Expand Up @@ -43,22 +42,6 @@ macro_rules! log {
};
}

/// Wait until the endpoint has figured out it's own DERP region.
async fn await_relay_region(endpoint: &Endpoint) -> anyhow::Result<()> {
let t0 = Instant::now();
loop {
let addr = endpoint.node_addr().initialized().await;
if addr.relay_url().is_some() {
break;
}
if t0.elapsed() > Duration::from_secs(10) {
anyhow::bail!("timeout waiting for DERP region");
}
tokio::time::sleep(Duration::from_millis(50)).await;
}
Ok(())
}

async fn create_endpoint(
key: iroh::SecretKey,
ipv4_addr: Option<SocketAddrV4>,
Expand Down Expand Up @@ -112,8 +95,8 @@ async fn server(args: Args) -> anyhow::Result<()> {
create_endpoint(key.clone(), options.ipv4_bind_addr, options.ipv6_bind_addr).await?;
let db = Tracker::new(options, endpoint.clone())?;
db.dump().await?;
await_relay_region(&endpoint).await?;
let addr = endpoint.node_addr().initialized().await;
endpoint.online().await;
let addr = endpoint.node_addr();
println!("tracker addr: {}\n", addr.node_id);
info!("listening on {:?}", addr);
// let db2 = db.clone();
Expand Down Expand Up @@ -169,7 +152,7 @@ pub async fn load_secret_key(key_path: PathBuf) -> anyhow::Result<iroh::SecretKe
let secret_key = SecretKey::from_bytes(&kp.private.to_bytes());
Ok(secret_key)
} else {
let secret_key = SecretKey::generate(rand::rngs::OsRng);
let secret_key = SecretKey::generate(&mut rand::rng());
let ckey = ssh_key::private::Ed25519Keypair {
public: secret_key.public().public().into(),
private: secret_key.secret().into(),
Expand Down
6 changes: 3 additions & 3 deletions content-discovery/iroh-content-tracker/src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ impl Tracker {
) -> anyhow::Result<Stats> {
let cap = format!("{content} at {host}");
let HashAndFormat { hash, format } = content;
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let stats = if probe_kind == ProbeKind::Incomplete {
tracing::debug!("Size probing {}...", cap);
let (size, stats) = unverified_size(connection, hash).await?;
Expand All @@ -1042,7 +1042,7 @@ impl Tracker {
match format {
BlobFormat::Raw => {
let size = self.get_or_insert_size(connection, hash).await?;
let random_chunk = rng.gen_range(0..ChunkNum::chunks(size).0);
let random_chunk = rng.random_range(0..ChunkNum::chunks(size).0);
tracing::debug!("Chunk probing {}, chunk {}", cap, random_chunk);
let stats = chunk_probe(connection, hash, ChunkNum(random_chunk)).await?;
tracing::debug!(
Expand All @@ -1055,7 +1055,7 @@ impl Tracker {
}
BlobFormat::HashSeq => {
let (hs, sizes) = self.get_or_insert_sizes(connection, hash).await?;
let ranges = random_hash_seq_ranges(&sizes, rand::thread_rng());
let ranges = random_hash_seq_ranges(&sizes, rand::rng());
let text = ranges
.iter_non_empty_infinite()
.map(|(index, ranges)| format!("child={index}, ranges={ranges:?}"))
Expand Down
2 changes: 1 addition & 1 deletion content-discovery/iroh-content-tracker/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn smoke_test() -> anyhow::Result<()> {
let accept_task = tokio::spawn(tracker.clone().accept_loop(tracker_ep.clone()));
let tracker_id = tracker_ep.node_id();
let store = MemStore::new();
let blobs = BlobsProtocol::new(&store, provider_ep.clone(), None);
let blobs = BlobsProtocol::new(&store, None);
let provider_router = RouterBuilder::new(provider_ep.clone())
.accept(iroh_blobs::ALPN, blobs.clone())
.spawn();
Expand Down
4 changes: 2 additions & 2 deletions h3-iroh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ http-body = { version = "1", optional = true }
http-body-util = { version = "0.1", optional = true }
hyper = { version = "1.5", optional = true }
hyper-util = { version = "0.1", optional = true }
iroh = "0.91"
iroh-base = { version = "0.91", features = ["ticket"] }
iroh = "0.93"
iroh-base = { version = "0.93", features = ["ticket"] }
tokio = { version = "1", features = ["io-util"], default-features = false}
tokio-util = "0.7"
tower = { version = "0.5", optional = true }
Expand Down
6 changes: 2 additions & 4 deletions h3-iroh/examples/server-axum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use anyhow::Result;
use axum::{response::Html, routing::get, Router};
use iroh::Watcher;
use iroh_base::ticket::NodeTicket;
use tracing::info;

Expand All @@ -21,9 +20,8 @@ async fn main() -> Result<()> {
info!("accepting connections on node: {}", ep.node_id());

// Wait for direct addresses and a RelayUrl before printing a NodeTicket.
ep.direct_addresses().initialized().await;
ep.home_relay().initialized().await;
let ticket = NodeTicket::new(ep.node_addr().initialized().await);
ep.online().await;
let ticket = NodeTicket::new(ep.node_addr());
info!("node ticket: {ticket}");
info!("run: cargo run --example client -- iroh+h3://{ticket}/");

Expand Down
9 changes: 4 additions & 5 deletions h3-iroh/examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bytes::{Bytes, BytesMut};
use clap::Parser;
use h3::{error::ErrorLevel, quic::BidiStream, server::RequestStream};
use http::{Request, StatusCode};
use iroh::{endpoint::Incoming, Watcher};
use iroh::endpoint::Incoming;
use iroh_base::ticket::NodeTicket;
use tokio::{fs::File, io::AsyncReadExt};
use tracing::{debug, error, field, info, info_span, Instrument, Span};
Expand Down Expand Up @@ -50,9 +50,8 @@ async fn main() -> Result<()> {
info!("accepting connections on node: {}", ep.node_id());

// Wait for direct addresses and a RelayUrl before printing a NodeTicket.
ep.direct_addresses().initialized().await;
ep.home_relay().initialized().await;
let ticket = NodeTicket::new(ep.node_addr().initialized().await);
ep.online().await;
let ticket = NodeTicket::new(ep.node_addr());
info!("node ticket: {ticket}");
info!("run e.g.: cargo run --example client -- iroh+h3://{ticket}/Cargo.toml");

Expand All @@ -77,7 +76,7 @@ async fn handle_connection(incoming: Incoming, root: Arc<Option<PathBuf>>) -> Re
let conn = incoming.accept()?.await?;
let remote_node_id = conn.remote_node_id()?;
let span = Span::current();
span.record("remote_node_id", remote_node_id.fmt_short());
span.record("remote_node_id", remote_node_id.fmt_short().to_string());
info!("new connection");

let mut h3_conn = h3::server::Connection::new(h3_iroh::Connection::new(conn)).await?;
Expand Down
12 changes: 6 additions & 6 deletions iroh-dag-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2021"

[dependencies]
iroh-blobs = "0.93"
iroh-gossip = "0.91"
iroh = "0.91"
iroh-base = { version ="0.91", features = ["ticket"] }
iroh-car = "0.5.0"
iroh-blobs = "0.95"
iroh-gossip = "0.93"
iroh = "0.93"
iroh-base = { version ="0.93", features = ["ticket"] }
iroh-car = "0.5"
redb = "2.1.1"
clap = { version = "4.5.7", features = ["derive"] }
tracing-subscriber = "0.3.18"
Expand All @@ -24,7 +24,7 @@ genawaiter = "0.99.1"
bytes = "1.6.0"
hex = "0.4.3"
ron = "0.8.1"
rand = "0.8.5"
rand = "0.9.2"
tracing = "0.1.40"
serde_bytes = "0.11.14"
ipld-core = "0.4.1"
Expand Down
6 changes: 3 additions & 3 deletions iroh-dag-sync/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use clap::Parser;
use futures_lite::StreamExt;
use ipld_core::codec::Links;
use iroh::discovery::{dns::DnsDiscovery, pkarr::PkarrPublisher, ConcurrentDiscovery};
use iroh::{NodeAddr, Watcher};
use iroh::NodeAddr;
use iroh_base::ticket::NodeTicket;
use iroh_car::CarReader;
use protocol::{ron_parser, Cid, Request};
Expand Down Expand Up @@ -123,8 +123,8 @@ async fn main() -> anyhow::Result<()> {
args::SubCommand::Node(args) => {
let endpoint =
create_endpoint(args.net.iroh_ipv4_addr, args.net.iroh_ipv6_addr).await?;
endpoint.home_relay().initialized().await;
let addr = endpoint.node_addr().initialized().await;
endpoint.online().await;
let addr = endpoint.node_addr();
println!("Node id:\n{}", addr.node_id);
println!(
"Listening on {:#?}, {:#?}",
Expand Down
9 changes: 0 additions & 9 deletions iroh-dag-sync/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,6 @@ impl SyncResponseHeader {
}
}

#[derive(Debug, Serialize, Deserialize)]
#[repr(u8)]
pub enum DataMode {
/// no data is included
None = 0,
/// data is included
Inline = 1,
}

/// Options to configure a traversal
///
/// The exact traversal options will probably be project specific, since we don't
Expand Down
13 changes: 8 additions & 5 deletions iroh-dag-sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Context;
use bao_tree::{io::outboard::EmptyOutboard, BaoTree, ChunkRanges};
use iroh::endpoint::{Connecting, RecvStream, SendStream};
use iroh_blobs::store::{fs::FsStore, IROH_BLOCK_SIZE};
use iroh_io::TokioStreamReader;
use iroh_io::{TokioStreamReader, TokioStreamWriter};
use multihash_codetable::MultihashDigest;
use tokio::io::AsyncReadExt;

Expand Down Expand Up @@ -61,25 +61,28 @@ where
T::Db: ReadableTables,
{
let mut traversal = traversal;
let mut send = TokioStreamWriter(send);
while let Some(cid) = traversal.next().await? {
let hash = traversal
.db_mut()
.blake3_hash(cid.hash())?
.context("blake3 hash not found")?;
if inline(&cid) {
send.write_all(&SyncResponseHeader::Data(hash).as_bytes())
send.0
.write_all(&SyncResponseHeader::Data(hash).as_bytes())
.await?;

blobs
.export_bao(hash, ChunkRanges::all())
.write_quinn(send)
.write(&mut send)
.await?;
} else {
send.write_all(&SyncResponseHeader::Hash(hash).as_bytes())
send.0
.write_all(&SyncResponseHeader::Hash(hash).as_bytes())
.await?;
}
}
send.finish()?;
send.0.finish()?;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion iroh-dag-sync/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn get_or_create_secret() -> anyhow::Result<SecretKey> {
Ok(secret)
}
Err(_) => {
let secret = SecretKey::generate(rand::thread_rng());
let secret = SecretKey::generate(&mut rand::rng());
std::fs::write(FILENAME, secret.to_bytes())?;
Ok(secret)
}
Expand Down
4 changes: 2 additions & 2 deletions iroh-pkarr-naming-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2021"
[dependencies]
anyhow = "1.0.79"
derive_more = "0.99.17"
iroh = "0.91"
iroh-blobs = "0.93"
iroh = "0.93"
iroh-blobs = "0.95"
pkarr = { version = "2.3.1", features = ["async", "dht"] }
tokio = "1.35.1"
tokio-util = "0.7.12"
Expand Down
Loading