hotfix: overestimate batch size to avoid a DoS #1775
+30
−5
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.
The batcher could be brought to a stalemate by how it estimates the serialized size of a batch.
Currently, it misses the type and length indicator in the CBOR format when building the array of proofs to verify, so it sends batches bigger than operators had agreed on accepting.
See #1746
An accurate fix would be to use the whole array size by serializing the batch completely. However, that involves the following sources of complexity:
Instead, we go for a little over-estimation in the estimation, assuming it will always be the biggest marker (9 bytes).
We also add an assertion at startup to make sure configuration is consistent: if you won't send batches bigger than
N
bytes, you can't accept proofs bigger thanN-9
bytes.Type of change
Checklist
testnet
, everything else tostaging