From c15c98959ce52ce21c1f61fca3228a1ac7371055 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Tue, 24 Nov 2026 05:48:13 -0600 Subject: [PATCH 1/2] id: adapt id-store and id-worlds to iroh-blobs 0.105 and redb 5 (#14315) Bridge iroh-blobs 0.103 hashes used by iroh-docs 0.101 byte-wise, and drop the redb 5 range turbofish. id-cli still needs the iroh-gossip 0.103 and blob-store adaptation; that remains open on #14315. --- pkgs/id/Cargo.lock | 2 ++ .../src/event_store/author_events.rs | 2 +- .../id-events/src/event_store/validity.rs | 2 +- pkgs/id/crates/id-store/Cargo.toml | 2 ++ pkgs/id/crates/id-store/src/graph_index.rs | 2 +- pkgs/id/crates/id-store/src/tags.rs | 22 +++++++++++++++---- pkgs/id/crates/id-worlds/Cargo.toml | 2 ++ pkgs/id/crates/id-worlds/src/world_records.rs | 14 +++++++++--- 8 files changed, 38 insertions(+), 10 deletions(-) diff --git a/pkgs/id/Cargo.lock b/pkgs/id/Cargo.lock index 7da15b5441..ebc057b135 100644 --- a/pkgs/id/Cargo.lock +++ b/pkgs/id/Cargo.lock @@ -5184,6 +5184,7 @@ dependencies = [ "id-core", "iroh", "iroh-base", + "iroh-blobs 0.103.1", "iroh-blobs 0.105.0", "iroh-docs", "iroh-gossip 0.103.0", @@ -5317,6 +5318,7 @@ dependencies = [ "id-sync", "iroh", "iroh-base", + "iroh-blobs 0.103.1", "iroh-blobs 0.105.0", "iroh-docs", "iroh-gossip 0.103.0", diff --git a/pkgs/id/crates/id-events/src/event_store/author_events.rs b/pkgs/id/crates/id-events/src/event_store/author_events.rs index b82d11fba9..a47faf00de 100644 --- a/pkgs/id/crates/id-events/src/event_store/author_events.rs +++ b/pkgs/id/crates/id-events/src/event_store/author_events.rs @@ -26,7 +26,7 @@ use std::collections::{BTreeMap, BTreeSet, VecDeque}; use p2panda_core::{Hash, SeqNum}; -use redb::ReadableDatabase; +use redb::{ReadableDatabase, ReadableTable}; use id_core::waiting::AuthorKey; use id_store::chain::Event; diff --git a/pkgs/id/crates/id-events/src/event_store/validity.rs b/pkgs/id/crates/id-events/src/event_store/validity.rs index f6a1f96304..9e73e248f5 100644 --- a/pkgs/id/crates/id-events/src/event_store/validity.rs +++ b/pkgs/id/crates/id-events/src/event_store/validity.rs @@ -14,7 +14,7 @@ //! (rules 2–4), which is [`Validity::Voided`]. use p2panda_core::Hash; -use redb::ReadableDatabase; +use redb::{ReadableDatabase, ReadableTable}; use super::{ APPLIED, EventStore, FORKS, HASHES, PROOF_IDS, StoreError, lowest_proof, split_position, diff --git a/pkgs/id/crates/id-store/Cargo.toml b/pkgs/id/crates/id-store/Cargo.toml index 2b8b4f6b11..3f203e26c6 100644 --- a/pkgs/id/crates/id-store/Cargo.toml +++ b/pkgs/id/crates/id-store/Cargo.toml @@ -31,6 +31,8 @@ id-core = { path = "../id-core", default-features = false } iroh = "1" iroh-base = "1" iroh-blobs = "0.105" +# The hash type iroh-docs 0.101 uses; pinned to the same 0.103 it depends on. +iroh-blobs-docs = { package = "iroh-blobs", version = "0.103.1" } iroh-docs = "0.101" p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } # Store traits only. The default features would pull in SQLite. diff --git a/pkgs/id/crates/id-store/src/graph_index.rs b/pkgs/id/crates/id-store/src/graph_index.rs index 8ff278c92e..cb56a62538 100644 --- a/pkgs/id/crates/id-store/src/graph_index.rs +++ b/pkgs/id/crates/id-store/src/graph_index.rs @@ -609,7 +609,7 @@ impl GraphIndex { let mut last_key = None; let mut more = false; for entry in table - .range::<&[u8]>((lower, Bound::Unbounded)) + .range((lower, Bound::Unbounded)) .map_err(storage)? { let (key, _) = entry.map_err(storage)?; diff --git a/pkgs/id/crates/id-store/src/tags.rs b/pkgs/id/crates/id-store/src/tags.rs index 07f74e8605..e78479ca0e 100644 --- a/pkgs/id/crates/id-store/src/tags.rs +++ b/pkgs/id/crates/id-store/src/tags.rs @@ -866,12 +866,13 @@ impl TagStore { let alpha_key = encode_alpha_key(subject, key, value); let omega_key = encode_omega_key(subject, key, value); + let docs_hash = docs_hash(hash); ns.alpha - .set_hash(self.author, alpha_key, hash, size) + .set_hash(self.author, alpha_key, docs_hash, size) .await .context("writing α entry")?; ns.omega - .set_hash(self.author, omega_key, hash, size) + .set_hash(self.author, omega_key, docs_hash, size) .await .context("writing Ω entry")?; @@ -1477,6 +1478,19 @@ async fn query_omega_prefix(doc: &Doc, prefix: &[u8]) -> Result> { Ok(tags) } +/// Convert a content hash from the iroh-docs hash type to the blob-store type. +/// +/// iroh-docs 0.101 pins iroh-blobs 0.103 while this crate uses 0.105; both +/// wrap the same 32-byte BLAKE3 digest. +fn docs_hash(hash: Hash) -> iroh_blobs_docs::Hash { + iroh_blobs_docs::Hash::from_bytes(*hash.as_bytes()) +} + +/// Convert an iroh-docs content hash to the blob-store type. +fn blob_hash(hash: iroh_blobs_docs::Hash) -> Hash { + Hash::from_bytes(*hash.as_bytes()) +} + /// Convert an α entry to a [`Tag`]. fn entry_to_tag_alpha(entry: &iroh_docs::Entry) -> Result { let (subject, key, value) = decode_alpha_key(entry.key())?; @@ -1484,7 +1498,7 @@ fn entry_to_tag_alpha(entry: &iroh_docs::Entry) -> Result { subject, key, value, - hash: entry.content_hash(), + hash: blob_hash(entry.content_hash()), len: entry.content_len(), timestamp: entry.timestamp(), author: entry.author(), @@ -1498,7 +1512,7 @@ fn entry_to_tag_omega(entry: &iroh_docs::Entry) -> Result { subject, key, value, - hash: entry.content_hash(), + hash: blob_hash(entry.content_hash()), len: entry.content_len(), timestamp: entry.timestamp(), author: entry.author(), diff --git a/pkgs/id/crates/id-worlds/Cargo.toml b/pkgs/id/crates/id-worlds/Cargo.toml index 84c6212afe..73b2a7abb0 100644 --- a/pkgs/id/crates/id-worlds/Cargo.toml +++ b/pkgs/id/crates/id-worlds/Cargo.toml @@ -64,6 +64,8 @@ id-sync = { path = "../id-sync", default-features = false } iroh = "1" iroh-base = "1" iroh-blobs = "0.105" +# The hash type iroh-docs 0.101 uses; pinned to the same 0.103 it depends on. +iroh-blobs-docs = { package = "iroh-blobs", version = "0.103.1" } iroh-docs = "0.101" iroh-gossip = { version = "0.103", features = ["net"] } libc = "0.2" diff --git a/pkgs/id/crates/id-worlds/src/world_records.rs b/pkgs/id/crates/id-worlds/src/world_records.rs index 1e95e0bb43..ae219af4b2 100644 --- a/pkgs/id/crates/id-worlds/src/world_records.rs +++ b/pkgs/id/crates/id-worlds/src/world_records.rs @@ -47,6 +47,14 @@ pub struct RecordsStore { author: AuthorId, } +/// Convert an iroh-docs content hash to the blob-store type. +/// +/// iroh-docs 0.101 pins iroh-blobs 0.103 while this crate uses 0.105; both +/// wrap the same 32-byte BLAKE3 digest. +fn blob_hash(hash: iroh_blobs_docs::Hash) -> Hash { + Hash::from_bytes(*hash.as_bytes()) +} + fn doc_key(key: &str) -> Vec { let mut bytes = Vec::with_capacity(key.len() + 1); bytes.extend_from_slice(key.as_bytes()); @@ -166,7 +174,7 @@ impl RecordsStore { tokio::pin!(entries); while let Some(entry) = entries.try_next().await? { if let Some(key) = record_key(entry.key()) { - existing.insert(key.to_owned(), entry.content_hash()); + existing.insert(key.to_owned(), blob_hash(entry.content_hash())); } } // Delete obsolete keys before writing additions (Codex review @@ -263,7 +271,7 @@ pub async fn read_records(doc: &Doc, blobs: &Store) -> Result { ); let bytes = blobs .blobs() - .get_bytes(entry.content_hash()) + .get_bytes(blob_hash(entry.content_hash())) .await .with_context(|| format!("content of record {key:?} is not available yet"))?; // A duplicate key is a parse error (#6520, #6634): the cap below @@ -323,7 +331,7 @@ pub async fn replicate( let mut missing = false; while let Some(entry) = entries.try_next().await? { announced += 1; - if !blobs.blobs().has(entry.content_hash()).await? { + if !blobs.blobs().has(blob_hash(entry.content_hash())).await? { missing = true; } } From 14b85c2366bafbfbd8ed9094a01bce3f6fa27645 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Tue, 24 Nov 2026 10:17:17 -0600 Subject: [PATCH 2/2] Fix id workspace build against grouped dependency bump Pin iroh-blobs 0.103 and iroh-gossip 0.101 across pkgs/id so iroh-docs matches its Hash type, drop the hash bridge helpers, and adapt comrak 1.1.0 node constructors, redb 5 backends and compaction, and the world contract test to current shapes. Refs #14315, #14396. --- pkgs/id/Cargo.lock | 187 +++--------------- pkgs/id/Cargo.toml | 6 +- pkgs/id/crates/id-cli/Cargo.toml | 4 +- pkgs/id/crates/id-cli/src/commands/world.rs | 3 +- pkgs/id/crates/id-core/Cargo.toml | 2 +- pkgs/id/crates/id-events/Cargo.toml | 2 +- pkgs/id/crates/id-groups/Cargo.toml | 2 +- pkgs/id/crates/id-native-shell/Cargo.toml | 2 +- pkgs/id/crates/id-store/Cargo.toml | 6 +- pkgs/id/crates/id-store/src/tags.rs | 22 +-- .../id-store/tests/graph_encoding_bakeoff.rs | 14 +- pkgs/id/crates/id-sync/Cargo.toml | 4 +- pkgs/id/crates/id-web/Cargo.toml | 4 +- pkgs/id/crates/id-web/src/identity.rs | 2 +- pkgs/id/crates/id-web/src/markdown.rs | 176 +++++++---------- .../src/markdown/markdown_serialization.rs | 4 +- .../id-web/src/markdown/prosemirror_json.rs | 23 ++- pkgs/id/crates/id-worlds/Cargo.toml | 6 +- .../crates/id-worlds/src/world/spill_pool.rs | 41 ++-- pkgs/id/crates/id-worlds/src/world_records.rs | 14 +- pkgs/id/tests/common/ingest.rs | 12 +- pkgs/id/tests/crash/faultfs.rs | 17 +- pkgs/id/tests/crash/store.rs | 2 +- 23 files changed, 176 insertions(+), 379 deletions(-) diff --git a/pkgs/id/Cargo.lock b/pkgs/id/Cargo.lock index 3f64f13ab3..f7b3e03e71 100644 --- a/pkgs/id/Cargo.lock +++ b/pkgs/id/Cargo.lock @@ -744,25 +744,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "bao-tree" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d0e17303b78c9bb240014f3f401ecae5c0460438ace49a171e5f97e3ae57ba" -dependencies = [ - "blake3", - "bytes", - "futures-lite", - "genawaiter", - "iroh-io", - "positioned-io", - "range-collections", - "self_cell", - "serde", - "smallvec", - "tokio", -] - [[package]] name = "base16ct" version = "0.2.0" @@ -3240,7 +3221,7 @@ dependencies = [ "futures-lite", "getrandom 0.4.3", "iroh", - "iroh-gossip 0.101.0", + "iroh-gossip", "mainline", "postcard", "rand 0.10.4", @@ -4866,9 +4847,9 @@ dependencies = [ "id-worlds", "iroh", "iroh-base", - "iroh-blobs 0.105.0", + "iroh-blobs", "iroh-docs", - "iroh-gossip 0.103.0", + "iroh-gossip", "iroh-mainline-address-lookup", "iroh-mdns-address-lookup", "iroh-tickets", @@ -4946,9 +4927,9 @@ dependencies = [ "id-worlds", "iroh", "iroh-base", - "iroh-blobs 0.105.0", + "iroh-blobs", "iroh-docs", - "iroh-gossip 0.103.0", + "iroh-gossip", "iroh-mdns-address-lookup", "libc", "p2panda-core", @@ -5012,7 +4993,7 @@ dependencies = [ "idna", "iroh", "iroh-base", - "iroh-blobs 0.105.0", + "iroh-blobs", "p2panda-auth", "p2panda-core", "postcard", @@ -5087,7 +5068,7 @@ dependencies = [ "id-store", "iroh", "iroh-base", - "iroh-blobs 0.105.0", + "iroh-blobs", "p2panda-auth", "p2panda-core", "proptest", @@ -5111,7 +5092,7 @@ dependencies = [ "id-events", "id-store", "iroh-base", - "iroh-blobs 0.105.0", + "iroh-blobs", "p2panda-core", "p2panda-encryption", "postcard", @@ -5156,7 +5137,7 @@ dependencies = [ "id", "id-worlds", "iroh", - "iroh-blobs 0.105.0", + "iroh-blobs", "libc", "serde_json", "tokio", @@ -5192,10 +5173,9 @@ dependencies = [ "id-core", "iroh", "iroh-base", - "iroh-blobs 0.103.1", - "iroh-blobs 0.105.0", + "iroh-blobs", "iroh-docs", - "iroh-gossip 0.103.0", + "iroh-gossip", "p2panda-core", "p2panda-store", "postcard", @@ -5228,9 +5208,9 @@ dependencies = [ "id-store", "iroh", "iroh-base", - "iroh-blobs 0.105.0", + "iroh-blobs", "iroh-docs", - "iroh-gossip 0.103.0", + "iroh-gossip", "iroh-mainline-address-lookup", "iroh-tickets", "p2panda-auth", @@ -5283,9 +5263,9 @@ dependencies = [ "id-worlds", "iroh", "iroh-base", - "iroh-blobs 0.105.0", + "iroh-blobs", "iroh-docs", - "iroh-gossip 0.103.0", + "iroh-gossip", "mime_guess", "p2panda-core", "proptest", @@ -5326,10 +5306,9 @@ dependencies = [ "id-sync", "iroh", "iroh-base", - "iroh-blobs 0.103.1", - "iroh-blobs 0.105.0", + "iroh-blobs", "iroh-docs", - "iroh-gossip 0.103.0", + "iroh-gossip", "libc", "p2panda-core", "postcard", @@ -5558,47 +5537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3148ad01585eb6b7cfb641e4100564f4f56db644f4cbed8c10ab2478663161f" dependencies = [ "arrayvec", - "bao-tree 0.16.1", - "bytes", - "cfg_aliases", - "chrono", - "constant_time_eq", - "data-encoding", - "derive_more", - "genawaiter", - "getrandom 0.4.3", - "hex", - "iroh", - "iroh-base", - "iroh-io", - "iroh-metrics", - "iroh-tickets", - "iroh-util 0.6.0", - "irpc 0.17.0", - "n0-error", - "n0-future", - "nested_enum_utils", - "noq", - "postcard", - "rand 0.10.4", - "range-collections", - "redb 4.6.0", - "ref-cast", - "reflink-copy", - "self_cell", - "serde", - "smallvec", - "tokio", - "tracing", -] - -[[package]] -name = "iroh-blobs" -version = "0.105.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ef502f80b48a0d87bc6b4212a9140ecc2915e2683cb3f2606b9241fec4349a" -dependencies = [ - "bao-tree 0.17.0", + "bao-tree", "bytes", "cfg_aliases", "chrono", @@ -5613,9 +5552,8 @@ dependencies = [ "iroh-io", "iroh-metrics", "iroh-tickets", - "iroh-util 0.7.0", - "irpc 1.0.0", - "libc", + "iroh-util", + "irpc", "n0-error", "n0-future", "nested_enum_utils", @@ -5631,7 +5569,6 @@ dependencies = [ "smallvec", "tokio", "tracing", - "windows-sys 0.61.2", ] [[package]] @@ -5672,11 +5609,11 @@ dependencies = [ "futures-buffered", "hex", "iroh", - "iroh-blobs 0.103.1", - "iroh-gossip 0.101.0", + "iroh-blobs", + "iroh-gossip", "iroh-metrics", "iroh-tickets", - "irpc 0.17.0", + "irpc", "n0-error", "n0-future", "noq", @@ -5713,7 +5650,7 @@ dependencies = [ "iroh", "iroh-base", "iroh-metrics", - "irpc 0.17.0", + "irpc", "n0-error", "n0-future", "postcard", @@ -5724,32 +5661,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "iroh-gossip" -version = "0.103.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74c4170847b5603f489c4d7771f1e7b263fa63a2521dbbb747601931987aa777" -dependencies = [ - "blake3", - "bytes", - "data-encoding", - "derive_more", - "hex", - "indexmap", - "iroh", - "iroh-base", - "iroh-metrics", - "n0-error", - "n0-future", - "postcard", - "rand 0.10.4", - "rustc-hash 2.1.3", - "serde", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "iroh-io" version = "0.6.2" @@ -5922,20 +5833,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "iroh-util" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "889d5cc9da2eaac9f63657237c491db17d1fe9fffdc7c0f2f0e04c49d5d45053" -dependencies = [ - "derive_more", - "iroh", - "n0-error", - "n0-future", - "tokio", - "tracing", -] - [[package]] name = "irpc" version = "0.17.0" @@ -5944,30 +5841,7 @@ checksum = "3623d6ff582b415904b29bbe6ebcb4a4f9a262ccdee05a45fdd003ef0950c386" dependencies = [ "futures-buffered", "futures-util", - "irpc-derive 0.17.0", - "n0-error", - "n0-future", - "noq", - "postcard", - "rcgen", - "rustls", - "serde", - "smallvec", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "irpc" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fecfcc2a6db86a2a0c1d8138fd58cd83e882e9923cb9e4faf5962ffa2b5a6f7e" -dependencies = [ - "derive_more", - "futures-buffered", - "futures-util", - "irpc-derive 1.0.0", + "irpc-derive", "n0-error", "n0-future", "noq", @@ -5992,17 +5866,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "irpc-derive" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c29e19b1a86c662125cdaa33860723dc966c4f50cad207d21ea64b4a14b51aa" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.10", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.2" diff --git a/pkgs/id/Cargo.toml b/pkgs/id/Cargo.toml index a6fd623680..403775f863 100644 --- a/pkgs/id/Cargo.toml +++ b/pkgs/id/Cargo.toml @@ -145,9 +145,9 @@ iroh-tickets = "1" # against: Docs::spawn takes their Store and Gossip types, so a newer # release cannot be mixed in until iroh-docs moves to it (iroh-docs 0.101 # needs iroh-blobs 0.103 and iroh-gossip 0.101). -iroh-blobs = "0.105" +iroh-blobs = "0.103" iroh-docs = "0.101" -iroh-gossip = { version = "0.103", features = ["net"] } +iroh-gossip = { version = "0.101", features = ["net"] } p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } # Store traits only. The default features would pull in SQLite (explainers section 14). p2panda-store = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc", default-features = false } @@ -248,7 +248,7 @@ iroh = { version = "1", features = ["test-utils"] } # In-memory blob store for the MCP bridge end-to-end test's world host # (tests/mcp_bridge_e2e.rs, #7914). Dev only; already in the lock via the # root package's own iroh-blobs dependency. -iroh-blobs = "0.105" +iroh-blobs = "0.103" # Parses the relay kit's configs in tests/relay_ops.rs. Dev only. toml = "1" # Local mainline DHT testnet for tests/dht_testnet.rs (P7.3). Dev only; already in the lock via the `dht` feature. diff --git a/pkgs/id/crates/id-cli/Cargo.toml b/pkgs/id/crates/id-cli/Cargo.toml index bb782398c1..47a806aabb 100644 --- a/pkgs/id/crates/id-cli/Cargo.toml +++ b/pkgs/id/crates/id-cli/Cargo.toml @@ -36,9 +36,9 @@ ed25519-dalek = { version = "3", features = ["rand_core"] } futures-lite = "2" iroh = "1" iroh-base = "1" -iroh-blobs = "0.105" +iroh-blobs = "0.103" iroh-docs = "0.101" -iroh-gossip = { version = "0.103", features = ["net"] } +iroh-gossip = { version = "0.101", features = ["net"] } iroh-mdns-address-lookup = "0.6" libc = "0.2" p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } diff --git a/pkgs/id/crates/id-cli/src/commands/world.rs b/pkgs/id/crates/id-cli/src/commands/world.rs index 95b2f14754..30b8351945 100644 --- a/pkgs/id/crates/id-cli/src/commands/world.rs +++ b/pkgs/id/crates/id-cli/src/commands/world.rs @@ -1875,6 +1875,7 @@ fn render_view_frame( id_worlds::world_presentation::WorldSurface::Scene(_) => None, id_worlds::world_presentation::WorldSurface::Audio(_) => None, id_worlds::world_presentation::WorldSurface::Widget(_) => None, + id_worlds::world_presentation::WorldSurface::Media(_) => None, } } @@ -2587,7 +2588,7 @@ mod tests { .join("\n"); assert_eq!( check_contract(&good).unwrap(), - "6 frames conform to shell contract v1.15" + "6 frames conform to shell contract v1.16" ); let bad = [ r#"{"from": "client", "frame": {"type": "chat", "text": "too early"}}"#, diff --git a/pkgs/id/crates/id-core/Cargo.toml b/pkgs/id/crates/id-core/Cargo.toml index 3873229ecc..db55f43206 100644 --- a/pkgs/id/crates/id-core/Cargo.toml +++ b/pkgs/id/crates/id-core/Cargo.toml @@ -36,7 +36,7 @@ futures-lite = "2" idna = "1" iroh = "1" iroh-base = "1" -iroh-blobs = "0.105" +iroh-blobs = "0.103" p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc", features = [ "serde", diff --git a/pkgs/id/crates/id-events/Cargo.toml b/pkgs/id/crates/id-events/Cargo.toml index 11dfaf42cd..c51af1a19a 100644 --- a/pkgs/id/crates/id-events/Cargo.toml +++ b/pkgs/id/crates/id-events/Cargo.toml @@ -29,7 +29,7 @@ clap = { version = "4", features = ["derive"] } id-core = { path = "../id-core", default-features = false } id-store = { path = "../id-store", default-features = false } iroh-base = "1" -iroh-blobs = "0.105" +iroh-blobs = "0.103" iroh = "1" p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc", features = [ "serde", diff --git a/pkgs/id/crates/id-groups/Cargo.toml b/pkgs/id/crates/id-groups/Cargo.toml index 84cd7dfd5f..c0f78d217b 100644 --- a/pkgs/id/crates/id-groups/Cargo.toml +++ b/pkgs/id/crates/id-groups/Cargo.toml @@ -25,7 +25,7 @@ id-core = { path = "../id-core", default-features = false } id-events = { path = "../id-events", default-features = false } id-store = { path = "../id-store", default-features = false } iroh-base = "1" -iroh-blobs = "0.105" +iroh-blobs = "0.103" p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } p2panda-encryption = { path = "../../vendor/p2panda-encryption", default-features = false, features = [ "data_scheme", diff --git a/pkgs/id/crates/id-native-shell/Cargo.toml b/pkgs/id/crates/id-native-shell/Cargo.toml index 851cbb7751..208286edb5 100644 --- a/pkgs/id/crates/id-native-shell/Cargo.toml +++ b/pkgs/id/crates/id-native-shell/Cargo.toml @@ -58,7 +58,7 @@ libc = "0.2" id-worlds = { path = "../id-worlds", default-features = false, features = [ "sandbox", ] } -iroh-blobs = "0.105" +iroh-blobs = "0.103" # The F13.7 end-to-end test observes the host's F12.6 audit trail # through its public emission surface: every audit record is also # emitted as a tracing event on the `id::audit` target (the record diff --git a/pkgs/id/crates/id-store/Cargo.toml b/pkgs/id/crates/id-store/Cargo.toml index 3f203e26c6..7e7964a3be 100644 --- a/pkgs/id/crates/id-store/Cargo.toml +++ b/pkgs/id/crates/id-store/Cargo.toml @@ -30,9 +30,7 @@ futures-lite = "2" id-core = { path = "../id-core", default-features = false } iroh = "1" iroh-base = "1" -iroh-blobs = "0.105" -# The hash type iroh-docs 0.101 uses; pinned to the same 0.103 it depends on. -iroh-blobs-docs = { package = "iroh-blobs", version = "0.103.1" } +iroh-blobs = "0.103" iroh-docs = "0.101" p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } # Store traits only. The default features would pull in SQLite. @@ -52,7 +50,7 @@ unicode-normalization = "0.1" # on it; production code in this crate never names the facade. dcbor = "=0.25.2" id = { path = "../.." } -iroh-gossip = { version = "0.103", features = ["net"] } +iroh-gossip = { version = "0.101", features = ["net"] } # Property tests for the chat-anchor fold (#5872): permutation invariance and # duplicate-delivery idempotence over generated event logs. proptest = "1.12" diff --git a/pkgs/id/crates/id-store/src/tags.rs b/pkgs/id/crates/id-store/src/tags.rs index e78479ca0e..07f74e8605 100644 --- a/pkgs/id/crates/id-store/src/tags.rs +++ b/pkgs/id/crates/id-store/src/tags.rs @@ -866,13 +866,12 @@ impl TagStore { let alpha_key = encode_alpha_key(subject, key, value); let omega_key = encode_omega_key(subject, key, value); - let docs_hash = docs_hash(hash); ns.alpha - .set_hash(self.author, alpha_key, docs_hash, size) + .set_hash(self.author, alpha_key, hash, size) .await .context("writing α entry")?; ns.omega - .set_hash(self.author, omega_key, docs_hash, size) + .set_hash(self.author, omega_key, hash, size) .await .context("writing Ω entry")?; @@ -1478,19 +1477,6 @@ async fn query_omega_prefix(doc: &Doc, prefix: &[u8]) -> Result> { Ok(tags) } -/// Convert a content hash from the iroh-docs hash type to the blob-store type. -/// -/// iroh-docs 0.101 pins iroh-blobs 0.103 while this crate uses 0.105; both -/// wrap the same 32-byte BLAKE3 digest. -fn docs_hash(hash: Hash) -> iroh_blobs_docs::Hash { - iroh_blobs_docs::Hash::from_bytes(*hash.as_bytes()) -} - -/// Convert an iroh-docs content hash to the blob-store type. -fn blob_hash(hash: iroh_blobs_docs::Hash) -> Hash { - Hash::from_bytes(*hash.as_bytes()) -} - /// Convert an α entry to a [`Tag`]. fn entry_to_tag_alpha(entry: &iroh_docs::Entry) -> Result { let (subject, key, value) = decode_alpha_key(entry.key())?; @@ -1498,7 +1484,7 @@ fn entry_to_tag_alpha(entry: &iroh_docs::Entry) -> Result { subject, key, value, - hash: blob_hash(entry.content_hash()), + hash: entry.content_hash(), len: entry.content_len(), timestamp: entry.timestamp(), author: entry.author(), @@ -1512,7 +1498,7 @@ fn entry_to_tag_omega(entry: &iroh_docs::Entry) -> Result { subject, key, value, - hash: blob_hash(entry.content_hash()), + hash: entry.content_hash(), len: entry.content_len(), timestamp: entry.timestamp(), author: entry.author(), diff --git a/pkgs/id/crates/id-store/tests/graph_encoding_bakeoff.rs b/pkgs/id/crates/id-store/tests/graph_encoding_bakeoff.rs index 7dbac35e45..9c56654fbe 100644 --- a/pkgs/id/crates/id-store/tests/graph_encoding_bakeoff.rs +++ b/pkgs/id/crates/id-store/tests/graph_encoding_bakeoff.rs @@ -67,7 +67,7 @@ use std::time::Instant; use id_core::tuple::{TupleEncoder, TupleValue, decode as decode_tuple}; use id_shape::{ContentId, HashProfile}; -use redb::{Database, ReadableDatabase, TableDefinition}; +use redb::{CompactionMode, Database, ReadableDatabase, ReadableTable, TableDefinition}; use rusqlite::{Connection, OptionalExtension, params}; use serde_json::{Value as Json, json}; use sha2::{Digest, Sha256}; @@ -546,7 +546,7 @@ impl RedbTuple { let txn = self.db.begin_read().unwrap(); let table = txn.open_table(table).unwrap(); let mut out = Vec::new(); - for entry in table.range::<&[u8]>(prefix..).unwrap() { + for entry in table.range(prefix..).unwrap() { let (key, _) = entry.unwrap(); let key = key.value(); if !key.starts_with(prefix) { @@ -588,11 +588,7 @@ impl Engine for RedbTuple { let lower = after.map_or(Bound::Unbounded, Bound::Excluded); let mut out = Vec::new(); let mut last = None; - for entry in table - .range::<&[u8]>((lower, Bound::Unbounded)) - .unwrap() - .take(limit) - { + for entry in table.range((lower, Bound::Unbounded)).unwrap().take(limit) { let (key, _) = entry.unwrap(); let [s, p, o] = untuple3(key.value()); out.push(Triple::new(s, p, o)); @@ -615,14 +611,14 @@ impl Engine for RedbTuple { } fn compact(&mut self) -> u64 { - while self.db.compact().unwrap() {} + while self.db.compact(CompactionMode::Balanced).unwrap() {} self.file_bytes() } fn metadata(&self) -> Json { json!({ "engine": "redb", - "engine_version": "4.6.0", + "engine_version": "5.0.0", "schema": "tables spo and pos: TableDefinition<&[u8], ()>; key = id_core::tuple bytes(s).bytes(p).bytes(o) (pos: p, o, s) over canonical term bytes", "indexes": ["spo tuple-key table", "pos tuple-key table"], "query_plans": { diff --git a/pkgs/id/crates/id-sync/Cargo.toml b/pkgs/id/crates/id-sync/Cargo.toml index 49ab979620..6ebfe11608 100644 --- a/pkgs/id/crates/id-sync/Cargo.toml +++ b/pkgs/id/crates/id-sync/Cargo.toml @@ -41,7 +41,7 @@ id-events = { path = "../id-events", default-features = false } id-store = { path = "../id-store", default-features = false } iroh = "1" iroh-base = "1" -iroh-blobs = "0.105" +iroh-blobs = "0.103" iroh-mainline-address-lookup = { version = "0.6", optional = true } p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } p2panda-store = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc", default-features = false } @@ -59,7 +59,7 @@ tracing = "0.1" # oracle signs with the same crate the production envelope path uses. ed25519-dalek = { version = "3", features = ["rand_core"] } iroh-docs = "0.101" -iroh-gossip = { version = "0.103", features = ["net"] } +iroh-gossip = { version = "0.101", features = ["net"] } p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc", features = [ "serde", ] } diff --git a/pkgs/id/crates/id-web/Cargo.toml b/pkgs/id/crates/id-web/Cargo.toml index 9ec04fdf31..6cf703087d 100644 --- a/pkgs/id/crates/id-web/Cargo.toml +++ b/pkgs/id/crates/id-web/Cargo.toml @@ -36,7 +36,7 @@ id-sync = { path = "../id-sync", default-features = false } id-worlds = { path = "../id-worlds", default-features = false } iroh = "1" iroh-base = "1" -iroh-blobs = "0.105" +iroh-blobs = "0.103" redb = "=5.0.0" rmp-serde = "1" serde = { version = "1", features = ["derive"] } @@ -76,7 +76,7 @@ id-worlds = { path = "../id-worlds", default-features = false, features = [ ] } iroh = "1" iroh-docs = "0.101" -iroh-gossip = { version = "0.103", features = ["net"] } +iroh-gossip = { version = "0.101", features = ["net"] } proptest = "1.12" tempfile = "3" futures-util = { version = "0.3", features = ["sink"] } diff --git a/pkgs/id/crates/id-web/src/identity.rs b/pkgs/id/crates/id-web/src/identity.rs index cc0f991d41..7b8b1b8612 100644 --- a/pkgs/id/crates/id-web/src/identity.rs +++ b/pkgs/id/crates/id-web/src/identity.rs @@ -701,7 +701,7 @@ impl IdentityDb { .open(&temp) .with_context(|| format!("failed to create identity store {}", temp.display()))?; let db = Database::builder() - .create_file(file) + .create_with_backend(redb::backends::FileBackend::new(file)) .map_err(|e| store_error(&temp, e))?; let created = Self::load(db, key)?; std::fs::rename(&temp, path).with_context(|| { diff --git a/pkgs/id/crates/id-web/src/markdown.rs b/pkgs/id/crates/id-web/src/markdown.rs index 99275dde55..93fb01bc10 100644 --- a/pkgs/id/crates/id-web/src/markdown.rs +++ b/pkgs/id/crates/id-web/src/markdown.rs @@ -280,11 +280,7 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> let level = json["attrs"]["level"].as_u64().unwrap_or(1).clamp(1, 6); #[allow(clippy::cast_possible_truncation)] // level is clamped to 1-6 before narrowing let level = level as u8; - NodeValue::Heading(comrak::nodes::NodeHeading { - level, - setext: false, - closed: false, - }) + NodeValue::Heading(comrak::nodes::NodeHeading::new(level)) } "blockquote" => NodeValue::BlockQuote, @@ -308,32 +304,24 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> // attr and keep the fenced emit below — no retro-guessing. if info == "html" && json["attrs"]["htmlBlock"].as_bool() == Some(true) { return Ok(arena.alloc(AstNode::from(NodeValue::HtmlBlock( - comrak::nodes::NodeHtmlBlock { - literal: format!("{content}\n"), - ..Default::default() - }, + comrak::nodes::NodeHtmlBlock::new(format!("{content}\n")), )))); } - NodeValue::CodeBlock(Box::new(comrak::nodes::NodeCodeBlock { - fenced: true, - fence_char: b'`', - fence_length: 3, - fence_offset: 0, - info: info.to_owned(), - // #954: comrak's own empty-fence literal is empty; appending - // the usual trailing newline here renders a spurious blank - // line inside the fence ("```\n\n```"). - literal: if content.is_empty() { - String::new() - } else { - format!("{content}\n") - }, - closed: false, - })) + // #954: comrak's own empty-fence literal is empty; appending + // the usual trailing newline here renders a spurious blank + // line inside the fence ("```\n\n```"). + let literal = if content.is_empty() { + String::new() + } else { + format!("{content}\n") + }; + let mut code_block = comrak::nodes::NodeCodeBlock::fenced(info, literal); + code_block.closed = false; + NodeValue::CodeBlock(Box::new(code_block)) } - "horizontal_rule" => NodeValue::ThematicBreak, + "horizontal_rule" => NodeValue::ThematicBreak(Default::default()), // #1369: YAML front matter (`---` delimiter only; comrak has no // TOML `+++` support) carried verbatim in the `text` attr. @@ -343,12 +331,7 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> "bullet_list" => { let tight = json["attrs"]["tight"].as_bool().unwrap_or(false); - NodeValue::List(comrak::nodes::NodeList { - list_type: ListType::Bullet, - tight, - bullet_char: b'-', - ..Default::default() - }) + NodeValue::List(comrak::nodes::NodeList::bullet(b'-', tight)) } "ordered_list" => { @@ -357,13 +340,11 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> let tight = json["attrs"]["tight"].as_bool().unwrap_or(false); // #1380: carry the delimiter style; absent (legacy docs) // defaults to Period in delimiter_from_attrs. - NodeValue::List(comrak::nodes::NodeList { - list_type: ListType::Ordered, - start: order, + NodeValue::List(comrak::nodes::NodeList::ordered( + order, + delimiter_from_attrs(json), tight, - delimiter: delimiter_from_attrs(json), - ..Default::default() - }) + )) } "list_item" => NodeValue::Item(comrak::nodes::NodeList::default()), @@ -389,32 +370,19 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> #[allow(clippy::cast_possible_truncation)] // order is typically small let order = json["attrs"]["order"].as_u64().map(|o| o as usize); match order { - Some(start) => NodeValue::List(comrak::nodes::NodeList { - list_type: ListType::Ordered, + // #1380: same delimiter carry as ordered_list. + Some(start) => NodeValue::List(comrak::nodes::NodeList::ordered( start, + delimiter_from_attrs(json), tight, - // #1380: same delimiter carry as ordered_list. - delimiter: delimiter_from_attrs(json), - ..Default::default() - }), - None => NodeValue::List(comrak::nodes::NodeList { - list_type: ListType::Bullet, - tight, - bullet_char: b'-', - ..Default::default() - }), + )), + None => NodeValue::List(comrak::nodes::NodeList::bullet(b'-', tight)), } } "task_list_item" => { let checked = json["attrs"]["checked"].as_bool().unwrap_or(false); - NodeValue::TaskItem(comrak::nodes::NodeTaskItem { - symbol: checked.then_some('x'), - symbol_sourcepos: comrak::nodes::Sourcepos { - start: comrak::nodes::LineColumn { line: 0, column: 0 }, - end: comrak::nodes::LineColumn { line: 0, column: 0 }, - }, - }) + NodeValue::TaskItem(comrak::nodes::NodeTaskItem::new(checked.then_some('x'))) } "table" => { @@ -442,12 +410,9 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> .unwrap_or_default(); alignments.resize(num_columns, comrak::nodes::TableAlignment::None); alignments.truncate(num_columns); - NodeValue::Table(Box::new(comrak::nodes::NodeTable { - alignments, - num_columns, - num_rows, - num_nonempty_cells: 0, - })) + let mut table = comrak::nodes::NodeTable::new(alignments); + table.num_rows = num_rows; + NodeValue::Table(Box::new(table)) } "table_row" => { @@ -457,7 +422,7 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> .and_then(|arr| arr.first()) .and_then(|c| c["type"].as_str()) .is_some_and(|t| t == "table_header"); - NodeValue::TableRow(is_header) + NodeValue::TableRow(comrak::nodes::NodeTableRow::new(is_header)) } "table_header" | "table_cell" => NodeValue::TableCell, @@ -509,10 +474,7 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> NodeValue::HtmlInline(tag) } else { // Standard markdown image syntax - NodeValue::Image(Box::new(comrak::nodes::NodeLink { - url: src, - title: title.to_owned(), - })) + NodeValue::Image(Box::new(comrak::nodes::NodeLink::new(src, title))) } } @@ -525,10 +487,9 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> // #945: footnote reference atom -> comrak FootnoteReference; the // commonmark formatter renders it natively as [^label]. "footnote_reference" => { - NodeValue::FootnoteReference(Box::new(comrak::nodes::NodeFootnoteReference { - name: json["attrs"]["label"].as_str().unwrap_or("").to_owned(), - ..Default::default() - })) + NodeValue::FootnoteReference(Box::new(comrak::nodes::NodeFootnoteReference::new( + json["attrs"]["label"].as_str().unwrap_or(""), + ))) } // #945: footnote definition block -> comrak FootnoteDefinition. @@ -537,10 +498,9 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> // (comrak requires block children) and the formatter renders them // under the [^label]: heading. "footnote_definition" => { - NodeValue::FootnoteDefinition(comrak::nodes::NodeFootnoteDefinition { - name: json["attrs"]["label"].as_str().unwrap_or("").to_owned(), - total_references: 0, - }) + NodeValue::FootnoteDefinition(comrak::nodes::NodeFootnoteDefinition::new( + json["attrs"]["label"].as_str().unwrap_or(""), + )) } "hard_break" => NodeValue::LineBreak, @@ -674,17 +634,18 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> let mut first_row: Option<&AstNode<'a>> = None; let mut has_header_row = false; for child in ast_node.children() { - if let NodeValue::TableRow(is_header) = &child.data.borrow().value { + if let NodeValue::TableRow(row) = &child.data.borrow().value { if first_row.is_none() { first_row = Some(child); } - if *is_header { + if row.header { has_header_row = true; } } } if !has_header_row && let Some(row) = first_row { - row.data.borrow_mut().value = NodeValue::TableRow(true); + row.data.borrow_mut().value = + NodeValue::TableRow(comrak::nodes::NodeTableRow::new(true)); } } @@ -720,20 +681,19 @@ fn json_to_ast<'a>(arena: &'a Arena<'a>, json: &Value) -> Result<&'a AstNode<'a> { wrappers.push(( mark_nesting_rank("link"), - NodeValue::Link(Box::new(comrak::nodes::NodeLink { - // #5745: same save-direction neutralization as above. - url: sanitize_link_url(link_href), - title: json["attrs"]["linkTitle"].as_str().unwrap_or("").to_owned(), - })), + NodeValue::Link(Box::new(comrak::nodes::NodeLink::new( + sanitize_link_url(link_href), + json["attrs"]["linkTitle"].as_str().unwrap_or(""), + ))), )); } if let Some(marks) = json["marks"].as_array() { for mark in marks { let mark_type = mark["type"].as_str().unwrap_or(""); let wrapper = match mark_type { - "em" => NodeValue::Emph, - "strong" => NodeValue::Strong, - "strikethrough" => NodeValue::Strikethrough, + "em" => NodeValue::Emph(Default::default()), + "strong" => NodeValue::Strong(Default::default()), + "strikethrough" => NodeValue::Strikethrough(Default::default()), _ => continue, }; if !wrappers.iter().any(|(_, w)| same_mark_wrapper(w, &wrapper)) { @@ -766,11 +726,11 @@ fn valid_table_cell_child(value: &NodeValue) -> bool { value, NodeValue::Text(..) | NodeValue::Code(..) - | NodeValue::Emph - | NodeValue::Strong + | NodeValue::Emph(_) + | NodeValue::Strong(_) | NodeValue::Link(..) | NodeValue::Image(..) - | NodeValue::Strikethrough + | NodeValue::Strikethrough(_) | NodeValue::Highlight | NodeValue::Insert | NodeValue::HtmlInline(..) @@ -848,9 +808,9 @@ fn collect_cell_text<'a>(node: &'a AstNode<'a>, segments: &mut Vec) { fn same_mark_wrapper(a: &NodeValue, b: &NodeValue) -> bool { match (a, b) { (NodeValue::Link(x), NodeValue::Link(y)) => x.url == y.url && x.title == y.title, - (NodeValue::Strong, NodeValue::Strong) - | (NodeValue::Emph, NodeValue::Emph) - | (NodeValue::Strikethrough, NodeValue::Strikethrough) => true, + (NodeValue::Strong(_), NodeValue::Strong(_)) + | (NodeValue::Emph(_), NodeValue::Emph(_)) + | (NodeValue::Strikethrough(_), NodeValue::Strikethrough(_)) => true, _ => false, } } @@ -860,7 +820,10 @@ fn same_mark_wrapper(a: &NodeValue, b: &NodeValue) -> bool { fn is_mark_wrapper(value: &NodeValue) -> bool { matches!( value, - NodeValue::Link(..) | NodeValue::Strong | NodeValue::Emph | NodeValue::Strikethrough + NodeValue::Link(..) + | NodeValue::Strong(_) + | NodeValue::Emph(_) + | NodeValue::Strikethrough(_) ) } @@ -1059,17 +1022,17 @@ fn create_marked_text<'a>(arena: &'a Arena<'a>, text: &str, marks: &[Value]) -> for mark in sorted_marks { let mark_type = mark["type"].as_str().unwrap_or(""); let wrapper_value = match mark_type { - "em" => NodeValue::Emph, - "strong" => NodeValue::Strong, - "strikethrough" => NodeValue::Strikethrough, + "em" => NodeValue::Emph(Default::default()), + "strong" => NodeValue::Strong(Default::default()), + "strikethrough" => NodeValue::Strikethrough(Default::default()), "link" => { let href = mark["attrs"]["href"].as_str().unwrap_or(""); let title = mark["attrs"]["title"].as_str().unwrap_or(""); - NodeValue::Link(Box::new(comrak::nodes::NodeLink { - // #5745: same save-direction neutralization as above. - url: sanitize_link_url(href), - title: title.to_owned(), - })) + // #5745: same save-direction neutralization as above. + NodeValue::Link(Box::new(comrak::nodes::NodeLink::new( + sanitize_link_url(href), + title, + ))) } // #1045: `code` is skipped here because it is handled // below as the innermost node; any other unrecognized mark @@ -1083,10 +1046,9 @@ fn create_marked_text<'a>(arena: &'a Arena<'a>, text: &str, marks: &[Value]) -> // Start with the innermost node: a Code node when a code mark is // present, otherwise the plain text node. let inner_node = if has_code { - arena.alloc(AstNode::from(NodeValue::Code(comrak::nodes::NodeCode { - num_backticks: 1, - literal: text.to_owned(), - }))) + let mut code = comrak::nodes::NodeCode::new(text); + code.num_backticks = 1; + arena.alloc(AstNode::from(NodeValue::Code(code))) } else { arena.alloc(AstNode::from(NodeValue::Text(text.to_owned().into()))) }; @@ -6049,7 +6011,7 @@ mod tests { // canonical order (strong outside em) must keep it stable. let (first, second) = two_saves("***both***\n"); assert_eq!(first, second); - assert!(first.contains("***both***")); + assert_eq!(first, "**_both_**\n"); } #[test] diff --git a/pkgs/id/crates/id-web/src/markdown/markdown_serialization.rs b/pkgs/id/crates/id-web/src/markdown/markdown_serialization.rs index 74f4d4d505..c347b58531 100644 --- a/pkgs/id/crates/id-web/src/markdown/markdown_serialization.rs +++ b/pkgs/id/crates/id-web/src/markdown/markdown_serialization.rs @@ -642,7 +642,7 @@ pub(crate) fn collect_boundary_kinds( pub(crate) fn is_delimiter_wrapper(value: &NodeValue) -> bool { matches!( value, - NodeValue::Emph | NodeValue::Strong | NodeValue::Strikethrough + NodeValue::Emph(_) | NodeValue::Strong(_) | NodeValue::Strikethrough(_) ) } @@ -1247,7 +1247,7 @@ pub(crate) fn is_block_node(node: &AstNode<'_>) -> bool { | NodeValue::TaskItem(_) | NodeValue::CodeBlock(_) | NodeValue::HtmlBlock(_) - | NodeValue::ThematicBreak + | NodeValue::ThematicBreak(_) | NodeValue::FrontMatter(_) | NodeValue::Table(_) | NodeValue::FootnoteDefinition(_) diff --git a/pkgs/id/crates/id-web/src/markdown/prosemirror_json.rs b/pkgs/id/crates/id-web/src/markdown/prosemirror_json.rs index 3beeb78533..c54c9b6b8d 100644 --- a/pkgs/id/crates/id-web/src/markdown/prosemirror_json.rs +++ b/pkgs/id/crates/id-web/src/markdown/prosemirror_json.rs @@ -104,7 +104,7 @@ pub(crate) fn convert_node<'a>(node: &'a AstNode<'a>, active_marks: &[Mark]) -> node_json } - NodeValue::ThematicBreak => { + NodeValue::ThematicBreak(_) => { json!({"type": "horizontal_rule"}) } @@ -163,7 +163,7 @@ pub(crate) fn convert_node<'a>(node: &'a AstNode<'a>, active_marks: &[Mark]) -> text_node_with_marks(&code.literal, &marks) } - NodeValue::Emph => { + NodeValue::Emph(_) => { // Emphasis - collect children with em mark added let mut marks = active_marks.to_vec(); marks.push(Mark { @@ -174,7 +174,7 @@ pub(crate) fn convert_node<'a>(node: &'a AstNode<'a>, active_marks: &[Mark]) -> json!(collect_inline_children(node, &marks)) } - NodeValue::Strong => { + NodeValue::Strong(_) => { // Strong - collect children with strong mark added let mut marks = active_marks.to_vec(); marks.push(Mark { @@ -354,8 +354,8 @@ pub(crate) fn convert_node<'a>(node: &'a AstNode<'a>, active_marks: &[Mark]) -> table_json } - NodeValue::TableRow(is_header) => { - let cell_type = if *is_header { + NodeValue::TableRow(row) => { + let cell_type = if row.header { "table_header" } else { "table_cell" @@ -412,7 +412,7 @@ pub(crate) fn convert_node<'a>(node: &'a AstNode<'a>, active_marks: &[Mark]) -> }) } - NodeValue::Strikethrough => { + NodeValue::Strikethrough(_) => { // Strikethrough - collect children with strikethrough mark added let mut marks = active_marks.to_vec(); marks.push(Mark { @@ -688,7 +688,10 @@ pub(crate) fn collect_inline_children<'a>( // Check if this is a mark wrapper (Emph, Strong, Link) let is_mark_wrapper = matches!( child_data.value, - NodeValue::Emph | NodeValue::Strong | NodeValue::Link(_) | NodeValue::Strikethrough + NodeValue::Emph(_) + | NodeValue::Strong(_) + | NodeValue::Link(_) + | NodeValue::Strikethrough(_) ); drop(child_data); @@ -784,7 +787,7 @@ pub(crate) fn collect_alt_markdown<'a>(node: &'a AstNode<'a>, out: &mut String) NodeValue::SoftBreak => out.push(' '), NodeValue::LineBreak => out.push('\n'), NodeValue::HtmlInline(html) => out.push_str(html), - NodeValue::Emph => { + NodeValue::Emph(_) => { drop(data); out.push('*'); for child in node.children() { @@ -792,7 +795,7 @@ pub(crate) fn collect_alt_markdown<'a>(node: &'a AstNode<'a>, out: &mut String) } out.push('*'); } - NodeValue::Strong => { + NodeValue::Strong(_) => { drop(data); out.push_str("**"); for child in node.children() { @@ -800,7 +803,7 @@ pub(crate) fn collect_alt_markdown<'a>(node: &'a AstNode<'a>, out: &mut String) } out.push_str("**"); } - NodeValue::Strikethrough => { + NodeValue::Strikethrough(_) => { drop(data); out.push_str("~~"); for child in node.children() { diff --git a/pkgs/id/crates/id-worlds/Cargo.toml b/pkgs/id/crates/id-worlds/Cargo.toml index 73b2a7abb0..95c1b52e0e 100644 --- a/pkgs/id/crates/id-worlds/Cargo.toml +++ b/pkgs/id/crates/id-worlds/Cargo.toml @@ -63,11 +63,9 @@ id-store = { path = "../id-store", default-features = false } id-sync = { path = "../id-sync", default-features = false } iroh = "1" iroh-base = "1" -iroh-blobs = "0.105" -# The hash type iroh-docs 0.101 uses; pinned to the same 0.103 it depends on. -iroh-blobs-docs = { package = "iroh-blobs", version = "0.103.1" } +iroh-blobs = "0.103" iroh-docs = "0.101" -iroh-gossip = { version = "0.103", features = ["net"] } +iroh-gossip = { version = "0.101", features = ["net"] } libc = "0.2" p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" } postcard = { version = "1", features = ["alloc"] } diff --git a/pkgs/id/crates/id-worlds/src/world/spill_pool.rs b/pkgs/id/crates/id-worlds/src/world/spill_pool.rs index 0564b5e36c..65eabbc622 100644 --- a/pkgs/id/crates/id-worlds/src/world/spill_pool.rs +++ b/pkgs/id/crates/id-worlds/src/world/spill_pool.rs @@ -398,7 +398,7 @@ mod tests { eligible_member(&mut pool, "successor", 50, 0); let mut lease = WriteLease::bootstrap(); lease - .apply_handoff(DO_WRITE_LEASE_HOLDER, "dead", 1, Some(30_000)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "dead", 1, Some(30_000), 0) .unwrap(); assert_eq!( @@ -420,8 +420,8 @@ mod tests { ] ); assert_eq!(plan.pre_grant_tip(), 50); - lease.apply_revoke("dead", 2, "term expired").unwrap(); - lease.apply_grant("successor", 3, Some(60_000)).unwrap(); + lease.apply_revoke("dead", 2, "term expired", 0).unwrap(); + lease.apply_grant("successor", 3, Some(60_000), 0).unwrap(); assert_eq!(lease.holder.as_deref(), Some("successor")); assert_eq!(lease.epoch, 3); assert!(lease.validate_history().is_ok()); @@ -432,7 +432,7 @@ mod tests { let pool = SpillPool::default(); let mut lease = WriteLease::bootstrap(); lease - .apply_handoff(DO_WRITE_LEASE_HOLDER, "dead", 1, Some(1)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "dead", 1, Some(1), 0) .unwrap(); assert_eq!( pool.plan_failover(&lease, 1, 50, 0).unwrap().actions(), @@ -454,9 +454,9 @@ mod tests { let pool = SpillPool::default(); let mut lease = WriteLease::bootstrap(); lease - .apply_handoff(DO_WRITE_LEASE_HOLDER, "dead", 1, Some(1)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "dead", 1, Some(1), 0) .unwrap(); - lease.apply_revoke("dead", 2, "term expired").unwrap(); + lease.apply_revoke("dead", 2, "term expired", 0).unwrap(); assert_eq!( pool.plan_failover(&lease, 1, 50, 0).unwrap().actions(), vec![LeaseAction::Grant { @@ -470,9 +470,9 @@ mod tests { fn writes_during_the_fence_window_are_retryable_holder_lost() { let mut lease = WriteLease::bootstrap(); lease - .apply_handoff(DO_WRITE_LEASE_HOLDER, "old", 1, Some(10)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "old", 1, Some(10), 0) .unwrap(); - lease.apply_revoke("old", 2, "term expired").unwrap(); + lease.apply_revoke("old", 2, "term expired", 0).unwrap(); assert_eq!( lease.check_writer("old", 1, 10), Err(LeaseRejectionReason::HolderLost) @@ -483,10 +483,10 @@ mod tests { fn fenced_holder_reconnect_is_rejected_and_auditable() { let mut lease = WriteLease::bootstrap(); lease - .apply_handoff(DO_WRITE_LEASE_HOLDER, "old", 1, Some(10)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "old", 1, Some(10), 0) .unwrap(); - lease.apply_revoke("old", 2, "term expired").unwrap(); - lease.apply_grant("new", 3, Some(30)).unwrap(); + lease.apply_revoke("old", 2, "term expired", 0).unwrap(); + lease.apply_grant("new", 3, Some(30), 0).unwrap(); assert_eq!( lease.check_writer("old", 1, 11), Err(LeaseRejectionReason::NotHolder) @@ -499,6 +499,7 @@ mod tests { observed_epoch: 3, reason: LeaseRejectionReason::NotHolder, received_at_ms: 11, + position: 0, }) .unwrap(); assert_eq!(lease.rejections().count(), 1); @@ -510,11 +511,11 @@ mod tests { // automatic failover from the old holder. let mut handback_first = WriteLease::bootstrap(); handback_first - .apply_handoff(DO_WRITE_LEASE_HOLDER, "native", 1, Some(30)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "native", 1, Some(30), 0) .unwrap(); assert!(handback_first.check_writer("native", 1, 29).is_ok()); handback_first - .apply_handoff("native", DO_WRITE_LEASE_HOLDER, 2, None) + .apply_handoff("native", DO_WRITE_LEASE_HOLDER, 2, None, 0) .unwrap(); assert_eq!( SpillPool::default().plan_failover(&handback_first, 30, 0, 0), @@ -525,7 +526,7 @@ mod tests { // back; automatic recovery uses revoke then grant from that state. let mut failover_first = WriteLease::bootstrap(); failover_first - .apply_handoff(DO_WRITE_LEASE_HOLDER, "native", 1, Some(30)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "native", 1, Some(30), 0) .unwrap(); assert_eq!( failover_first.check_writer("native", 1, 30), @@ -549,10 +550,10 @@ mod tests { let pool = SpillPool::default(); let mut lease = WriteLease::bootstrap(); lease - .apply_handoff(DO_WRITE_LEASE_HOLDER, "first", 1, Some(10)) + .apply_handoff(DO_WRITE_LEASE_HOLDER, "first", 1, Some(10), 0) .unwrap(); - lease.apply_revoke("first", 2, "term expired").unwrap(); - lease.apply_grant("second", 3, Some(40)).unwrap(); + lease.apply_revoke("first", 2, "term expired", 0).unwrap(); + lease.apply_grant("second", 3, Some(40), 0).unwrap(); assert_eq!( pool.plan_failover(&lease, 39, 0, 0), Err(FailoverPlanError::TermStillLive) @@ -576,7 +577,7 @@ mod tests { let mut holder = DO_WRITE_LEASE_HOLDER.to_owned(); for epoch in 1..=base_epoch { let next_holder = format!("holder-{epoch}"); - lease.apply_handoff(&holder, &next_holder, epoch, Some(1)).unwrap(); + lease.apply_handoff(&holder, &next_holder, epoch, Some(1), 0).unwrap(); holder = next_holder; } @@ -594,8 +595,8 @@ mod tests { prop_assert_eq!(*revoke_epoch, base_epoch + 1); prop_assert_eq!(*grant_epoch, base_epoch + 2); - lease.apply_revoke(former_holder, *revoke_epoch, "expired").unwrap(); - lease.apply_grant(successor, *grant_epoch, Some(2)).unwrap(); + lease.apply_revoke(former_holder, *revoke_epoch, "expired", 0).unwrap(); + lease.apply_grant(successor, *grant_epoch, Some(2), 0).unwrap(); prop_assert!(lease.validate_history().is_ok()); } } diff --git a/pkgs/id/crates/id-worlds/src/world_records.rs b/pkgs/id/crates/id-worlds/src/world_records.rs index ae219af4b2..1e95e0bb43 100644 --- a/pkgs/id/crates/id-worlds/src/world_records.rs +++ b/pkgs/id/crates/id-worlds/src/world_records.rs @@ -47,14 +47,6 @@ pub struct RecordsStore { author: AuthorId, } -/// Convert an iroh-docs content hash to the blob-store type. -/// -/// iroh-docs 0.101 pins iroh-blobs 0.103 while this crate uses 0.105; both -/// wrap the same 32-byte BLAKE3 digest. -fn blob_hash(hash: iroh_blobs_docs::Hash) -> Hash { - Hash::from_bytes(*hash.as_bytes()) -} - fn doc_key(key: &str) -> Vec { let mut bytes = Vec::with_capacity(key.len() + 1); bytes.extend_from_slice(key.as_bytes()); @@ -174,7 +166,7 @@ impl RecordsStore { tokio::pin!(entries); while let Some(entry) = entries.try_next().await? { if let Some(key) = record_key(entry.key()) { - existing.insert(key.to_owned(), blob_hash(entry.content_hash())); + existing.insert(key.to_owned(), entry.content_hash()); } } // Delete obsolete keys before writing additions (Codex review @@ -271,7 +263,7 @@ pub async fn read_records(doc: &Doc, blobs: &Store) -> Result { ); let bytes = blobs .blobs() - .get_bytes(blob_hash(entry.content_hash())) + .get_bytes(entry.content_hash()) .await .with_context(|| format!("content of record {key:?} is not available yet"))?; // A duplicate key is a parse error (#6520, #6634): the cap below @@ -331,7 +323,7 @@ pub async fn replicate( let mut missing = false; while let Some(entry) = entries.try_next().await? { announced += 1; - if !blobs.blobs().has(blob_hash(entry.content_hash())).await? { + if !blobs.blobs().has(entry.content_hash()).await? { missing = true; } } diff --git a/pkgs/id/tests/common/ingest.rs b/pkgs/id/tests/common/ingest.rs index cfd51c4553..3991214506 100644 --- a/pkgs/id/tests/common/ingest.rs +++ b/pkgs/id/tests/common/ingest.rs @@ -14,7 +14,7 @@ use id::event_store::{Chain, EventStore, Storage}; use id::waiting::{AuthorKey, WaitingLimits}; use p2panda_core::{Hash, SeqNum}; use redb::backends::InMemoryBackend; -use redb::{Database, DatabaseError, StorageBackend, StorageError}; +use redb::{BackendError, Database, DatabaseError, StorageBackend, StorageError}; /// The applied state of a set of authors, as a store reports it. #[derive(Clone, Debug, Default, PartialEq, Eq)] @@ -82,23 +82,23 @@ pub struct MemStorage { struct Shared(Arc); impl StorageBackend for Shared { - fn len(&self) -> Result { + fn len(&self) -> Result { self.0.len() } - fn read(&self, offset: u64, out: &mut [u8]) -> Result<(), io::Error> { + fn read(&self, offset: u64, out: &mut [u8]) -> Result<(), BackendError> { self.0.read(offset, out) } - fn set_len(&self, len: u64) -> Result<(), io::Error> { + fn set_len(&self, len: u64) -> Result<(), BackendError> { self.0.set_len(len) } - fn sync_data(&self) -> Result<(), io::Error> { + fn sync_data(&self) -> Result<(), BackendError> { self.0.sync_data() } - fn write(&self, offset: u64, data: &[u8]) -> Result<(), io::Error> { + fn write(&self, offset: u64, data: &[u8]) -> Result<(), BackendError> { self.0.write(offset, data) } } diff --git a/pkgs/id/tests/crash/faultfs.rs b/pkgs/id/tests/crash/faultfs.rs index be5610b94f..d3ef660301 100644 --- a/pkgs/id/tests/crash/faultfs.rs +++ b/pkgs/id/tests/crash/faultfs.rs @@ -7,7 +7,7 @@ //! redb's own `CrashBackend` does (`src/db.rs` in redb 4.6.0). The caller must stop counting work //! once `cut()` is true, because the process it models is dead. -use redb::StorageBackend; +use redb::{BackendError, StorageBackend}; use std::io; use std::sync::{Arc, Mutex, MutexGuard}; @@ -232,25 +232,22 @@ fn tick(st: &mut State, kind: Kind, offset: u64, len: usize) -> bool { } impl StorageBackend for FaultFs { - fn len(&self) -> Result { + fn len(&self) -> Result { Ok(self.lock().live.len() as u64) } - fn read(&self, offset: u64, out: &mut [u8]) -> Result<(), io::Error> { + fn read(&self, offset: u64, out: &mut [u8]) -> Result<(), BackendError> { let st = self.lock(); let start = offset as usize; let end = start + out.len(); if end > st.live.len() { - return Err(io::Error::new( - io::ErrorKind::UnexpectedEof, - "read past end", - )); + return Err(io::Error::new(io::ErrorKind::UnexpectedEof, "read past end").into()); } out.copy_from_slice(&st.live[start..end]); Ok(()) } - fn set_len(&self, len: u64) -> Result<(), io::Error> { + fn set_len(&self, len: u64) -> Result<(), BackendError> { let mut guard = self.lock(); let st = &mut *guard; if st.cut { @@ -266,7 +263,7 @@ impl StorageBackend for FaultFs { Ok(()) } - fn sync_data(&self) -> Result<(), io::Error> { + fn sync_data(&self) -> Result<(), BackendError> { let mut guard = self.lock(); let st = &mut *guard; if st.cut { @@ -289,7 +286,7 @@ impl StorageBackend for FaultFs { Ok(()) } - fn write(&self, offset: u64, data: &[u8]) -> Result<(), io::Error> { + fn write(&self, offset: u64, data: &[u8]) -> Result<(), BackendError> { let mut guard = self.lock(); let st = &mut *guard; if st.cut { diff --git a/pkgs/id/tests/crash/store.rs b/pkgs/id/tests/crash/store.rs index 4cb367d14e..1e597afeb6 100644 --- a/pkgs/id/tests/crash/store.rs +++ b/pkgs/id/tests/crash/store.rs @@ -271,7 +271,7 @@ impl Storage for SimDir { .cloned() .ok_or_else(|| io::Error::from(io::ErrorKind::NotFound))? }; - handle.sync_data() + handle.sync_data().map_err(io::Error::from) } fn sync_dir(&self) -> io::Result<()> {