Skip to content

refactor(pkg/p2p): swap GossipSub by FloodSub#3263

Merged
julienrbrt merged 2 commits intomainfrom
p2p-debug
Apr 17, 2026
Merged

refactor(pkg/p2p): swap GossipSub by FloodSub#3263
julienrbrt merged 2 commits intomainfrom
p2p-debug

Conversation

@julienrbrt
Copy link
Copy Markdown
Member

@julienrbrt julienrbrt commented Apr 17, 2026

Thanks @Wondertan for suggesting this.

Summary by CodeRabbit

  • Refactor
    • Updated the peer-to-peer communication backend to use an alternative message flooding implementation for network information sharing across distributed participants.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedApr 17, 2026, 9:22 AM

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 17, 2026

Claude finished @julienrbrt's task in 1m 22s —— View job


Code Review

  • Gather context and read changed files
  • Review code change in pkg/p2p/client.go
  • Review documentation updates
  • Post final review

Summary

Clean, minimal change — the actual implementation is a single line swap in setupGossiping. The rationale (from @Wondertan) makes sense: FloodSub is simpler and more predictable for small rollup networks where GossipSub's mesh overhead provides little benefit. Overall this is a reasonable direction.

Two issues found — one is a missed stale reference (minor bug), the other is an inaccurate description that could mislead future contributors.


Issues

1. Stale reference in README mermaid diagrampkg/p2p/README.md:27

The top-level architecture diagram was not updated:

Libp2p -- "Components" --> PubSub["GossipSub"]   ← still GossipSub

The second diagram at line 72 was correctly updated to FloodSub PubSub, but this first diagram was missed. Fix this →


2. Inaccurate description for FloodSubpkg/p2p/README.md:101

- Provides efficient message propagation with reduced bandwidth overhead

This description was carried over from GossipSub, but it's factually wrong for FloodSub. GossipSub was specifically designed to reduce bandwidth overhead via a mesh topology (it only forwards to D peers instead of all peers). FloodSub broadcasts to all directly connected peers — it has higher bandwidth overhead, which is the tradeoff you accept in exchange for simplicity. The description should be corrected to something like:

- Simple broadcast to all directly connected peers — predictable behavior for small networks

Fix this →


Suggestions (non-blocking)

ADR-003 missing rationaledocs/adr/adr-003-peer-discovery.md

The ADR was updated to replace GossipSub with FloodSub but no explanation for why was added. ADRs are most valuable when they capture the reasoning behind decisions. Consider adding a note (even just a sentence) under the relevant section explaining the tradeoff: FloodSub is simpler, has no misconfiguration risk (no mesh scoring/pruning), and is sufficient for small-topology rollup networks.


Code Change Assessment

The implementation change itself (client.go:453) is correct. pubsub.NewFloodSub(ctx, c.host) with default options is idiomatic. The function name setupGossiping remains appropriate as a generic term. No tests need updating since the pubsub interface is unchanged.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 17, 2026

Warning

Rate limit exceeded

@julienrbrt has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 31 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 53 minutes and 31 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 242ca4af-46d5-4d27-88c0-a0f388352f8e

📥 Commits

Reviewing files that changed from the base of the PR and between 28ec4f9 and c599936.

📒 Files selected for processing (5)
  • AGENTS.md
  • CHANGELOG.md
  • docs/adr/adr-003-peer-discovery.md
  • docs/overview/architecture.md
  • pkg/p2p/README.md
📝 Walkthrough

Walkthrough

The pubsub backend initialization in setupGossiping was changed from pubsub.NewGossipSub(ctx, c.host) to pubsub.NewFloodSub(ctx, c.host), switching the message propagation algorithm while maintaining existing error handling and assignment logic.

Changes

Cohort / File(s) Summary
Pubsub Algorithm Switch
pkg/p2p/client.go
Changed pubsub backend from GossipSub to FloodSub in the setupGossiping function initialization.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 From whispered gossip to a floody stream,
The rabbit hops through a new p2p dream,
One line changed, the message flows wide,
Through floodgates of truth, no secrets to hide! 💧

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete and lacks required information such as overview, context, rationale, and testing details specified in the template. Add a comprehensive overview explaining why GossipSub is being replaced with FloodSub, including the rationale, benefits, and any testing performed or needed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: replacing GossipSub with FloodSub in the p2p package, matching the code modification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch p2p-debug

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.35%. Comparing base (77b39d4) to head (c599936).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3263      +/-   ##
==========================================
+ Coverage   62.33%   62.35%   +0.02%     
==========================================
  Files         122      122              
  Lines       12877    12877              
