hedera-json-rpc-relay icon indicating copy to clipboard operation
hedera-json-rpc-relay copied to clipboard

Batch Requests - Method not allowed for batch request

Open AlfredoG87 opened this issue 2 years ago • 0 comments
trafficstars

Problem

Some methods should not be allowed to be requested as part of a batch.

Debug and Filter APIs to start with, but we might want to leave them in a configurable property that we can extend if needed.

Solution

  • New error
    code: -32007 message: Method <method> is not permitted as part of batch requests

  • New Configurable property with the list of the methods that are not allowed for batch.

  • Add a validation on each request, right before calling getRequestResult Current:

const promises = body.map((item: any) => this.getRequestResult(item, ctx.ip));

Proposed:

    const promises = body.map((item: any) => {
      //validate method is allowed for batch requests
      if(this.methodIsAllowed(item.method)) {
        this.getRequestResult(item, ctx.ip)
      } else {
        return jsonResp(item.id, new MethodNotAllowedForBatch(item.method), undefined);
      }
    });

Alternatives

No response

AlfredoG87 avatar Nov 08 '23 15:11 AlfredoG87