Summary
The per-chain metrics file's inserted.logs field reports the raw streamed Portal log count, not the number of logs actually inserted into the sync-store. In a window whose raw logs are all dropped by client-side re-match, the file can therefore report logs > 0 while blocks = 0 and zero logs were inserted.
Mechanism
stats.logs is incremented from the raw streamed logs during range streaming: stats.logs += b.logs.length (portal/portal.ts ~L409). The code separately tracks matchedLogsAdded, confirming stats.logs is the raw (pre-match) count.
- Actual log insertion uses the assembled (post-re-match) set:
syncStore.insertLogs({ logs: assembled.logs }) in syncBlockRangeData (~L1000). Raw over-returned logs that assembly drops (e.g. bounded out-of-range logs — see the existing portal.test.ts coverage) are never inserted.
- The metrics file maps
inserted: { logs: stats.logs, ... } (portal/portal-metrics.ts ~L115), i.e. inserted.logs = the raw count.
Result: on a window where raw logs were streamed but all re-match-dropped, assembled.blocks is empty → syncBlockData takes the blockArr.length === 0 path and emits a metrics file with inserted.logs > 0, inserted.blocks = 0. The logs count contradicts the fact that nothing was inserted.
Scope / relationship to #140
This is pre-existing and independent of #140/#142 — the normal (non-empty) path already reports inserted.logs from the raw count. #142 (emit metrics on 0-block windows) merely surfaces it on one additional code path. The real #140 case (empty child-address set → 0 raw logs → stats.logs = 0) is unaffected and reports honest zeros.
Suggested fix
Make inserted.logs reflect logs actually inserted — count assembled.logs.length at insertion time rather than raw b.logs.length at stream time — so inserted.* is uniformly a store-insertion count. Note this metric feeds the completion-line provenance, so update that path together and add a regression test for a re-match-dropped-only empty window (logs reported = 0 when nothing is inserted).
Severity: low (observability/metric accuracy; indexing correctness unaffected). Surfaced during review of #142.
Summary
The per-chain metrics file's
inserted.logsfield reports the raw streamed Portal log count, not the number of logs actually inserted into the sync-store. In a window whose raw logs are all dropped by client-side re-match, the file can therefore reportlogs > 0whileblocks = 0and zero logs were inserted.Mechanism
stats.logsis incremented from the raw streamed logs during range streaming:stats.logs += b.logs.length(portal/portal.ts~L409). The code separately tracksmatchedLogsAdded, confirmingstats.logsis the raw (pre-match) count.syncStore.insertLogs({ logs: assembled.logs })insyncBlockRangeData(~L1000). Raw over-returned logs that assembly drops (e.g. bounded out-of-range logs — see the existingportal.test.tscoverage) are never inserted.inserted: { logs: stats.logs, ... }(portal/portal-metrics.ts~L115), i.e.inserted.logs= the raw count.Result: on a window where raw logs were streamed but all re-match-dropped,
assembled.blocksis empty →syncBlockDatatakes theblockArr.length === 0path and emits a metrics file withinserted.logs > 0,inserted.blocks = 0. Thelogscount contradicts the fact that nothing was inserted.Scope / relationship to #140
This is pre-existing and independent of #140/#142 — the normal (non-empty) path already reports
inserted.logsfrom the raw count. #142 (emit metrics on 0-block windows) merely surfaces it on one additional code path. The real #140 case (empty child-address set → 0 raw logs →stats.logs = 0) is unaffected and reports honest zeros.Suggested fix
Make
inserted.logsreflect logs actually inserted — countassembled.logs.lengthat insertion time rather than rawb.logs.lengthat stream time — soinserted.*is uniformly a store-insertion count. Note this metric feeds the completion-line provenance, so update that path together and add a regression test for a re-match-dropped-only empty window (logsreported = 0 when nothing is inserted).Severity: low (observability/metric accuracy; indexing correctness unaffected). Surfaced during review of #142.