fix(sink): always update requestActiveStartBlock on session init#792
fix(sink): always update requestActiveStartBlock on session init#792maoueh wants to merge 2 commits into
Conversation
The Response_Session case in (*Sinker).doRequest short-circuited with a bare `break` when the handler implemented SinkerSessionInitHandler, skipping the `s.requestActiveStartBlock = r.Session.ResolvedStartBlock` assignment. That field is consumed by the Response_ModulesProgress case to compute ProgressMessageLastContiguousBlock for production-mode mapper stages, so a custom session-init handler silently left the metric wrong. Remove the `break` entirely: the custom handler (when present) is still invoked, but the default log line and the requestActiveStartBlock assignment now run unconditionally. The case body is extracted into a documented private method (*Sinker).handleSessionInit for testability. # Conflicts: # docs/release-notes/change-log.md
Document on the SinkerSessionInitHandler interface that HandleSessionInit behaves as an interceptor and does not short-circuit the Sinker's normal session-init handling: the default "session initialized" log line and the internal resolved-start-block bookkeeping still run after the callback.
1df8f5f to
49c9cc5
Compare
🔍 Vulnerabilities of
|
| digest | sha256:08b189fdea008f7530b53dc595c0484dd3e33f47fd7a81400af67e9c7f82871f |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 116 MB |
| packages | 353 |
📦 Base Image ubuntu:24.04
# ./Dockerfile (17:17)
COPY --from=build /app/substreams /app/substreams
Description
Description
Description
Description
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# ./Dockerfile (17:17)
COPY --from=build /app/substreams /app/substreams
Description
|
Summary
Fixes a latent bug in
(*Sinker).doRequest'sResponse_Sessionhandling. When the registered handler implementedSinkerSessionInitHandler, the case body did a barebreakright after invokingHandleSessionInit, which skipped the sinker-internal bookkeeping that follows — most importantlys.requestActiveStartBlock = session.ResolvedStartBlock.That field is consumed in the
Response_ModulesProgresscase to identify the contiguous completed range covering the user's resolved start block. WithrequestActiveStartBlockleft at zero, the predicate0 <= r.StartBlock && r.EndBlock >= 0is trivially true, causingProgressMessageLastContiguousBlockto be overwritten by every completed range of the last (mapper) stage in production mode instead of only the contiguous one. Impact is metric-only (no data correctness impact) and latent today since no SF repo currently implementsSinkerSessionInitHandler.Changes:
Response_Sessioncase body into(*Sinker).handleSessionInit. The customSinkerSessionInitHandler.HandleSessionInitcallback (when implemented) now runs as an interceptor: the default "session initialized with remote endpoint" log line and therequestActiveStartBlockassignment always run afterwards, regardless of whether a custom handler is installed.SinkerSessionInitHandlerinterface (sink/types.go) to make explicit that it behaves as an interceptor and does not short-circuit the sinker's default session handling.sink/sinker_test.go.## Unreleased.Test plan
go test ./sink/...passesgo vet ./sink/cleanProgressMessageLastContiguousBlockmetric stays correct for a production-mode mapper sink that implementsSinkerSessionInitHandler