Repository navigation
cl/p2p: send gossip messages ahead of queued sidecars - #26569
Merged
Merged
Conversation
Caplin publishes up to 128 data column sidecars per block to every mesh peer, and small time-critical messages (attestations, payload attestations, blocks, envelopes) wait behind them in the per-peer outbound queue. Use the WithMessagePriority router option to put every message except data column and blob sidecars in the priority lane. The option is not released upstream yet (libp2p/go-libp2p-pubsub#741), so go.mod replaces go-libp2p-pubsub with a fork that is v0.17.0 plus that commit, and the lint config allows the replace.
domiwei
requested review from
AskAlexSharov,
awskii,
sudeepdino008 and
yperbasis
as code owners
November 19, 2026 11:39
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Core queue scheduling depends on an unreleased pubsub fork absent from the snapshot, requiring human review of its pinned diff against v0.17.0 to verify queue bounds, synchronization, and priority semantics.
No open issues 🎉
What changed in this PR
This PR reduces Caplin gossip delays by prioritizing time-critical messages ahead of queued data column and blob sidecars in each peer’s outbound queue.
Changes:
- Enables GossipSub message priority for all topics except data column and blob sidecars, without changing queue limits.
- Pins a pubsub fork containing the unreleased priority option and permits the module replacement in lint configuration.
- Adds topic-classification tests and a mock-network test checking that attestations overtake queued columns.
| File | Description |
|---|---|
go.sum |
Replaces upstream pubsub checksums with the pinned fork’s checksums. |
go.mod |
Adds the pubsub fork replacement. |
cl/p2p/libp2p_setting.go |
Configures message priority and excludes sidecar topics. |
cl/p2p/libp2p_setting_test.go |
Tests topic priorities and outbound message ordering. |
.golangci.yml |
Allows the pubsub module replacement. |
Review effort: Balanced
awskii
approved these changes
Nov 19, 2026
Member
Author
|
Re-ran the E3 devnet A/B with the exact commits of this PR (240 measured slots, both nodes with a local timing-log overlay):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Caplin publishes up to 128 data column sidecars per block, each to the peers of its column subnet. Small, time-critical messages published or forwarded right after them (attestations, payload attestations, blocks, execution payload envelopes) wait behind several megabytes of columns in go-libp2p-pubsub's per-peer outbound queue.
This PR uses a new GossipSub router option,
WithMessagePriority, to put every message Caplin publishes or forwards, except data column and blob sidecars, in the queue's existing priority lane.cl/p2p/libp2p_setting.go:gossipMessageHasPriorityreturns false fordata_column_sidecar_*andblob_sidecar_*topics and true for every other topic.pubsubOptionspasses it topubsub.WithMessagePriority.go.mod: the option is not released upstream yet (Add WithMessagePriority router option libp2p/go-libp2p-pubsub#741), sogithub.com/libp2p/go-libp2p-pubsubis replaced bygithub.com/domiwei/go-libp2p-pubsub v0.0.0-20261119062000-9d96f54458a3. That commit is upstream v0.17.0 plus a cherry-pick of the commit from that PR, nothing else. Its go.mod is the same as in v0.17.0 and the require stays at v0.17.0, so no other module version changes; go-libp2p is not bumped. Once upstream releases the option, the require can move to that release and the replace can go..golangci.yml: allows the new replace ingomoddirectives.Behaviour to note:
PublishBatch, IWANT responses and heartbeat control traffic keep the queue they used before, as defined by the upstream option. The normal queue is sent only when the priority lane is empty, so on a link that cannot keep up with the prioritised traffic, sidecars, IWANT responses and heartbeat control traffic wait longer than before.Measurement
E3 local devnet: Kurtosis, 8 beacon nodes (Lighthouse, Teku, Prysm, Nimbus, Lodestar, Grandine and two embedded Caplin nodes), 40 ms one-way delay per link, every node responsible for all 128 data columns. The two Caplin nodes ran side by side for 240 slots: A = main d273dec, B = the same build with an equivalent version of this change (the fork code vendored locally). Both had a local timing-log overlay.
B − A, median of the paired per-slot differences with a 95% interval; the own-block rows compare different slots (unpaired, difference of the medians):
Block → head, envelope → FULL head and attestation_data latency moved by less than 1 ms. CPU moved by −0.004 cores and peak memory by +0.02 GiB (medians of the paired 12 s samples).
Tests
TestGossipMessageHasPrioritychecks the rule on full topic strings for the sidecar topics and for several other topic families.TestPubsubOptionsSendAttestationAheadOfQueuedColumnsbuilds a gossipsub router frompubsubOptionsand connects it to a mocknet peer that does not read yet. It publishes four 1 KiB messages on a data column topic and then one on an attestation topic, and checks that the attestation-topic message is not sent last. It fails when theWithMessagePriorityline is removed frompubsubOptions.gossipsub_priority_test.go, the same tests as in Add WithMessagePriority router option libp2p/go-libp2p-pubsub#741).make lint,go test ./cl/p2p/...andgo build ./cmd/erigon ./cmd/caplinpass.