fix: response checking from RequestManager for blobs #6755
Merged
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.
Previously
checkResponse
for blobs could potentially return some erroneous results for certain values ofidList
. The algo went like:here, initially
found
isfalse
, say we check the first elem ofidList
, we see it passes correctly through theif
statement, we may seefound
astrue
and exit the inner loop, thereby NOT checking the other elements of theidList
,else
we straightway returnfalse
. hence, in any case we DON'T correctly iterate throughidList
and check it.one simple attack, could be a situation where the seq of
BlobSidecar
has the correct inclusion proof, but any of the non 1st response element(s) is/are missing/incorrect,checkResponse
regardless should still respond astrue
.looking at all of this, here's an updated algo, this iterates through the
idList
and the responded seq using a common loop control variable, and efficiently jumps if only a subset of the request has been responded correctly, it performs this check using a binary search.thereby, the final time complexity of this response checker drops from
O(n^2)
(ifidList
was correctly iterated), toO(n log n)
. this optimization should be more relevant for data columns later as well, as we would often ask for columns in the order of 50-60 of them, if we were a supernode.