==========================================
+ Hits         8027     8030       +3     
+ Misses       3969     3967       -2     
+ Partials      881      880       -1     
Flag Coverage Δ
combined 62.35% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@julienrbrt julienrbrt requested a review from auricom April 17, 2026 09:22
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-17 10:05 UTC

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/p2p/client.go`:
- Line 453: Switching c.ps from pubsub.NewGossipSub to pubsub.NewFloodSub (the
change at pubsub.NewFloodSub(ctx, c.host)) increases per-message egress and
removes GossipSub's mesh/gossip and scoring protections; update the PR by either
reverting to GossipSub or adding explicit justification and measurements: state
intended lifetime (temporary debug branch p2p-debug vs permanent), expected
production peer fan-out per node, and benchmark results showing FloodSub
bandwidth/duplicate delivery behavior for worst-case message sizes (blocks/data
blobs). Also mention impacts on downstream consumers such as
pkg/sync/sync_service.go which use goheaderp2p.NewSubscriber with
pubsub.DefaultMsgIdFn and explain how deduplication/delivery semantics will
change under FloodSub. Ensure this rationale is added to the PR description
and/or a comment near the pubsub.NewFloodSub call (c.ps) so reviewers can verify
the tradeoff.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3d1a083-28aa-491e-8bb1-4c41e73418c9

📥 Commits

Reviewing files that changed from the base of the PR and between 77b39d4 and 28ec4f9.

📒 Files selected for processing (1)
  • pkg/p2p/client.go

Comment thread pkg/p2p/client.go
func (c *Client) setupGossiping(ctx context.Context) error {
var err error
c.ps, err = pubsub.NewGossipSub(ctx, c.host)
c.ps, err = pubsub.NewFloodSub(ctx, c.host)
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Confirm the scalability tradeoff of switching to FloodSub.

FloodSub forwards every message to every connected peer with no mesh or gossip optimization, so per-message bandwidth scales linearly with peer fan-out. GossipSub was specifically designed to bound this cost via mesh degree (D) + gossip. For a blockchain P2P network propagating headers/blocks/data, this change can materially increase egress bandwidth and duplicate deliveries as the network grows, and it removes score-based peer protection against spam/amplification that GossipSub provides.

Since the PR description doesn't include rationale or benchmarks, could you confirm:

  1. Expected peer count per node in production — is fan-out bounded enough that flooding is acceptable?
  2. Whether this is intended as a temporary debug aid (the source branch is p2p-debug) or a permanent change.
  3. Any measurements showing FloodSub behaves acceptably for the largest expected message sizes (e.g., blocks/data blobs).

Also note that downstream consumers such as pkg/sync/sync_service.go pass pubsub.DefaultMsgIdFn to goheaderp2p.NewSubscriber; that should still work (it's a generic PubSub helper, not GossipSub-specific), but message deduplication characteristics will differ in practice under FloodSub's flood semantics.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/p2p/client.go` at line 453, Switching c.ps from pubsub.NewGossipSub to
pubsub.NewFloodSub (the change at pubsub.NewFloodSub(ctx, c.host)) increases
per-message egress and removes GossipSub's mesh/gossip and scoring protections;
update the PR by either reverting to GossipSub or adding explicit justification
and measurements: state intended lifetime (temporary debug branch p2p-debug vs
permanent), expected production peer fan-out per node, and benchmark results
showing FloodSub bandwidth/duplicate delivery behavior for worst-case message
sizes (blocks/data blobs). Also mention impacts on downstream consumers such as
pkg/sync/sync_service.go which use goheaderp2p.NewSubscriber with
pubsub.DefaultMsgIdFn and explain how deduplication/delivery semantics will
change under FloodSub. Ensure this rationale is added to the PR description
and/or a comment near the pubsub.NewFloodSub call (c.ps) so reviewers can verify
the tradeoff.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected and something I suggested. It does indeed increase bandwidth requirements; however, it simplifies the system substantially as well when it comes to propagation issue debugging. The gossipsub is an overkill for the scale evolve networks are deployed at and if the network ever grows to hundreds of peers we can always migrated back to gossipsub in a backwards compatible manner

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wondertan, thanks for the clear rationale — that makes complete sense. FloodSub is a reasonable fit for small, bounded networks where simplicity and debuggability outweigh bandwidth efficiency, and the backwards-compatible migration path to GossipSub if the network scales is a pragmatic safety net. I'll note this for future reviews.

ʕ •ᴥ•ʔ


✏️ Learnings added
Learnt from: Wondertan
Repo: evstack/ev-node PR: 3263
File: pkg/p2p/client.go:453-453
Timestamp: 2026-04-17T10:00:53.638Z
Learning: In evstack/ev-node, the p2p layer intentionally uses FloodSub (pubsub.NewFloodSub) instead of GossipSub. This is a deliberate design decision suggested by Wondertan: FloodSub simplifies propagation debugging, and GossipSub is considered overkill for the small peer counts (well below hundreds) at which evolve networks are deployed. Migration back to GossipSub is considered feasible in a backwards-compatible manner if the network ever grows significantly. Do not flag this as a scalability concern.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: alpe
Repo: evstack/ev-node PR: 3146
File: block/internal/syncing/da_follower.go:128-156
Timestamp: 2026-03-12T14:41:30.304Z
Learning: In evstack/ev-node, DA priority heights (queued via `QueuePriorityHeight` in `block/internal/syncing/da_follower.go`) are untrusted, best-effort optimizations sourced from P2P hints. Dropping a hint on a transient fetch failure is intentional — the sequential catchup loop in `da.Subscriber` will cover every height eventually. Do not flag missing retry/re-queue logic for priority hints as a bug.

Learnt from: alpe
Repo: evstack/ev-node PR: 3131
File: block/internal/syncing/syncer_backoff_test.go:241-245
Timestamp: 2026-03-06T09:40:36.029Z
Learning: In evstack/ev-node, the module declares go 1.25.6. Since Go 1.22, loop variables are per-iteration by default, so loop variable capture is not a concern. Do not flag or fix loop variable capture in this codebase for any Go files; this rule applies to all Go files in the repository, not just the specific test file.

@julienrbrt julienrbrt added this pull request to the merge queue Apr 17, 2026
Copy link
Copy Markdown
Contributor

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫡

Merged via the queue into main with commit 4c7323f Apr 17, 2026
39 of 40 checks passed
@julienrbrt julienrbrt deleted the p2p-debug branch April 17, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants