From ea582e9bc7245049d1674f7f2d9d6cde73397dd9 Mon Sep 17 00:00:00 2001 From: Ian Clarke Date: Fri, 19 Dec 2025 15:07:20 -0600 Subject: [PATCH 1/2] build: bump versions to 0.1.53 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - freenet: → 0.1.53 - fdev: → 0.3.31 🤖 Automated release commit --- Cargo.lock | 4 ++-- crates/core/Cargo.toml | 2 +- crates/fdev/Cargo.toml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 702f946ec..a06a4ff81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1673,7 +1673,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fdev" -version = "0.3.30" +version = "0.3.31" dependencies = [ "anyhow", "axum", @@ -1803,7 +1803,7 @@ dependencies = [ [[package]] name = "freenet" -version = "0.1.52" +version = "0.1.53" dependencies = [ "aes-gcm", "ahash", diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index bbddf02d6..79953919b 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "freenet" -version = "0.1.52" +version = "0.1.53" edition = "2021" rust-version = "1.80" publish = true diff --git a/crates/fdev/Cargo.toml b/crates/fdev/Cargo.toml index 19537cdca..9a142a079 100644 --- a/crates/fdev/Cargo.toml +++ b/crates/fdev/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fdev" -version = "0.3.30" +version = "0.3.31" edition = "2021" rust-version = "1.80" publish = true @@ -44,7 +44,7 @@ reqwest = { version = "0.12", features = ["json"] } http = "1.4" # internal -freenet = { path = "../core", version = "0.1.52" } +freenet = { path = "../core", version = "0.1.53" } freenet-stdlib = { workspace = true } [features] From 41c318199fe7b5ff7e8b902920c11cb438331274 Mon Sep 17 00:00:00 2001 From: Ian Clarke Date: Sat, 20 Dec 2025 00:10:28 -0600 Subject: [PATCH 2/2] fix: correct seeding contracts count in diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The diagnostics endpoint was using all_network_subscriptions().len() which counts remote peer subscribers, not the actual seeding cache. This caused "Seeding contracts: 0" to be displayed even when the node was correctly seeding contracts after a PUT operation. The actual seeding mechanism works correctly - seed_contract() IS called for PUT originators and the contract IS stored in the seeding cache. Only the diagnostics metric was wrong. Added seeding_contracts_count() methods to SeedingManager and Ring to expose the correct count from the seeding cache, with a unit test to verify correctness. Also fixed flaky test simulate_send_max_short_message by adding a 10s timeout to conn.recv() - the missing timeout caused the test to hang indefinitely under CI load conditions instead of failing fast. Fixes #2340 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../src/node/network_bridge/p2p_protoc.rs | 5 ++- crates/core/src/ring/mod.rs | 6 ++++ crates/core/src/ring/seeding.rs | 35 +++++++++++++++++++ .../core/src/transport/connection_handler.rs | 2 +- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/crates/core/src/node/network_bridge/p2p_protoc.rs b/crates/core/src/node/network_bridge/p2p_protoc.rs index c5e72b69b..6eb89bcec 100644 --- a/crates/core/src/node/network_bridge/p2p_protoc.rs +++ b/crates/core/src/node/network_bridge/p2p_protoc.rs @@ -1194,8 +1194,11 @@ impl P2pConnManager { // Collect system metrics if config.include_system_metrics { + // Use the actual seeding cache count, not the subscriber count. + // The seeding cache tracks contracts this node is actively caching, + // while subscribers tracks remote peers subscribed to updates. let seeding_contracts = - op_manager.ring.all_network_subscriptions().len() as u32; + op_manager.ring.seeding_contracts_count() as u32; response.system_metrics = Some(SystemMetrics { active_connections: connected_peer_ids.len() as u32, seeding_contracts, diff --git a/crates/core/src/ring/mod.rs b/crates/core/src/ring/mod.rs index bbaf5f953..d0e36d14d 100644 --- a/crates/core/src/ring/mod.rs +++ b/crates/core/src/ring/mod.rs @@ -380,6 +380,12 @@ impl Ring { self.seeding_manager.all_subscriptions() } + /// Get the number of contracts in the seeding cache. + /// This is the actual count of contracts this node is caching/seeding. + pub fn seeding_contracts_count(&self) -> usize { + self.seeding_manager.seeding_contracts_count() + } + pub async fn prune_connection(&self, peer: PeerId) { tracing::debug!(peer = %peer, "Removing connection"); self.live_tx_tracker.prune_transactions_from_peer(peer.addr); diff --git a/crates/core/src/ring/seeding.rs b/crates/core/src/ring/seeding.rs index bf392ec7c..8ed476031 100644 --- a/crates/core/src/ring/seeding.rs +++ b/crates/core/src/ring/seeding.rs @@ -268,6 +268,12 @@ impl SeedingManager { .map(|entry| (*entry.key(), entry.value().clone())) .collect() } + + /// Get the number of contracts in the seeding cache. + /// This is the actual count of contracts this node is caching/seeding. + pub fn seeding_contracts_count(&self) -> usize { + self.seeding_cache.read().len() + } } #[cfg(test)] @@ -768,4 +774,33 @@ mod tests { "sender (peer1) should NOT be in broadcast targets" ); } + + #[test] + fn test_seeding_contracts_count() { + use super::super::seeding_cache::AccessType; + + let seeding_manager = SeedingManager::new(); + + // Initially no contracts are seeded + assert_eq!(seeding_manager.seeding_contracts_count(), 0); + + // Add first contract + let key1 = make_contract_key(1); + seeding_manager.record_contract_access(key1, 1000, AccessType::Put); + assert_eq!(seeding_manager.seeding_contracts_count(), 1); + + // Add second contract + let key2 = make_contract_key(2); + seeding_manager.record_contract_access(key2, 1000, AccessType::Put); + assert_eq!(seeding_manager.seeding_contracts_count(), 2); + + // Add third contract + let key3 = make_contract_key(3); + seeding_manager.record_contract_access(key3, 1000, AccessType::Get); + assert_eq!(seeding_manager.seeding_contracts_count(), 3); + + // Re-accessing a contract doesn't increase count + seeding_manager.record_contract_access(key1, 1000, AccessType::Get); + assert_eq!(seeding_manager.seeding_contracts_count(), 3); + } } diff --git a/crates/core/src/transport/connection_handler.rs b/crates/core/src/transport/connection_handler.rs index 996d69e23..7c7b60fa0 100644 --- a/crates/core/src/transport/connection_handler.rs +++ b/crates/core/src/transport/connection_handler.rs @@ -2372,7 +2372,7 @@ pub mod mock_transport { let peer_a = tokio::spawn(async move { let peer_b_conn = peer_a.connect(peer_b_pub, peer_b_addr).await; let mut conn = tokio::time::timeout(Duration::from_secs(5), peer_b_conn).await??; - let msg = conn.recv().await?; + let msg = tokio::time::timeout(Duration::from_secs(10), conn.recv()).await??; assert!(msg.len() <= MAX_DATA_SIZE); Ok::<_, anyhow::Error>(()) });