-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Increase limit on light client response size #5461
Increase limit on light client response size #5461
Conversation
/// - max. pending requests = 128 | ||
/// - inactivity timeout = 15s | ||
/// - request timeout = 15s | ||
pub fn new(id: &ProtocolId) -> Self { | ||
let mut c = Config { | ||
max_data_size: 1024 * 1024, | ||
max_data_size: 64 * 1024 * 1024, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't 64MB not a little too much? Any idea why the request is that big?
I would have assumed that this #5179 brings down the size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would perhaps make sense to rename max_data_size
to max_request_data_size
and keep the 1 MiB limit (unless we expect requests to exceed this limit which is quite unlikely I guess). Currently max_data_size
is also used as a limit for the response data and we could have a separate and larger limit here which is then used in line 1080.
For clarification it's not the requests that are large, it's the responses. |
So I have a little setup with "polkadotjs <-> light node <-> full node" on a dev chain. The communications between the light and full nodes start with four identical Then I see a serie of RemoteReadRequests of sizes 70, 70, 110, 118, 185, 201, 259, 283, 333, 365, 407 Since the requests are mysteriously growing in size, here's the last read request before I shut down the node:
After trying again, I don't see this increase anymore and I might have just been measuring the outcome of a normal PolkadotJS activity, it's kind of hard to tell. |
It seems that the limit for responses here is 1.7MiB, but keep in mind that this is a dev chain and not Kusama/Polkadot, and I'm not sure how they compare. What about 16MiB for responses? This response size limit is mostly a way for light clients to know that they're not allocating an unreasonable amount of memory to store that response. Light client can't really get DoSed, as they are not supposed to get connected to and can just respond to any anomaly by closing their connections. Any "reasonable memory size" would look good to me. The limit for request sizes is probably more important and can probably be set at 4kiB, if that sounds reasonable? |
A 16MiB (or even bigger) response data limit looks good to me. |
Ahh I'm an idiot. |
Did the change. Also included a small unused import warning fix. |
I also realized that we don't need to deploy this to full nodes ahead of time, since the message size limit is not enforced on the sending size. I'll open the PR to switch to the new protocol shortly after this one is merged. |
I'm working on a pull request that switches to this new light client protocol, but I realized that none of the requests are going through on Polkadot because the maximum response size is too low.
Even the most basic responses are 1.7MiB in size, so more than the default 1MiB.
Unfortunately this also causes the connection to be force-closed (and immediately reopened afterwards) because of libp2p/rust-libp2p#1530
I'm opening this PR separately because we need it to be deployed on full nodes before light client can switch to this new protocol.