-
-
Notifications
You must be signed in to change notification settings - Fork 111
fix: correct seeding contracts count in diagnostics #2341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- freenet: → 0.1.53 - fdev: → 0.3.31 🤖 Automated release commit
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 <noreply@anthropic.com>
|
|
@claude Please do a skeptical review of this PR |
|
Claude finished @sanity's task in 2m 57s —— View job Skeptical PR ReviewI've conducted a thorough review of this PR with a critical eye. Here are my findings: 1. Root Cause Analysis: INCORRECT ❌The PR description claims:
This is wrong. Looking at the code:
So the old code was counting: "How many contracts have remote peers subscribed to them?" This is indeed different from "How many contracts am I seeding?", but the explanation in the PR is technically inaccurate. 2. The Fix is Correct, But...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the diagnostics endpoint that incorrectly reported "Seeding contracts: 0" even when contracts were being actively seeded. The issue stemmed from using the wrong metric - counting remote peer subscribers instead of the actual seeding cache size.
Key changes:
- Added
seeding_contracts_count()methods to expose actual seeding cache size throughSeedingManagerandRing - Updated diagnostics endpoint to use the correct metric for counting seeded contracts
- Fixed flaky transport test by adding missing timeout to prevent indefinite hangs
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/core/src/ring/seeding.rs |
Added seeding_contracts_count() method and comprehensive unit test |
crates/core/src/ring/mod.rs |
Added delegating method to expose seeding cache count |
crates/core/src/node/network_bridge/p2p_protoc.rs |
Updated diagnostics to use correct seeding cache count with explanatory comments |
crates/core/src/transport/connection_handler.rs |
Added 10s timeout to prevent test from hanging indefinitely |
crates/core/Cargo.toml |
Version bump from 0.1.52 to 0.1.53 |
crates/fdev/Cargo.toml |
Version bump from 0.3.30 to 0.3.31 and dependency update |
Cargo.lock |
Lockfile updates for version changes |
The changes are well-implemented with clear documentation and appropriate test coverage. The fix correctly addresses the root cause by distinguishing between the seeding cache (contracts this node is actively caching) and the subscriber list (remote peers subscribed to updates). No issues were identified during the review.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Response to Skeptical ReviewThank you for the thorough review. Let me address each point: 1. Root Cause Explanation - Partially CorrectYou're right that my wording was imprecise. The old code counted "contracts that have at least one subscriber" not "total subscribers". However, the core issue remains: for an isolated node or PUT originator with no remote subscribers, this always returns 0 regardless of whether contracts are being seeded locally. The fix correctly changes this to count the seeding cache. 2. Version Bumps - Not in This PRChecking the actual diff: There are no version bump files in this PR. The Copilot review listing 3. Semantic Mismatch - IntentionalThe field 4. Flaky Test - Root Cause ExplainedThe mock transport uses in-memory channels (
The 10s timeout matches other similar tests (lines 2132, 2564, 2699, etc.) and ensures the test fails fast instead of hanging for 60+ seconds. 5. Integration Test - Unit Test is SufficientThe unit test 6. Benchmark Regression - CI Shows PassThe benchmark job shows 7. Documentation - Fair PointI can add a doc comment to clarify the semantics if needed, but this is a minor improvement rather than a blocking issue. CI Status: All checks passing ✅ [AI-assisted - Claude] |
Problem
The diagnostics endpoint was incorrectly reporting "Seeding contracts: 0" even when a node was correctly seeding contracts after a PUT operation. This was misleading and suggested the seeding mechanism was broken.
The issue was reported in #2340 where after a successful PUT, the diagnostics showed:
Why CI didn't catch this: The diagnostics metric is displayed output, not tested in CI. The actual seeding mechanism works correctly - this was purely a display issue.
Root Cause Investigation
Initial hypothesis was that PUT originators weren't calling
seed_contract(), but investigation proved the seeding mechanism works correctly:seed_contract()IS called for PUT originators atput.rs:228The diagnostics code at
p2p_protoc.rs:1197-1198was using:This counts remote peer subscribers, not the seeding cache. For an isolated node or the PUT originator, there are no remote subscribers, so this always returns 0.
This Solution
Added
seeding_contracts_count()methods to expose the actual seeding cache size:SeedingManager::seeding_contracts_count()- returnsseeding_cache.len()Ring::seeding_contracts_count()- delegates to SeedingManagerUpdated diagnostics to use the correct count:
Additional Fix: Flaky Transport Test
Also fixed the flaky
simulate_send_max_short_messagetest that was causing CI failures on main. The test was missing a timeout onconn.recv(), causing it to hang indefinitely under CI load conditions instead of failing fast. Added a 10s timeout to match the pattern used by other similar tests.Testing
test_isolated_node_update_operationpassesseeding_contracts_count()methodCloses #2340
[AI-assisted - Claude]