serverconn: ack stale unary responses - #544
Conversation
|
@claude review |
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to safely acknowledge and discard stale or unrelated envelopes without delivering actor messages, preventing the ingress loop from stalling. It adds a new ErrEnvelopeHandled sentinel error, a helper function IsIncomingMetadataCorrelationID to identify durable incoming metadata queries, and corresponding unit tests. The reviewer recommends adding a debug log when discarding stale responses to improve observability, and points out that a similar stalling issue likely exists for the ListOORRecipientEventsByScript route, which should also be addressed.
| if !oor.IsIncomingMetadataCorrelationID( | ||
| env.Rpc.CorrelationId, | ||
| ) { | ||
| return nil, serverconn.ErrEnvelopeHandled | ||
| } |
There was a problem hiding this comment.
While handling stale ListVTXOsByScripts responses by returning serverconn.ErrEnvelopeHandled is correct, doing so silently can make troubleshooting difficult if a valid response is misclassified. Adding a debug log helps with observability.
Additionally, the exact same stalling issue (described in #543) likely exists for the ListOORRecipientEventsByScript route (lines 2529-2535). If a stale normal unary response for ListOORRecipientEventsByScript is pulled from the mailbox, oor.ParseIncomingResolveCorrelationID will fail because the correlation ID lacks the expected OOR prefix, returning an error and stalling the ingress loop. You should implement a similar prefix check (e.g., oor.IsIncomingResolveCorrelationID) for that route to safely discard stale non-OOR responses.
| if !oor.IsIncomingMetadataCorrelationID( | |
| env.Rpc.CorrelationId, | |
| ) { | |
| return nil, serverconn.ErrEnvelopeHandled | |
| } | |
| if !oor.IsIncomingMetadataCorrelationID( | |
| env.Rpc.CorrelationId, | |
| ) { | |
| s.log.DebugS(context.Background(), | |
| "Discarding stale non-OOR ListVTXOsByScripts response", | |
| "correlation_id", env.Rpc.CorrelationId, | |
| ) | |
| return nil, serverconn.ErrEnvelopeHandled | |
| } |
There was a problem hiding this comment.
Both points addressed in e5dd7ef:
- Debug log on discard — added a
DebugSbreadcrumb (correlation_id/service/method) before returningErrEnvelopeHandledon this route. ListOORRecipientEventsByScripthas the same bug — good catch, it did. Applied the symmetric fix: newoor.IsIncomingResolveCorrelationID(withParseIncomingResolveCorrelationIDrefactored to use it), a matching prefix guard + debug log on that route, and aTestIsIncomingResolveCorrelationIDmirroring the metadata test.
|
Claude finished @bhandras's task in 2m 14s —— View job Code Review
The approach is clean and well-scoped. The One issue that should be addressed before merging:
|
524147d to
e5dd7ef
Compare
|
@claude addressed both your finding and Gemini's in
Validation: Please re-review. |
|
Claude finished @bhandras's task in 1m 35s —— View job Code Review (re-review)
All previous concerns are resolved. The fixes are symmetric, correct, and well-tested.
Both nil-check Tests — This PR is ready to merge. |
Fresh installs can replay old mailbox responses for the same client identity. A stale ListVTXOsByScripts response without the durable OOR metadata prefix should not poison ingress cursor advancement. Let envelope routes mark an envelope handled without actor delivery. The OOR metadata route uses that path for non-OOR metadata responses so checkpoint and ack processing can move on.
e5dd7ef to
8290933
Compare
Summary
Fixes #543 by letting mailbox ingress move past stale
ListVTXOsByScriptsresponses that are not correlated to a durable OOR incoming-metadata query.A fresh local install can start mailbox ingress from cursor 0 while reusing the same client mailbox identity, especially in lnd mode where the identity derives from the same wallet key. If the remote mailbox still contains old unary responses,
serverconnhas no in-memory waiter for them and falls back to durable route dispatch by service/method.The OOR metadata route handles
arkrpc.IndexerService/ListVTXOsByScripts, but durable OOR metadata responses are the only responses on that route that should be delivered to the OOR actor. Those responses use theoor-incoming-metadata:correlation prefix. Stale normal unary responses do not, so treating them as OOR metadata was making adaptation fail and preventing cursor/ack advancement.Changes
serverconn.ErrEnvelopeHandledso an envelope route can consume an envelope without delivering an actor message.oor.IsIncomingMetadataCorrelationIDto distinguish durable OOR metadata responses from ordinaryListVTXOsByScriptsresponses.Validation
make fmt-changedmake unit pkg=./serverconnmake unit pkg=./oormake unit pkg=./darepodmake lint-changed-localmake commitmsg-lint range="origin/main..HEAD"git diff --check