Skip to content

Commit e03aa6f

Browse files
feat!: update to iroh@0.98n, iroh-gossip@0.98, iroh-blobs@0.100 (#95)
## Description <!-- A summary of what this pull request achieves and a rough list of changes. --> ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented. --------- Co-authored-by: dignifiedquire <me@dignifiedquire.com>
1 parent 6e1d6c3 commit e03aa6f

8 files changed

Lines changed: 643 additions & 526 deletions

File tree

Cargo.lock

Lines changed: 591 additions & 479 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ derive_more = { version = "2.0.1", features = [
2626
"into",
2727
"as_ref",
2828
] }
29-
ed25519-dalek = { version = "3.0.0-pre.1", features = ["serde", "rand_core"] }
29+
ed25519-dalek = { version = "=3.0.0-pre.6", features = ["serde", "rand_core"] }
3030
futures-buffered = "0.2.4"
3131
futures-lite = "2.3.0"
3232
futures-util = { version = "0.3.25" }
3333
hex = "0.4"
34-
iroh = { version = "0.97", default-features = false }
35-
iroh-tickets = { version = "0.4" }
36-
iroh-blobs = { version = "0.99", default-features = false }
37-
iroh-gossip = { version = "0.97", features = ["net"], default-features = false }
34+
iroh = { version = "0.98", default-features = false }
35+
iroh-tickets = { version = "0.5" }
36+
iroh-blobs = { version = "0.100", default-features = false }
37+
iroh-gossip = { version = "0.98", features = ["net"], default-features = false }
3838
iroh-metrics = { version = "0.38", default-features = false }
39-
irpc = { version = "0.13", default-features = false }
39+
irpc = { version = "0.14", default-features = false }
4040
n0-error = "0.1.0"
4141
n0-future = { version = "0.3.1", features = ["serde"] }
4242
num_enum = "0.7"
@@ -45,13 +45,13 @@ postcard = { version = "1", default-features = false, features = [
4545
"use-std",
4646
"experimental-derive",
4747
] }
48-
noq = { version = "0.17.0", optional = true }
49-
rand = "0.9.2"
48+
noq = { version = "0.18", optional = true }
49+
rand = "0.10"
5050
redb = { version = "2.6.3" }
5151
self_cell = "1.0.3"
5252
serde = { version = "1.0.164", features = ["derive"] }
5353
serde-error = "0.1.3"
54-
strum = { version = "0.26", features = ["derive"] }
54+
strum = { version = "0.28", features = ["derive"] }
5555
tempfile = { version = "3.4" }
5656
thiserror = "2"
5757
tokio = { version = "1", features = ["sync", "rt", "time", "io-util"] }
@@ -61,14 +61,14 @@ tracing = "0.1"
6161

6262
[dev-dependencies]
6363
data-encoding = "2.6.0"
64-
iroh = { version = "0.97", features = ["test-utils"] }
64+
iroh = { version = "0.98", features = ["test-utils"] }
6565
nested_enum_utils = "0.2"
6666
parking_lot = "0.12.3"
6767
proptest = "1.2.0"
68-
rand_chacha = "0.9"
68+
rand = { version = "0.10", features = ["chacha"] }
6969
tempfile = "3.4"
7070
test-strategy = "0.4"
71-
testdir = "0.7"
71+
testdir = "0.8"
7272
testresult = "0.4.1"
7373
tokio = { version = "1", features = ["sync", "macros"] }
7474
tracing-test = "0.2.5"

src/net/codec.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ impl BobState {
251251
.await
252252
}
253253
(Message::Init { .. }, Some(_)) => {
254-
return Err(self.fail(anyhow!("double init message")))
254+
return Err(self.fail(anyhow!("double init message")));
255255
}
256256
(Message::Sync(_), None) => {
257-
return Err(self.fail(anyhow!("unexpected sync message before init")))
257+
return Err(self.fail(anyhow!("unexpected sync message before init")));
258258
}
259259
(Message::Abort { .. }, _) => {
260-
return Err(self.fail(anyhow!("unexpected sync abort message")))
260+
return Err(self.fail(anyhow!("unexpected sync abort message")));
261261
}
262262
};
263263
let (reply, progress) = next.map_err(|e| self.fail(e))?;
@@ -296,7 +296,7 @@ mod tests {
296296
use anyhow::Result;
297297
use iroh::SecretKey;
298298
use iroh_blobs::Hash;
299-
use rand::{CryptoRng, SeedableRng};
299+
use rand::{CryptoRng, RngExt, SeedableRng};
300300
use tracing_test::traced_test;
301301

302302
use super::*;
@@ -489,16 +489,16 @@ mod tests {
489489
async fn test_sync_many_authors(mut alice_store: Store, mut bob_store: Store) -> Result<()> {
490490
let num_messages = &[1, 2, 5, 10];
491491
let num_authors = &[2, 3, 4, 5, 10];
492-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(99);
492+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(99);
493493

494494
for num_messages in num_messages {
495495
for num_authors in num_authors {
496496
println!(
497497
"bob & alice each using {num_authors} authors and inserting {num_messages} messages per author"
498498
);
499499

500-
let alice_node_pubkey = SecretKey::generate(&mut rng).public();
501-
let bob_node_pubkey = SecretKey::generate(&mut rng).public();
500+
let alice_node_pubkey = SecretKey::from_bytes(&rng.random()).public();
501+
let bob_node_pubkey = SecretKey::from_bytes(&rng.random()).public();
502502
let namespace = NamespaceSecret::new(&mut rng);
503503

504504
let mut all_messages = vec![];
@@ -639,9 +639,9 @@ mod tests {
639639
}
640640

641641
async fn test_sync_timestamps(mut alice_store: Store, mut bob_store: Store) -> Result<()> {
642-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(99);
643-
let alice_node_pubkey = SecretKey::generate(&mut rng).public();
644-
let bob_node_pubkey = SecretKey::generate(&mut rng).public();
642+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(99);
643+
let alice_node_pubkey = SecretKey::from_bytes(&rng.random()).public();
644+
let bob_node_pubkey = SecretKey::from_bytes(&rng.random()).public();
645645
let namespace = NamespaceSecret::new(&mut rng);
646646

647647
let author = alice_store.new_author(&mut rng)?;

src/sync.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ mod tests {
15501550
}
15511551

15521552
async fn test_timestamps(mut store: Store) -> Result<()> {
1553-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(1);
1553+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(1);
15541554
let namespace = NamespaceSecret::new(&mut rng);
15551555
let _replica = store.new_replica(namespace.clone())?;
15561556
let author = store.new_author(&mut rng)?;
@@ -2133,7 +2133,7 @@ mod tests {
21332133

21342134
#[allow(clippy::redundant_pattern_matching)]
21352135
async fn test_replica_capability(mut store: Store) -> Result<()> {
2136-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(1);
2136+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(1);
21372137
let author = store.new_author(&mut rng)?;
21382138
let namespace = NamespaceSecret::new(&mut rng);
21392139

@@ -2182,7 +2182,7 @@ mod tests {
21822182

21832183
async fn test_actor_capability(store: Store) -> Result<()> {
21842184
// test with actor
2185-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(1);
2185+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(1);
21862186
let author = Author::new(&mut rng);
21872187
let handle = SyncHandle::spawn(store, None, "test".into());
21882188
let author = handle.import_author(author).await?;
@@ -2232,7 +2232,7 @@ mod tests {
22322232
/// (too old) by the time they are actually inserted in the store.
22332233
#[tokio::test]
22342234
async fn test_replica_no_wrong_remote_insert_events() -> Result<()> {
2235-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(1);
2235+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(1);
22362236
let mut store1 = store::Store::memory();
22372237
let mut store2 = store::Store::memory();
22382238
let peer1 = [1u8; 32];
@@ -2307,7 +2307,7 @@ mod tests {
23072307
}
23082308

23092309
async fn test_replica_queries(mut store: Store) -> Result<()> {
2310-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(1);
2310+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(1);
23112311
let namespace = NamespaceSecret::new(&mut rng);
23122312
let namespace_id = namespace.id();
23132313

@@ -2494,7 +2494,7 @@ mod tests {
24942494
}
24952495

24962496
fn test_dl_policies(store: &mut Store) -> Result<()> {
2497-
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(1);
2497+
let mut rng = rand::rngs::ChaCha12Rng::seed_from_u64(1);
24982498
let namespace = NamespaceSecret::new(&mut rng);
24992499
let id = namespace.id();
25002500

tests/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Context, Result};
22
use iroh_blobs::api::blobs::{ExportMode, ImportMode};
33
use iroh_docs::store::Query;
44
use n0_future::StreamExt;
5-
use rand::RngCore;
5+
use rand::Rng;
66
use testresult::TestResult;
77
use tokio::io::AsyncWriteExt;
88
use tracing_test::traced_test;

tests/gc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bytes::Bytes;
77
use futures_lite::StreamExt;
88
use iroh_blobs::api::blobs::ImportMode;
99
use n0_future::time::Duration;
10-
use rand::RngCore;
10+
use rand::Rng;
1111
use testdir::testdir;
1212
use util::Node;
1313

@@ -26,8 +26,10 @@ async fn persistent_node(
2626
path: PathBuf,
2727
gc_period: Duration,
2828
) -> (Node, async_channel::Receiver<()>) {
29+
use iroh::endpoint::presets;
30+
2931
let (gc_send, gc_recv) = async_channel::unbounded();
30-
let ep = iroh::Endpoint::empty_builder().bind().await.unwrap();
32+
let ep = iroh::Endpoint::bind(presets::Minimal).await.unwrap();
3133
let node = Node::persistent(path, ep)
3234
.gc_interval(Some(gc_period))
3335
.register_gc_done_cb(Box::new(move || {

tests/sync.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::{anyhow, bail, Context, Result};
44
use bytes::Bytes;
55
use futures_lite::Stream;
66
use futures_util::{FutureExt, StreamExt, TryStreamExt};
7-
use iroh::{Endpoint, PublicKey, SecretKey};
7+
use iroh::{endpoint::presets, Endpoint, PublicKey, SecretKey};
88
use iroh_blobs::Hash;
99
use iroh_docs::{
1010
api::{
@@ -16,7 +16,7 @@ use iroh_docs::{
1616
AuthorId, ContentStatus, Entry,
1717
};
1818
use n0_future::time::{Duration, Instant};
19-
use rand::{CryptoRng, Rng, SeedableRng};
19+
use rand::{CryptoRng, RngExt, SeedableRng};
2020
#[cfg(feature = "fs-store")]
2121
use tempfile::tempdir;
2222
use tracing::{debug, error_span, info, Instrument};
@@ -29,7 +29,7 @@ use crate::util::empty_endpoint;
2929
const TIMEOUT: Duration = Duration::from_secs(60);
3030

3131
async fn test_node(secret_key: SecretKey) -> Result<Builder> {
32-
let ep = Endpoint::empty_builder()
32+
let ep = Endpoint::builder(presets::Minimal)
3333
.secret_key(secret_key)
3434
.bind()
3535
.await?;
@@ -41,9 +41,9 @@ async fn test_node(secret_key: SecretKey) -> Result<Builder> {
4141
// still collecting the futures before awaiting them altogether (see [`spawn_nodes`])
4242
fn spawn_node(
4343
i: usize,
44-
rng: &mut (impl CryptoRng + Rng),
44+
rng: &mut impl CryptoRng,
4545
) -> impl Future<Output = anyhow::Result<Node>> + 'static {
46-
let secret_key = SecretKey::generate(rng);
46+
let secret_key = SecretKey::from_bytes(&rng.random());
4747
async move {
4848
let node = test_node(secret_key).await?;
4949
let node = node.spawn().await?;
@@ -52,16 +52,16 @@ fn spawn_node(
5252
}
5353
}
5454

55-
async fn spawn_nodes(n: usize, mut rng: &mut (impl CryptoRng + Rng)) -> anyhow::Result<Vec<Node>> {
55+
async fn spawn_nodes(n: usize, mut rng: &mut impl CryptoRng) -> anyhow::Result<Vec<Node>> {
5656
let mut futs = vec![];
5757
for i in 0..n {
5858
futs.push(spawn_node(i, &mut rng));
5959
}
6060
futures_buffered::join_all(futs).await.into_iter().collect()
6161
}
6262

63-
pub fn test_rng(seed: &[u8]) -> rand_chacha::ChaCha12Rng {
64-
rand_chacha::ChaCha12Rng::from_seed(*Hash::new(seed).as_bytes())
63+
pub fn test_rng(seed: &[u8]) -> rand::rngs::ChaCha12Rng {
64+
rand::rngs::ChaCha12Rng::from_seed(*Hash::new(seed).as_bytes())
6565
}
6666

6767
macro_rules! match_event {
@@ -489,20 +489,21 @@ async fn sync_subscribe_stop_close() -> Result<()> {
489489
#[tokio::test]
490490
#[traced_test]
491491
async fn test_sync_via_relay() -> Result<()> {
492+
let mut rng = test_rng(b"test_sync_via_relay");
492493
let (relay_map, _relay_url, _guard) = iroh::test_utils::run_relay_server().await?;
493494

494495
use crate::util::endpoint;
495496

496497
let ep1 = endpoint(
497-
SecretKey::generate(&mut rand::rng()),
498+
SecretKey::from_bytes(&rng.random()),
498499
relay_map.clone(),
499500
None,
500501
)
501502
.await?;
502503
let node1 = Node::memory(ep1).spawn().await?;
503504
let node1_id = node1.id();
504505
let ep2 = endpoint(
505-
SecretKey::generate(&mut rand::rng()),
506+
SecretKey::from_bytes(&rng.random()),
506507
relay_map.clone(),
507508
None,
508509
)
@@ -605,7 +606,7 @@ async fn sync_restart_node() -> Result<()> {
605606
let lookup_server = iroh::test_utils::DnsPkarrServer::run().await?;
606607

607608
let node1_dir = tempfile::TempDir::with_prefix("test-sync_restart_node-node1")?;
608-
let secret_key_1 = SecretKey::generate(&mut rng);
609+
let secret_key_1 = SecretKey::from_bytes(&rng.random());
609610

610611
let ep = endpoint(
611612
secret_key_1.clone(),
@@ -625,7 +626,7 @@ async fn sync_restart_node() -> Result<()> {
625626
.await?;
626627

627628
// create node2
628-
let secret_key_2 = SecretKey::generate(&mut rng);
629+
let secret_key_2 = SecretKey::from_bytes(&rng.random());
629630
let ep = endpoint(secret_key_2, relay_map.clone(), Some(&lookup_server)).await?;
630631
let node2 = Node::memory(ep).spawn().await?;
631632
let id2 = node2.id();

tests/util.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@ use std::{
66
};
77

88
use iroh::{
9-
endpoint::BindError, test_utils::DnsPkarrServer, tls::CaRootsConfig, Endpoint, EndpointId,
10-
RelayMap, RelayMode, SecretKey,
9+
endpoint::{presets, BindError},
10+
test_utils::DnsPkarrServer,
11+
tls::CaRootsConfig,
12+
Endpoint, EndpointId, RelayMap, RelayMode, SecretKey,
1113
};
1214
use iroh_blobs::store::GcConfig;
1315
use iroh_docs::{engine::ProtectCallbackHandler, protocol::Docs};
1416
use iroh_gossip::net::Gossip;
1517
use n0_error::Result;
1618

1719
pub async fn empty_endpoint() -> Result<Endpoint, BindError> {
18-
Endpoint::empty_builder().bind().await
20+
Endpoint::bind(presets::Minimal).await
1921
}
2022

2123
pub async fn endpoint(
2224
secret_key: SecretKey,
2325
relay_map: RelayMap,
2426
dns_pkarr_server: Option<&DnsPkarrServer>,
2527
) -> Result<Endpoint, BindError> {
26-
let mut builder = Endpoint::empty_builder();
28+
let mut builder = Endpoint::builder(presets::Minimal);
2729
if let Some(dns_pkarr_server) = dns_pkarr_server {
2830
builder = builder.preset(dns_pkarr_server.preset());
2931
}

0 commit comments

Comments
 (0)