refactor(p2p): drop NoPeersSubscribedToTopic suppression path#298
refactor(p2p): drop NoPeersSubscribedToTopic suppression path#298MegaRedHand wants to merge 1 commit intomainfrom
Conversation
Since every validator now subscribes to its own attestation subnet (#293), the transient "no remote peer knows of this subnet yet" condition is no longer part of the expected publish path. If it surfaces, it's a real signal (partition, misconfigured peer) and deserves the warning. Removes: - SwarmHandle::publish_ignore_no_peers and the ignore_no_peers flag on SwarmCommand::Publish - The is_aggregator field on BuiltSwarm / P2PServer (only used to pick between the two publish paths) - The aggregator-only branch in publish_attestation Publish errors are now logged uniformly via inspect_err on the single publish path in the swarm adapter.
🤖 Kimi Code ReviewSummary Issues & Concerns
Positive Aspects
Consensus & Security Assessment
Recommendation: Approve if the team accepts increased warning verbosity in small networks, or request filtering Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code ReviewFindings
No other correctness, security, fork-choice, attestation-validation, STF, XMSS, or SSZ issues stood out in this diff. The rest of the change is mainly cleanup of now-unused I could not run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Claude Code ReviewHere is the code review for PR #298: PR #298 —
|
Greptile SummaryThis PR removes the Confidence Score: 5/5Safe to merge — clean dead-code removal with no functional regressions on the changed paths. All findings are P2 (a stale comment). The logic change is correct: removing suppression that was only needed when non-aggregators lacked subnet subscriptions, a precondition that no longer holds after #293. No new error paths, no data loss, no broken contracts. No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/net/p2p/src/swarm_adapter.rs | Dropped ignore_no_peers from SwarmCommand::Publish and removed publish_ignore_no_peers helper; execute_command now uses a single inspect_err warn path for all publish failures. |
| crates/net/p2p/src/gossipsub/handler.rs | publish_attestation simplified: removed is_aggregator branch, always calls swarm_handle.publish; stale "gossipsub fanout" comment remains but the fallback path is effectively unreachable since every validator now subscribes to its own subnet. |
| crates/net/p2p/src/lib.rs | Removed is_aggregator from BuiltSwarm and P2PServer; SwarmConfig.is_aggregator is intentionally retained for subscription logic in build_swarm. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[publish_attestation called] --> B[compute subnet_id]
B --> C[look up topic in attestation_topics]
C --> D{found?}
D -- yes --> E[swarm_handle.publish topic]
D -- no --> F[attestation_subnet_topic fallback]
F --> E
E --> G[SwarmCommand::Publish enqueued]
G --> H[execute_command in swarm_loop]
H --> I[gossipsub.publish]
I --> J{error?}
J -- no --> K[done]
J -- yes --> L[warn! Swarm adapter: publish failed]
L --> K
style F stroke-dasharray: 5 5
style F fill:#ffe0b2
Comments Outside Diff (1)
-
crates/net/p2p/src/gossipsub/handler.rs, line 141-146 (link)Stale "fanout" comment and dead fallback branch
Since fix: subscribe non-aggregator validators to their attestation subnets #293 every validator subscribes to its own attestation subnet before publishing,
attestation_topicswill always contain the validator'ssubnet_id. Theunwrap_or_elsebranch and its comment about gossipsub fanout are now unreachable in normal operation; consider updating or removing both to avoid misleading future readers.Prompt To Fix With AI
This is a comment left during a code review. Path: crates/net/p2p/src/gossipsub/handler.rs Line: 141-146 Comment: **Stale "fanout" comment and dead fallback branch** Since #293 every validator subscribes to its own attestation subnet before publishing, `attestation_topics` will always contain the validator's `subnet_id`. The `unwrap_or_else` branch and its comment about gossipsub fanout are now unreachable in normal operation; consider updating or removing both to avoid misleading future readers. How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: crates/net/p2p/src/gossipsub/handler.rs
Line: 141-146
Comment:
**Stale "fanout" comment and dead fallback branch**
Since #293 every validator subscribes to its own attestation subnet before publishing, `attestation_topics` will always contain the validator's `subnet_id`. The `unwrap_or_else` branch and its comment about gossipsub fanout are now unreachable in normal operation; consider updating or removing both to avoid misleading future readers.
```suggestion
// Look up subscribed topic; every validator subscribes to its own subnet.
let topic = server
.attestation_topics
.get(&subnet_id)
.cloned()
.unwrap_or_else(|| attestation_subnet_topic(subnet_id));
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "refactor(p2p): drop NoPeersSubscribedToT..." | Re-trigger Greptile
Summary
Follow-up to #293. Now that every validator subscribes to its own attestation subnet, the
NoPeersSubscribedToTopicerror path is no longer an expected-and-ignorable case on any publish site. Remove the suppression machinery and unify on a single publish path.Motivation
Before #293 only aggregators subscribed to attestation subnets. A non-aggregator publishing via fanout, or an aggregator in a single-subscriber mesh, could legitimately get
PublishError::NoPeersSubscribedToTopicand we handled this by gatingpublish_ignore_no_peersonis_aggregator. This was already slightly misaligned (Codex flagged this on #293) and is now fully obsolete: every validator that publishes an attestation is itself in the mesh for that subnet, so if gossipsub still reports no remote subscribers, it means something is actually wrong (partition, misconfigured peer) and we want the warning.Changes
crates/net/p2p/src/swarm_adapter.rsignore_no_peersfield onSwarmCommand::Publishand theSwarmHandle::publish_ignore_no_peershelper. The publish execution now uses a singleinspect_errpath that warns on any failure, includingNoPeersSubscribedToTopic. Removed the now-unusedPublishErrorimport.crates/net/p2p/src/gossipsub/handler.rspublish_attestationno longer branches onis_aggregator; always callsswarm_handle.publish(...).crates/net/p2p/src/lib.rsis_aggregatorfield removed fromBuiltSwarmandP2PServer— the only consumer was the branching inpublish_attestation.SwarmConfig.is_aggregatorstays (still drives subscription decisions).Net diff: 3 files, +9/-49.
Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --release --lib— 60 passed, 6 ignoredcargo test -p ethlambda-blockchain --release --test forkchoice_spectests— 57 passedcargo test -p ethlambda-state-transition --release --test stf_spectests— 47 passed