fix(client): correlate batch responses by JSON-RPC id#67
Closed
Dollyerls wants to merge 2 commits into
Closed
Conversation
SendBatch returned responses in server order while callers index them positionally. JSON-RPC 2.0 allows arbitrary batch response ordering, so a reordering node could associate a response with the wrong request. Realign responses to request order via the id field.
SendBatch returned responses in server order while callers index them positionally. JSON-RPC 2.0 allows arbitrary batch response ordering, so a reordering node could associate a response with the wrong request. Realign responses to request order via the id field.
Collaborator
|
Thanks for the PR! Rolled fwd with your commits in the linked PR |
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.
Batch responses must be correlated by
id, not by positionDescription
Client.SendBatchreturns the raw decoded reply slice, and every caller (plus the doccomment example) indexes it positionally —
responses[0]is assumed to answer the firstAdd. JSON-RPC 2.0 explicitly allows the server to return batch responses in anyorder, requiring the client to correlate them via the
idmember. We never did that.Steps to reproduce
eth_sendRawTransaction× 2).responses[0].Expected
responses[0]corresponds to the first request added.Actual
responses[0]holds whatever the server happened to put first — for the reversed reply,the wrong transaction's hash/nonce/receipt. Against well-behaved test servers it looks
correct; against a real reordering node it mismatches intermittently. For a parallel-nonce
SDK this means tracking or acting on the wrong transaction.