Skip to content

Commit

Permalink
Merge branch 'main' into pluggable-gc-with-exemptions
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/net_protocol.rs
  • Loading branch information
rklaehn committed Nov 28, 2024
2 parents 715d668 + b9dbf2c commit 24a1172
Show file tree
Hide file tree
Showing 21 changed files with 359 additions and 417 deletions.
664 changes: 307 additions & 357 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ indicatif = { version = "0.17.8", optional = true }
iroh-base = { version = "0.28.0", features = ["redb"] }
iroh-io = { version = "0.6.0", features = ["stats"] }
iroh-metrics = { version = "0.28.0", default-features = false }
iroh-net = { version = "0.28.1" }
iroh-router = "0.28.0"
iroh = { version = "0.28.1" }
nested_enum_utils = { version = "0.1.0", optional = true }
num_cpus = "1.15.0"
oneshot = "0.1.8"
Expand Down Expand Up @@ -76,13 +75,12 @@ tracing-futures = "0.2.5"
walkdir = { version = "2.5.0", optional = true }

# Examples
iroh = { version = "0.28", optional = true }
console = { version = "0.15.8", optional = true }

[dev-dependencies]
http-body = "1.0"
iroh-test = { version = "0.28" }
iroh-net = { version = "0.28", features = ["test-utils"] }
iroh = { version = "0.28", features = ["test-utils"] }
futures-buffered = "0.2.4"
proptest = "1.0.0"
serde_json = "1.0.107"
Expand Down Expand Up @@ -116,7 +114,12 @@ rpc = [
"downloader",
]

example-iroh = ["dep:iroh", "dep:clap", "dep:indicatif", "dep:console"]
example-iroh = [
"dep:clap",
"dep:indicatif",
"dep:console",
"iroh/discovery-local-network"
]

[package.metadata.docs.rs]
all-features = true
Expand Down Expand Up @@ -177,8 +180,6 @@ panic = 'abort'
incremental = false

