ref-fvm icon indicating copy to clipboard operation
ref-fvm copied to clipboard

Eth JSON-RPC API: audit errors and not found situations

Open raulk opened this issue 2 years ago • 2 comments

The Eth JSON-RPC API currently happily assimilates internal errors to "not found" situations and returning empty objects. I suspect we need to distinguish between the two.

For example, in eth_getTransactionReceipt, we should return nil if we were unable to find the message, but we should return an error if StateReplay failed to execute. To a client, the fact that a receipt was not found is very different to a receipt being found and the node being incapable of processing it.

However, what we choose to do is dependent on what clients expect and how other standard node implementations behave. So some investigation is needed before we take action here.

raulk avatar Dec 22 '22 12:12 raulk

Some quick investigation reveals that these methods, for example, may return errors:

  • eth_getTransactionByHash
  • eth_getTransactionCount
  • eth_getTransactionReceipt
  • eth_sendRawTransaction
  • eth_getBlockByHash
  • eth_getBlockByNumber

These methods won't:

  • eth_getTransactionByBlockNumberAndIndex
  • eth_getTransactionByBlockHashAndIndex

The correct behavior here is:

  • not found => nil
  • internal error => error

@ychiaoli18 do you have some bandwidth to conduct this audit and implement the changes?

raulk avatar Dec 22 '22 12:12 raulk

Actually, I'll take this one since I'd feel better to have it ASAP.

raulk avatar Dec 22 '22 12:12 raulk