nethermind icon indicating copy to clipboard operation
nethermind copied to clipboard

Redesign first layer of JSON RPC

Open tkstanczak opened this issue 5 years ago • 4 comments

The calls should extract method name then resolve an RpcRequestHandler

RpcRequestHandler should be an abstract class from which a specific, e.g. EthBlockNumber should inherit. (we have done similar code for Catalyst and it avoid a lot of nonsense there)

Then we should invoke the method with parameters and with the response body stream passed directly.

Each handler should support 'smart' cached responses. For example on eth_getBlockByNumber or eth_blockNumber we can easily cache the most likely responses already serialized.

image

tkstanczak avatar Feb 02 '20 20:02 tkstanczak

there is a code sample for it

tkstanczak avatar Jun 25 '20 21:06 tkstanczak

Currently each JSON RPC request is being processed by a series of classes - JsonRpcProcessor, JsonRpcService and then particular modules. The way the modules like EthModule : IEthModule are implemented in Nethermind has a few disadvantages. The code for the whole module is in a single class which may lead to quite big classes handling multiple different requests. The amount of dependencies a single module may require can grow excessively as each method may require some dependencies but not others.

I have worked on a slightly better, cleaner approach for Catalyst which can be found here. It assumes that each handler is an independent class with a single responsibility of handling a specific request.

tkstanczak avatar Jun 29 '20 16:06 tkstanczak

I think we did quite a lot recently around jsonrpc deserialization and some nice improvement in gaslimit project also.

Can you guys check if anything more should be done here? cc @MarekM25 @LukaszRozmej @benaadams

kamilchodola avatar Jun 03 '24 13:06 kamilchodola

This proposal is to split up modules to a single class per request. I find it kind of optional, would make some things better, but might make some worse in terms of code organisation.

Won't change actual functionality

LukaszRozmej avatar Jun 03 '24 16:06 LukaszRozmej