Commit 3178fda
authored
fix missing attestations by using GossipSub for subnet peer coverage (#19523)
## Summary
- Fix intermittent missing attestations caused by inaccurate subnet peer
coverage calculation. The previous ENR-based approach counted peers that
*claimed* to support subnets, while GossipSub mesh often had far fewer
actual subscribers (e.g., ENR showed 3 peers but GossipSub only had 1).
- Add proactive subnet peer search that runs every slot (12s) to find
and connect peers for underserved subnets (< 4 peers).
- Add subnet-aware peer pruning that avoids disconnecting peers covering
critical subnets.
- Allow subnet-useful peers past the peer limit in `onConnection` so
proactive search results are not immediately rejected.
## Root Cause
Attestations were published with only 1-2 peers on the GossipSub topic,
causing them to not propagate. The Sentinel used ENR `attnets` to
estimate subnet coverage, but ENR represents *capability* (what a peer
claims to support), not *actual GossipSub subscriptions*. This led to
the system believing it had sufficient peers when it didn't, skipping
peer search for those subnets.
## Changes
- **`cl/sentinel/discovery.go`**: Replace ENR-based
`getSubnetCoverage()` with GossipSub `ListPeers()` for accurate
coverage; add `proactiveSubnetPeerSearch()`, `findPeersForSubnets()`,
`pruneExcessPeers()`; subnet-aware `onConnection` handler
- **`cl/sentinel/sentinel.go`**: Store `*enode.Node` in `pidToEnr` (was
`string`) for ENR data access in `onConnection`
- **`cl/phase1/network/gossip/gossip_manager.go`**: Log peer count when
publishing attestations; remove `MinTopicSize(1)` to avoid publish
failures on empty topics
- **`cl/beacon/handler/block_production.go`**: Add subnet info to
"Produced Attestation" debug log
https://beaconcha.in/validator/1667009#charts
<img width="937" height="636" alt="截圖 2026-02-27 晚上7 48 54"
src="https://github.com/user-attachments/assets/e435b9ac-3ee3-444f-a4c1-fb1891d381b7"
/>1 parent 307b6ce commit 3178fda
File tree
6 files changed
+443
-14
lines changed- cl
- beacon/handler
- p2p/mock_services
- phase1/network/gossip
- sentinel
- peers
6 files changed
+443
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | | - | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
264 | 273 | | |
265 | | - | |
| 274 | + | |
| 275 | + | |
266 | 276 | | |
267 | 277 | | |
268 | 278 | | |
| |||
0 commit comments