Repository navigation
fix(server): one shared rule for Heard By, direct (no 1-byte hop, TRACE, failed-signature advert, retired prefix) - #31
Merged
Conversation
…TRACE, no failed-signature advert directHeardNode now goes through packetpath.HeardKey, the rule the ingestor already uses for client receptions. Three cases no longer credit a node: - a 1-byte last hop, even with a single known candidate: a node CoreScope does not know can share the byte; - TRACE, whose path bytes are per-hop SNR; - a zero-hop ADVERT with signatureValid false. An advert without the field still credits the advertiser. A 2-byte or longer hop still resolves through relayCandidates and still needs exactly one candidate. Benchmarks (go test -bench BuildDirectHeardIndex, old and new test binaries run alternately, 3 rounds x 2, minimum ns/op, noisy machine): - BuildDirectHeardIndex (3M observations, 2-byte last hop): old 67.9 ms, new 66.6 ms - BuildDirectHeardIndex_MixedHops (new, 500k observations, 1/2/3-byte hops, 5% zero-hop adverts): old 42.9 ms, new 39.4 ms A first version that looked the key up through relayCandidates lowered the case twice and measured 30-40% slower; the lookup now uses the already lower-cased key directly. The Heard By titles on the node page say a 1-byte hop is never taken as proof of who transmitted.
…s 1-byte hops Review follow-up on the shared heard rule: - directHeardNode checked signatureFailed for every empty-path observation before the ADVERT test. signatureFailed scans the decoded JSON and parses it when it holds a \u escape, so a zero-hop message could warm the decoded cache in the pass over all observations. The advert test now runs first. TestDirectHeardNode_ZeroHopNonAdvertLeaves DecodedCacheCold pins it. - The empty-state title of "Heard By, direct" (nodes.js, full page and side pane) now says a 1-byte hop is left unattributed too, the most common reason a node shows no direct observer since this rule.
…shares A repeater that retention moved to inactive_nodes is no resolver candidate, but it may still relay on its prefix. uniqueHopPrefix already refuses such a prefix as certain evidence (Kpa-clawbot#2260); directHeardNode now does the same, so a 2-byte or longer hop shared with a retired repeater credits nobody. Benchmark BuildDirectHeardIndex (3M observations), old and new test binaries alternated, 7 rounds x 2, minimum: old 64.1 ms, new 68.0 ms. The benchmark's prefix map has no retired prefixes; with a populated set the check is one map lookup per observation with a 2-byte or longer last hop.
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.
What
One rule decides which node an observation heard directly:
packetpath.HeardKey(internal/packetpath/heard.go). The ingestor (client receptions,deriveHeardKey) and the server ("Heard By, direct" on the node page,directHeardNode) both use it.The server rule gets stricter. These no longer credit a node as heard directly:
signatureValid: false: the pubkey is not proven to be the transmitter's. An advert without the field still counts.inactive_nodes, may still relay), the same checkuniqueHopPrefixalready does for certain liveness (Node liveness (Last Heard, Active status, Notify-me) counts ambiguous 1-byte hops: a silent repeater shows "Active, last relayed 4m ago" Kpa-clawbot/CoreScope#2260).Unchanged: flood last hop of 2 bytes or more with exactly one candidate, zero-hop adverts on flood and direct (
sendZeroHop), direct routes with a path never attribute. The ingestor's behaviour is unchanged:TestDeriveHeardKey_MatchesPacketpathpins it toHeardKey, and the node-discover branch stays in the ingestor.The node page tooltips ("Heard By, direct" title and its empty state) now say a 1-byte hop is not taken as proof.
This is PR 1 of the node analytics series (only what a node itself did). The analytics page itself is unchanged here.
Measured on staging
Same deployment, same config, two restarts about 10 minutes apart: old rule (
staging/2391, e41bcfe) then this branch (staging/2391-dh, 80a600a). Each snapshot was taken once the packet store stopped growing (130,896 and 130,869 packets), from/api/nodes/<pk>/healthfor all 1932 nodes.502a3b3f: 5 observers / 15,224 packets before, 3 / 550 after. Repeater2f0942c8: 21,882 packets before, 825 after.Browser check on staging: the node pages of
502a3b3fandf307fa08render the direct table with the same rows and totals as the snapshot, and the new tooltip text.Performance
directHeardNoderuns for every observation on each recompute pass (about 3M on a large instance). Old and new test binaries run alternately, minimum ns/op:BenchmarkBuildDirectHeardIndex(existing, 3M observations, 2-byte hops): 64.1 ms old, 68.0 ms new (with the retired check; its prefix map has no retired prefixes).BenchmarkBuildDirectHeardIndex_MixedHops(new, 500k observations, 1/2/3-byte hops, 5% zero-hop adverts): 42.9 ms old, 39.4 ms new. 1-byte hops now stop before the map lookup.The signature check runs only for ADVERTs, so a zero-hop message does not parse its decoded JSON in this pass (
TestDirectHeardNode_ZeroHopNonAdvertLeavesDecodedCacheCold).Tests
go test ./...ininternal/packetpath,cmd/ingestorandcmd/server: ok on this branch. On the fork staging base the three suites passed for the first four commits; after the retired commit onlygo vetand theDirectHeard|Certaintests ran there. Skipped locally:TestSaveGeoFilterPreservesFileModeandTestWriteStatsAtomic_SymlinkAtDestIsReplaced(Windows-only failures, unrelated).node tests/unit/test-direct-rf-heard-by.js(10 passed),node tests/unit/test-frontend-helpers.js(809 passed).TestHeardKey(11 cases),TestDeriveHeardKey_MatchesPacketpath, 5 newTestDirectHeardNodecases,TestDirectHeardNode_RetiredPrefixCreditsNobody, the cache test above, and an empty-state title assertion.Not done
src/meshpacket.js) is not updated; separate repo.v3.17.0, so it can go upstream as is.