node/evm: return per-element error in batch poller#4895
Open
peaktwilight wants to merge 1 commit into
Open
Conversation
When a batched eth_getBlockByNumber call succeeds at the transport level but an individual element fails, RawBatchCallContext records the failure on that batch element (batch[idx].Error). getBlocks and getBlockRange instead inspected results[idx].err, a field that is never populated, and on a hit returned the outer transport error, which is nil on this path. A failed block fetch was therefore reported as an empty success rather than an error. Read the per-element error from batch[idx].Error and return it so callers observe the real failure. The unused err field on BatchResult and the no-op Error assignments that fed it are removed. Worst case previously was downstream len/nil handling of the empty result leading to a watcher restart, so this is a correctness cleanup, not a security fix. Add table-driven coverage for getBlocks and getBlockRange that injects a per-element error and asserts the error propagates, alongside the success case.
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.
When a batched eth_getBlockByNumber call succeeds at the transport level but an individual element fails, getBlocks and getBlockRange logged the per-element error but then returned the outer err, which is nil on that path, so a failed block fetch was reported as an empty success instead of an error.
Note: geth records per-element failures on batch[idx].Error; the previously-referenced results[idx].err field is never populated, so the error branch never fired. This fix reads batch[idx].Error at both sites and removes the dead field.
Worst case previously was downstream nil/len handling of the empty result leading to a watcher restart, so this is a correctness cleanup, not a security fix. Adds a table-driven test proving the per-element error now propagates.