p2p, blocksync: add native peer observation hooks - #46
Draft
0xrukimedo wants to merge 1 commit into
Draft
0xrukimedo wants to merge 1 commit into
0xrukimedo wants to merge 1 commit into
Conversation
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
Expose thin native peer observation hooks so Heimdall can score repeated bulk requests and existing validation outcomes without a sidecar or a second P2P stack. An application installs
Config.P2P.PeerObserverbefore node construction; the field is excluded from serialized config and defaults to nil.Both connection directions report decoded messages and their existing envelope sizes, successful local send-queue acceptance, and existing decode/unwrap failures. Blocksync/statesync report basic validation failures before their existing disconnect paths. Local
MaxSnapshotChunkspolicy rejection is excluded from correctness evidence. Hooks borrow messages; they perform no extra serialization, hashing, validation, scoring or admission themselves.Heimdall owns bounded scoring and metrics through this interface. Existing protocol validation, disconnects, bans, snapshot exclusions and serving behavior remain unchanged. Queue acceptance is explicitly not delivery/acknowledgement. Deferred validation needs supplier provenance before adding more evidence hooks. See
p2p/observation/README.mdfor the callback contract.Executed tests
go test -race ./p2p/... ./blocksync ./statesync ./configpassed, including real transport tests for both directions, malformed messages, send outcomes and reactor validation. An initial non-race run failedTestBadBlockStopsPeer; the later complete race-enabled package run passed.origin/developpassed.origin/developpassed: 16/16 mutations killed, T1 3/3; structure/size/dependency checks passed. Existing-function churn warnings remain informational.go mod verifyand diff whitespace checks passed.govulncheck ./...reports 18 reachable dependency advisories across six modules. Cleanorigin/developreports the identical 18 advisories; no new advisory IDs. This is not a clean standalone security scan. Dependency/security review is required before release. Heimdall's composed dependency graph is scanned separately.Rollout notes
Draft only. This is the native companion for Heimdall peer reputation observation: 0xPolygon/heimdall-v2#651. No observer means no new telemetry/policy state. Application callbacks must use bounded memory/work, perform no I/O, retain no message and never call networking recursively. Runtime observer replacement is unsupported.
No enforcement, new listener, IPC, sidecar, SDK change or identity mapping. No deployments, live sentry calibration, full CometBFT repository test run, Kurtosis run or live dashboard installation were performed. CI/security gates remain required before merge.