[patch.crates-io]
iroh-router = { git = "https://github.com/n0-computer/iroh", branch = "main" }
iroh-net = { git = "https://github.com/n0-computer/iroh", branch = "main" }
iroh-metrics = { git = "https://github.com/n0-computer/iroh", branch = "main" }
iroh-base = { git = "https://github.com/n0-computer/iroh", branch = "main" }
iroh = { git = "https://github.com/n0-computer/iroh", branch = "main" }
1 change: 0 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ allow = [
"ISC",
"MIT",
"OpenSSL",
"Unicode-DFS-2016",
"Zlib",
"MPL-2.0", # https://fossa.com/blog/open-source-software-licenses-101-mozilla-public-license-2-0/
"Unicode-3.0"
Expand Down
9 changes: 3 additions & 6 deletions examples/custom-protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ use anyhow::Result;
use clap::Parser;
use futures_lite::future::Boxed as BoxedFuture;
use iroh::{
net::{
endpoint::{get_remote_node_id, Connecting},
Endpoint, NodeId,
},
router::ProtocolHandler,
endpoint::{get_remote_node_id, Connecting},
protocol::{ProtocolHandler, Router},
Endpoint, NodeId,
};
use iroh_base::hash::Hash;
use iroh_blobs::{net_protocol::Blobs, rpc::client::blobs::MemClient, util::local_pool::LocalPool};
use iroh_router::Router;
use tracing_subscriber::{prelude::*, EnvFilter};

#[derive(Debug, Parser)]
Expand Down
5 changes: 2 additions & 3 deletions examples/hello-world-fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
use std::{env, str::FromStr};

use anyhow::{bail, ensure, Context, Result};
use iroh::base::ticket::BlobTicket;
use iroh::{protocol::Router, Endpoint};
use iroh_base::ticket::BlobTicket;
use iroh_blobs::{net_protocol::Blobs, util::local_pool::LocalPool, BlobFormat};
use iroh_net::Endpoint;
use iroh_router::Router;
use tracing_subscriber::{prelude::*, EnvFilter};

// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
Expand Down
3 changes: 1 addition & 2 deletions examples/hello-world-provide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
//! This is using an in memory database and a random node id.
//! run this example from the project root:
//! $ cargo run --example hello-world-provide
use iroh::{protocol::Router, Endpoint};
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
use iroh_blobs::{net_protocol::Blobs, util::local_pool::LocalPool};
use iroh_net::Endpoint;
use iroh_router::Router;
use tracing_subscriber::{prelude::*, EnvFilter};

// set the RUST_LOG env var to one of {debug,info,warn} to see logging info
Expand Down
7 changes: 3 additions & 4 deletions examples/local-swarm-discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ use std::path::PathBuf;
use anyhow::ensure;
use clap::{Parser, Subcommand};
use iroh::{
base::{hash::Hash, key::SecretKey},
net::{discovery::local_swarm_discovery::LocalSwarmDiscovery, key::PublicKey, NodeAddr},
discovery::local_swarm_discovery::LocalSwarmDiscovery, key::PublicKey, protocol::Router,
Endpoint, NodeAddr, RelayMode,
};
use iroh_base::{hash::Hash, key::SecretKey};
use iroh_blobs::{
net_protocol::Blobs, rpc::client::blobs::WrapOption, util::local_pool::LocalPool,
};
use iroh_net::{Endpoint, RelayMode};
use iroh_router::Router;
use tracing_subscriber::{prelude::*, EnvFilter};

use self::progress::show_download_progress;
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use indicatif::{
HumanBytes, HumanDuration, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressState,
ProgressStyle,
};
use iroh::{key::PublicKey, relay::RelayUrl, NodeAddr};
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
use iroh_net::{key::PublicKey, relay::RelayUrl, NodeAddr};
use tokio::io::AsyncWriteExt;

use crate::{
Expand Down
6 changes: 3 additions & 3 deletions src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ use std::{

use futures_lite::{future::BoxedLocal, Stream, StreamExt};
use hashlink::LinkedHashSet;
use iroh::{endpoint, Endpoint, NodeAddr, NodeId};
use iroh_base::hash::{BlobFormat, Hash, HashAndFormat};
use iroh_metrics::inc;
use iroh_net::{endpoint, Endpoint, NodeAddr, NodeId};
use tokio::{
sync::{mpsc, oneshot},
task::JoinSet,
Expand Down Expand Up @@ -354,7 +354,7 @@ impl Downloader {
{
let me = endpoint.node_id().fmt_short();
let (msg_tx, msg_rx) = mpsc::channel(SERVICE_CHANNEL_CAPACITY);
let dialer = iroh_net::dialer::Dialer::new(endpoint);
let dialer = iroh::dialer::Dialer::new(endpoint);

let create_future = move || {
let getter = get::IoGetter {
Expand Down Expand Up @@ -1492,7 +1492,7 @@ impl Queue {
}
}

impl Dialer for iroh_net::dialer::Dialer {
impl Dialer for iroh::dialer::Dialer {
type Connection = endpoint::Connection;

fn queue_dial(&mut self, node_id: NodeId) {
Expand Down
6 changes: 3 additions & 3 deletions src/downloader/get.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! [`Getter`] implementation that performs requests over [`Connection`]s.
//!
//! [`Connection`]: iroh_net::endpoint::Connection
//! [`Connection`]: iroh::endpoint::Connection

use futures_lite::FutureExt;
use iroh_net::endpoint;
use iroh::endpoint;

use super::{progress::BroadcastProgressSender, DownloadKind, FailureAction, GetStartFut, Getter};
use crate::{
Expand All @@ -27,7 +27,7 @@ impl From<GetError> for FailureAction {

/// [`Getter`] implementation that performs requests over [`Connection`]s.
///
/// [`Connection`]: iroh_net::endpoint::Connection
/// [`Connection`]: iroh::endpoint::Connection
pub(crate) struct IoGetter<S: Store> {
pub store: S,
}
Expand Down
2 changes: 1 addition & 1 deletion src/downloader/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{

use anyhow::anyhow;
use futures_util::future::FutureExt;
use iroh_net::key::SecretKey;
use iroh::key::SecretKey;

use super::*;
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{

use anyhow::Result;
use bao_tree::{io::fsm::BaoContentItem, ChunkNum};
use iroh_net::endpoint::{self, RecvStream, SendStream};
use iroh::endpoint::{self, RecvStream, SendStream};
use serde::{Deserialize, Serialize};
use tracing::{debug, error};

Expand Down Expand Up @@ -66,8 +66,8 @@ pub mod fsm {
BaoTree, ChunkRanges, TreeNode,
};
use derive_more::From;
use iroh::endpoint::Connection;
use iroh_io::{AsyncSliceWriter, AsyncStreamReader, TokioStreamReader};
use iroh_net::endpoint::Connection;
use tokio::io::AsyncWriteExt;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion src/get/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use genawaiter::{
rc::{Co, Gen},
GeneratorState,
};
use iroh::endpoint::Connection;
use iroh_base::hash::Hash;
use iroh_io::AsyncSliceReader;
use iroh_net::endpoint::Connection;
use serde::{Deserialize, Serialize};
use tokio::sync::oneshot;
use tracing::trace;
Expand Down
2 changes: 1 addition & 1 deletion src/get/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Error returned from get operations

use iroh_net::endpoint;
use iroh::endpoint;

use crate::util::progress::ProgressSendError;

Expand Down
2 changes: 1 addition & 1 deletion src/get/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;

use bao_tree::{ChunkNum, ChunkRanges};
use bytes::Bytes;
use iroh_net::endpoint::Connection;
use iroh::endpoint::Connection;
use rand::Rng;

use super::{fsm, Stats};
Expand Down
3 changes: 1 addition & 2 deletions src/net_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use std::{
use anyhow::{anyhow, bail, Result};
use futures_lite::future::Boxed as BoxedFuture;
use futures_util::future::BoxFuture;
use iroh::{endpoint::Connecting, protocol::ProtocolHandler, Endpoint, NodeAddr};
use iroh_base::hash::{BlobFormat, Hash};
use iroh_net::{endpoint::Connecting, Endpoint, NodeAddr};
use iroh_router::ProtocolHandler;
use serde::{Deserialize, Serialize};
use tracing::{debug, warn};

Expand Down
6 changes: 3 additions & 3 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
//! keep a connection open and reuse it for multiple requests.
use bao_tree::{ChunkNum, ChunkRanges};
use derive_more::From;
use iroh_net::endpoint::VarInt;
use iroh::endpoint::VarInt;
use serde::{Deserialize, Serialize};
mod range_spec;
pub use range_spec::{NonEmptyRequestRangeSpecIter, RangeSpec, RangeSpecSeq};
Expand Down Expand Up @@ -432,8 +432,8 @@ pub enum Closed {
/// [`RecvStream::stop`]. We don't use this explicitly but this is here as
/// documentation as to what happened to `0`.
///
/// [`RecvStream`]: iroh_net::endpoint::RecvStream
/// [`RecvStream::stop`]: iroh_net::endpoint::RecvStream::stop
/// [`RecvStream`]: iroh::endpoint::RecvStream
/// [`RecvStream::stop`]: iroh::endpoint::RecvStream::stop
StreamDropped = 0,
/// The provider is terminating.
///
Expand Down
2 changes: 1 addition & 1 deletion src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use bao_tree::io::{
EncodeError,
};
use futures_lite::future::Boxed as BoxFuture;
use iroh::endpoint::{self, RecvStream, SendStream};
use iroh_io::{
stats::{SliceReaderStats, StreamWriterStats, TrackingSliceReader, TrackingStreamWriter},
AsyncSliceReader, AsyncStreamWriter, TokioStreamWriter,
};
use iroh_net::endpoint::{self, RecvStream, SendStream};
use serde::{Deserialize, Serialize};
use tracing::{debug, debug_span, info, trace, warn};
use tracing_futures::Instrument;
Expand Down
25 changes: 12 additions & 13 deletions src/rpc/client/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use bytes::Bytes;
use futures_lite::{Stream, StreamExt};
use futures_util::SinkExt;
use genawaiter::sync::{Co, Gen};
use iroh_net::NodeAddr;
use iroh::NodeAddr;
use portable_atomic::{AtomicU64, Ordering};
use quic_rpc::{
client::{BoxStreamSync, BoxedConnector},
Expand Down Expand Up @@ -991,8 +991,8 @@ pub struct DownloadOptions {
mod tests {
use std::{path::Path, time::Duration};

use iroh::{key::SecretKey, test_utils::DnsPkarrServer, NodeId, RelayMode};
use iroh_base::{node_addr::AddrInfoOptions, ticket::BlobTicket};
use iroh_net::{key::SecretKey, test_utils::DnsPkarrServer, NodeId, RelayMode};
use node::Node;
use rand::RngCore;
use testresult::TestResult;
Expand All @@ -1005,8 +1005,7 @@ mod tests {
//! An iroh node that just has the blobs transport
use std::{path::Path, sync::Arc};

use iroh_net::{Endpoint, NodeAddr, NodeId};
use iroh_router::Router;
use iroh::{protocol::Router, Endpoint, NodeAddr, NodeId};
use tokio_util::task::AbortOnDropHandle;

use super::RpcService;
Expand All @@ -1023,7 +1022,7 @@ mod tests {
/// An iroh node that just has the blobs transport
#[derive(Debug)]
pub struct Node {
router: iroh_router::Router,
router: iroh::protocol::Router,
client: RpcClient,
_local_pool: LocalPool,
_rpc_task: AbortOnDropHandle<()>,
Expand All @@ -1034,7 +1033,7 @@ mod tests {
pub struct Builder<S> {
store: S,
events: EventSender,
endpoint: Option<iroh_net::endpoint::Builder>,
endpoint: Option<iroh::endpoint::Builder>,
}

impl<S: crate::store::Store> Builder<S> {
Expand All @@ -1047,7 +1046,7 @@ mod tests {
}

/// Set an endpoint builder
pub fn endpoint(self, endpoint: iroh_net::endpoint::Builder) -> Self {
pub fn endpoint(self, endpoint: iroh::endpoint::Builder) -> Self {
Self {
endpoint: Some(endpoint),
..self
Expand Down Expand Up @@ -1866,13 +1865,13 @@ mod tests {
#[tokio::test]
async fn test_download_via_relay() -> Result<()> {
let _guard = iroh_test::logging::setup();
let (relay_map, relay_url, _guard) = iroh_net::test_utils::run_relay_server().await?;
let (relay_map, relay_url, _guard) = iroh::test_utils::run_relay_server().await?;

let endpoint1 = iroh_net::Endpoint::builder()
let endpoint1 = iroh::Endpoint::builder()
.relay_mode(RelayMode::Custom(relay_map.clone()))
.insecure_skip_relay_cert_verify(true);
let node1 = Node::memory().endpoint(endpoint1).spawn().await?;
let endpoint2 = iroh_net::Endpoint::builder()
let endpoint2 = iroh::Endpoint::builder()
.relay_mode(RelayMode::Custom(relay_map.clone()))
.insecure_skip_relay_cert_verify(true);
let node2 = Node::memory().endpoint(endpoint2).spawn().await?;
Expand All @@ -1897,19 +1896,19 @@ mod tests {
#[ignore = "flaky"]
async fn test_download_via_relay_with_discovery() -> Result<()> {
let _guard = iroh_test::logging::setup();
let (relay_map, _relay_url, _guard) = iroh_net::test_utils::run_relay_server().await?;
let (relay_map, _relay_url, _guard) = iroh::test_utils::run_relay_server().await?;
let dns_pkarr_server = DnsPkarrServer::run().await?;

let secret1 = SecretKey::generate();
let endpoint1 = iroh_net::Endpoint::builder()
let endpoint1 = iroh::Endpoint::builder()
.relay_mode(RelayMode::Custom(relay_map.clone()))
.insecure_skip_relay_cert_verify(true)
.dns_resolver(dns_pkarr_server.dns_resolver())
.secret_key(secret1.clone())
.discovery(dns_pkarr_server.discovery(secret1));
let node1 = Node::memory().endpoint(endpoint1).spawn().await?;
let secret2 = SecretKey::generate();
let endpoint2 = iroh_net::Endpoint::builder()
let endpoint2 = iroh::Endpoint::builder()
.relay_mode(RelayMode::Custom(relay_map.clone()))
.insecure_skip_relay_cert_verify(true)
.dns_resolver(dns_pkarr_server.dns_resolver())
Expand Down
8 changes: 4 additions & 4 deletions src/util/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,20 @@ pub fn relative_canonicalized_path_to_string(path: impl AsRef<Path>) -> anyhow::
canonicalized_path_to_string(path, true)
}

/// Loads a [`iroh_net::key::SecretKey`] from the provided file, or stores a newly generated one
/// Loads a [`iroh::key::SecretKey`] from the provided file, or stores a newly generated one
/// at the given location.
#[cfg(feature = "rpc")]
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "rpc")))]
pub async fn load_secret_key(key_path: PathBuf) -> anyhow::Result<iroh_net::key::SecretKey> {
pub async fn load_secret_key(key_path: PathBuf) -> anyhow::Result<iroh::key::SecretKey> {
use tokio::io::AsyncWriteExt;

if key_path.exists() {
let keystr = tokio::fs::read(key_path).await?;
let secret_key =
iroh_net::key::SecretKey::try_from_openssh(keystr).context("invalid keyfile")?;
iroh::key::SecretKey::try_from_openssh(keystr).context("invalid keyfile")?;
Ok(secret_key)
} else {
let secret_key = iroh_net::key::SecretKey::generate();
let secret_key = iroh::key::SecretKey::generate();
let ser_key = secret_key.to_openssh()?;

// Try to canonicalize if possible
Expand Down
Loading

0 comments on commit 24a1172

Please sign in to comment.