Remove rejection of large JSON-RPC requests #1115
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.
cc #1098
After thinking about it, I've decided to go ahead and remove the limit of 64 MiB for JSON-RPC requests.
The presence of a limit is bad by itself due to the "additional thing to think about".
The existence of this limit was meant to limit the capacity for JSON-RPC clients to DoS the server by sending large requests. After all, the server can only allocate 4 GiB of memory in total due to compiling for
wasm32
.However, the current limit at 64 MiB is too large to be efficient. A client can simply send as many 64 MiB requests as possible and will reach the memory cap nonetheless.
Reducing the limit runs of the risk of actually running accidentally into said limit with legitimate requests.
If the JSON-RPC client is trusted, then there's nothing to do as the JSON-RPC client isn't going to DoS the server. There's still a risk of running out of memory space, but it will be solved by #88, and to me returning an error if requests are too large is no better than crashing.
If the JSON-RPC client isn't trusted, then it's good to have a limit to the size of requests (even with #88). When writing this PR, I initially added an option to
addChain
that allows specifying a limit. However, the code that wraps around smoldot also needs to enforce a limit for itself anyway, and as such a smoldot-specific solution isn't a good idea.