-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block response size check is not correct #1232
Comments
Requests/responses are encoded using unsigned-varint which just prepends a length (at most 9 bytes) to the message. This message length tag is not counted in so the block response has all of the 16 MB to use. It looks like right now the length is not checked for outbound messages which could cause "unexplainable errors" but I don't think exposing the details of the encoding should be exposed to the block request protocol and instead it should try to create the response within the limits that were provided when the protocol was initialized. |
If I understand correctly, we're encoding |
Fair enough. I think all the information is available to |
I was re-reviewing my PR paritytech/substrate#12146 and noticed that the size calculation (both before and after) is likely incorrect and can cause unexplainable errors.
Here estimation of total size accounts for some fields of
block_data
, but not others:polkadot-sdk/substrate/client/network/sync/src/block_request_handler.rs
Lines 419 to 430 in 0400ed9
I'm not aware of what are the historical reasons for this, but if my understanding is correct, response will always be strictly bigger than
total_size
estimated. The message, annoyingly, is in protobuf format, so suspect there is noencoded_size
method there, but I think it should push an entry intoblocks
, check encoded size and in case size is exceeded pop the value before breaking the loop.The text was updated successfully, but these errors were encountered: