Repository navigation
fix(p2p)!: enforce peer penalties and validate network settings - #1550
Conversation
Disconnect peers sending malformed protobuf, excessive envelope attributes, or structurally invalid consensus messages. Retain ordinary-peer score penalties across eviction while preserving reserved-slot protections and unknown-message compatibility. Avoid production-level peer-error log floods. Enforce connection windows while other connections remain open, initialize newly scored peer records, and validate P2P configuration with migration defaults. Preserve existing IPv6 buckets and bounded timestamp tracking. BREAKING CHANGE: invalid P2P configuration now prevents startup. An explicit zero incoming-connection-window is rejected; omit it for the 10ms default or configure a duration of at least 1ms. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude GPT-6 <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit 5e2ecde) · triage: critical |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification at head 4618821 confirms two blocking gaps: a missing inner vote bypasses malformed-data eviction, and downstream logging defeats the intended Debug-level handling of peer-controlled errors. Current GitHub checks show successful build, test, lint, and security checks, with PR Hygiene pending; no local builds or tests were run.
🔴 2 blocking
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff is large and intricate and changes peer-facing network deserialization and validation in internal/p2p/router.go, including malformed-message handling, penalties, disconnections, and resource-exhaustion defenses. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `internal/consensus/reactor.go`:
- [BLOCKING] internal/consensus/reactor.go:1072-1079: Reject missing inner votes before conversion can panic
The valid protobuf envelope bytes `ca 01 00` decode to an Envelope_Vote containing `tmcons.Vote{Vote:nil}`. EnvelopeFromProto accepts this recognized payload, and the message-cost calculation tolerates the nil inner vote. However, MsgFromProto calls types.VoteFromProto(nil), which dereferences `pv.BlockID` at types/vote.go:94. The recovery handler returns an ordinary error instead of reaching this ErrInvalidData wrapping. Consequently, an ordinary sender remains connected below capacity, and a reserved sender remains connected even at capacity. Sending the payload on ConsensusStateChannel reaches conversion before channel-specific type checking and lets the peer repeatedly generate panic stack traces without forced eviction. This directly bypasses the PR's promised handling of malformed recognized consensus messages. Reject nil input in VoteFromProto so conversion returns a normal error that this branch can classify; do not classify arbitrary recovered panics as peer faults. Add a wire-decoding/reactor regression that asserts ErrInvalidData and the resulting eviction policy.
In `internal/p2p/router.go`:
- [BLOCKING] internal/p2p/router.go:413-414: Preserve Debug classification through downstream peer-error logging
The Debug log above does not prevent production-level log amplification: PeerManager.Errored unconditionally logs at Error at peermanager.go:1224, and production node setup installs a real logger on that manager. The newly added unknown-envelope path invokes reportPeerError for every rejected frame and continues receiving; at capacity, each call reaches this Error log until asynchronous eviction closes the connection. This creates a new Error-per-frame path for unknown payloads. Malformed-data returns also reach routePeer's Error-level `peer failure` log, while consensus conversion rejections remain Error-level because isPeerFloodableError recognizes neither ErrInvalidData nor ErrUnrecognizedMessage. The new logging regression cannot detect these paths: it runs below capacity, installs its logger only on the router, and calls receivePeer without routePeer. Carry the peer-input classification through the downstream logging sites while preserving visibility for internal faults, and cover unknown payloads at capacity plus malformed-data shutdown using a shared real logger.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
Return ErrVoteNil for missing inner votes so recognized malformed messages reach invalid-data eviction without invoking panic recovery. Preserve the existing consensus unknown-message sentinel while carrying its peer-input classification through manager and router logging. Add wire/reactor, capacity and shared-logger teardown regressions, plus controls retaining Error visibility for internal failures. Targeted types, P2P and consensus race/deadlock checks and scoped lint pass. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Codex GPT-6 <[email protected]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The current head fixes both previously reported issues: peer-input classifications remain at Debug through downstream logging, and missing inner votes are rejected before conversion can panic. However, the new unknown-envelope path synchronously persists a peer-score update for every version-skew or unknown payload while continuing to receive, creating unbounded disk-I/O and shared-lock amplification; this requires changes. CI also has an unrelated failure in tests (00) for blocksync, while tests (03) and both end-to-end checks were still running in the supplied snapshot.
🔴 1 blocking
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The cross-cutting change is intricate and directly alters peer-facing network deserialization in internal/p2p/router.go receivePeer, including malformed protobuf classification, disconnection, and persistent scoring behavior. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `internal/p2p/router.go`:
- [BLOCKING] internal/p2p/router.go:913-917: Avoid database writes for every unknown envelope
An ordinary connected peer can repeatedly send small, valid protobuf envelopes whose oneof payload is unknown or absent. This branch reports each envelope and continues receiving, so the input is not bounded by disconnect policy or a reactor message limiter. `reportPeerError` synchronously calls `processPeerEvent`; that method holds `PeerManager.mtx` while `peerStore.Set` marshals the peer and unconditionally calls the backing database. Because `MutableScore` is ephemeral and omitted by `peerInfo.ToProto`, each score decrement still performs a database write until the score reaches `math.MinInt16` (up to 32,768 writes per peer), while the shared manager lock delays admission, eviction, scoring, and processing for other peers. The previously existing behavior dropped these envelopes without entering this persistence path. Coalesce or rate-limit unknown-message accounting, or avoid persisting records when only the ephemeral score changes; add a counting-database regression that verifies an unknown-envelope burst does not produce one database write per frame.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
Unknown-payload envelopes are now reported as peer errors, so every such frame reached processPeerEvent, which persisted the whole peer record via peerStore.Set while holding PeerManager.mtx. MutableScore is not part of the persisted record, so each of those writes changed nothing on disk, yet a peer could trigger one per frame. Known peers now have only their in-memory score updated (with the Ranked() cache invalidated); first-sight records are still persisted as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Static verification of the complete 89206d2..003edb6 range at head 003edb6 found no actionable in-scope defects; all three prior findings are fixed. Current CI passes the Linux build, all six unit-test shards, both end-to-end variants, application tests, vet, lint, protobuf and mock checks; only PR Hygiene remains pending, and no builds or tests were run locally. The base is six commits ahead, with no reported merge conflicts or intervening commits modifying this PR's changed files.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large diff changes critical peer-facing network deserialization and consensus message validation in internal/consensus and internal/p2p, including malformed-input eviction and penalty behavior. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
…limit With MaxConnected = 0 there is no connection pressure to relieve, but ShouldDisconnectOnError read every non-fatal error as being at capacity and evicted the peer. This PR routes unknown envelopes through that path. TestRouter_Network and TestRouter_Channel_Error relied on that defect, so they now send a fatal error to exercise disconnection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Client.resolve never checked the sender, so a colluding peer that knew a request ID could settle another peer's request and set its generation. The report then named the asked peer with the colluder's generation, and eviction was skipped as stale. A response from any other peer is now reported as unsolicited, leaving the request open for the peer asked. Tighten the block sync and client tests so decode, validation, await and duplicate-response mutants fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Verified the complete assigned diff at bdd7682 and independently confirmed that all 14 prior findings are fixed. Two in-scope blockers remain: consensus can discard already-established peer failures after disconnection, and intrinsically invalid transport fields bypass score accounting. Validation was static only; diff checks passed, the worktree remained clean, current build/test/lint/e2e checks are pending, and the supplied six-commit base drift has no conflicting or overlapping changed files.
🔴 2 blocking
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate diff changes peer-facing network deserialization in internal/libs/protoio/reader.go ReadMsg and internal/p2p/conn/connection.go recvRoutine, coupling malformed-input classification to connection teardown and generation-fenced peer penalties across reactors. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `internal/consensus/reactor.go`:
- [BLOCKING] internal/consensus/reactor.go:1482-1486: Forward verified peer errors even after the originating peer disconnects
The attributed report is still behind the GetPeerState guard at lines 1474–1478. If commit verification establishes an invalid signature and enqueues peerErrorMsg, but peerDown removes the sender before peerErrorRoutine drains it, the guard discards the report. Disconnected itself does not lower the score, so the ordinary peer reconnects without paying the intended identity-level penalty. The post-handler liveness check at lines 1388–1389 likewise discards an already-established ErrInvalidData failure when disconnect processing wins that interval. Keep the admission check for unprocessed stale work, but forward established failures with their originating ConnID regardless of current reactor peer state; PeerManager.ErroredConn already fences eviction without suppressing identity-level accounting. Add a deterministic regression that processes peer-down before draining a verified failure and checks that the score decreases while a replacement connection survives.
In `internal/p2p/conn/connection.go`:
- [BLOCKING] internal/p2p/conn/connection.go:527-530: Include intrinsically invalid transport fields in malformed-input accounting
The retained failure is recorded only when ReadMsg returns ErrMalformedMsg. PacketMsg.ChannelID is an int32, so an authenticated packet carrying ChannelID = -1 decodes successfully, reaches the intrinsic range check at lines 571–575, and stops the connection with an unmarked error. Neither onError nor PeerInputError classifies that rejection, so routePeer disconnects the sender without decreasing its score. A negative channel ID is intrinsically invalid, not an unopened channel or compatible version skew, and therefore leaves a sibling malformed-input path outside this PR's lasting-penalty policy. Separate intrinsic field-range violations from unknown in-range channels, mark and retain the former before stopping through the same teardown-safe mechanism, and extend the real SecretConnection regression to assert exactly one score penalty for a decodable packet with a negative channel ID.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
A forged commit or invalid data was dropped if peer-down won the race to the report, so the peer reconnected without its score penalty. ConnID now fences eviction, so both reports are forwarded whatever the reactor's peer state. Other handler rejections from an ended connection stay a silent local drop, and unprocessed stale envelopes stay refused at admission. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A decodable packet with a negative channel ID stopped the connection with an unmarked error, so the sender paid no score penalty. No protocol version can produce one, so it now takes the malformed-frame path. Unknown channels are unchanged: they end the connection without a penalty, because a newer peer can legitimately use them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stale rejection used an unpriced message on the vote channel, whose limiter dropped it before the handler, so the test passed without the re-check. Send it on the data channel so it reaches the re-check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ChannelID is a uint16, so no conforming sender can produce an ID above 65535. Treat those like negative IDs: retained as malformed, one penalty. IDs from 256 to 65535 stay unknown channels with no penalty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
At exact head 5e2ecde, independent static verification of the complete diff confirms that all 16 prior findings are fixed, with no remaining actionable in-scope findings. The Linux build, go vet, golangci-lint, and test shard 03 pass; the other test shards, end-to-end tests, generated-code checks, Super linter, and vulnerability check remain pending, and no local builds or tests were run. The diff whitespace check passes, and the supplied base-drift evidence reports six commits behind with no conflicts or overlapping changed files; one verified pre-existing state-sync issue is retained solely for separate follow-up.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This large, intricate diff directly changes peer-facing network deserialization in internal/p2p/conn/connection.go and internal/libs/protoio/reader.go, together with connection-generation fencing and malformed-input penalty handling across the router and reactors. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Prevent duplicate light-block responses from blocking the state-sync dispatcher — Dispatcher.Respond holds d.mtx while sending into a one-element response channel, while lightBlockWithConn consumes only one result and needs that mutex for deferred retirement. A queried peer can send duplicate responses, including empty responses: once one duplicate fills the channel, a further Respond can block holding the mutex and prevent retirement and unrelated dispatcher operations. Request timeout cannot break this cycle because Respond uses the reactor context. The same blocking-send and retirement algorithm exists at merge base 565c85b; this PR adds connection metadata without introducing, worsening, or relying on the duplicate-response behavior.
- Follow-up: Track a separate security fix that makes settlement single-shot and nonblocking under the dispatcher mutex, with a deterministic regression covering duplicate responses, retirement, unrelated requests, and cancellation.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
…iting-consensus-ccf700 Conflicts with #1550 (enforce peer penalties) in the p2p peer error path: the base now logs every peer error at Debug in Router.reportPeerError and marks floodable consensus rejections with p2p.ErrRejectedPeerInput for the peer manager's eviction log. That covers what PeerError.Floodable did, so the field, its router branch and its router test are dropped in favor of the base, and the reactor reports carry the base's ConnID. The malformed liveness message test now checks for ErrRejectedPeerInput. Co-Authored-By: Claude Opus 5.5 <[email protected]>
TL;DR: Disconnect peers that send malformed data, retain ordinary peers' penalties across reconnects, and reject invalid network settings at startup.
User story
As a node operator, I want malformed network traffic to have a lasting consequence while compatible peers remain connected, so my node can continue serving useful traffic.
Scenario
Base flow
A node receives traffic from connected peers, including peers reconnecting after a disconnect or running another compatible version.
Actual behavior
Malformed traffic can be discarded without a lasting penalty. A sender keeping another connection open can bypass the reconnect window. Invalid network settings can escape startup validation.
Expected behavior
Malformed traffic disconnects its sender and lowers an ordinary peer's score. Reserved peers retain their scoring exemption and protection from connection pressure, but malformed data still disconnects them. Unknown message types follow ordinary error handling, and unknown channels remain tolerated. Reconnect limits apply while another connection remains open. Invalid network settings produce actionable startup errors.
Detailed discussion
What was done
ErrVoteNil, so malformed recognized envelopes follow invalid-data eviction instead of panic recovery.ErrInvalidDataand classify malformed protobuf, excessive envelope attributes, and structural validation failures of recognized consensus messages. Preserve a distinct unknown-message error for version skew.PeerErrorcarries the sender'sConnID, and the peer manager schedules eviction only while that connection generation is live. The generation travels with the eviction into the router, and every envelope-derived report (router, consensus, evidence, PEX, statesync including backfill, p2p client) carries it too. Block sync reports carry the generation of the connection that delivered the response, or the one recorded when the peer was reserved if there was no response. A block response from a peer other than the one asked no longer resolves the request. The score penalty still applies to the peer identity.ErrInvalidData, record that classification before the connection stops, and account for it once in the router after both I/O workers finish. Router-level decode penalties use the router context, so send-side teardown cannot drop them. I/O errors, the config-dependent size limit, and SecretConnection read/MAC errors are not penalized.newPeerInfoso later address insertion is safe.MutableScoreis not persisted, so peer-triggered score changes no longer write the peer database underPeerManager.mtxonce per frame./64buckets and bounded timestamp storage.Known limitations
Testing
On Go 1.27.3/Linux with native BLS, focused types, P2P and consensus tests pass with
-race -tags=deadlock -p 1. Deterministic regressions reproduced the missing-vote panic and downstream Error amplification before the fixes. Coverage includes the exactca 01 00wire envelope, ordinary/reserved eviction policy, shared logger behavior at capacity, malformed connection shutdown, and internal-error visibility.The PR also includes regression coverage for excessive attributes, ordinary peer scoring, connection tracking, reserved-peer handling and configuration validation/migration. Pinned golangci-lint v2.15.0 reports zero issues; formatting and diff checks pass. Full repository and live network end-to-end suites were not run for this review update. Current-head CI is pending.
Breaking changes
Previously unchecked
[p2p]settings now prevent startup when invalid. In particular, an explicitincoming-connection-window = "0s"is rejected; omit the key for the default10ms, or specify at least1ms. Generated default configuration remains valid. Withmax-connections = 0, the validator, peer manager and listener all use the default of 64.Prior work
Preserves the reserved-peer, router delivery, connection-generation, and bounded-tracker behavior in the current upstream base.
Attribution
🤖 Co-authored by Claudius the Magnificent AI Agent
PR Hygiene ·
5e2ecdeWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.