Alethio / web3-multicall-go

Go interface for a Multicall contract to batch EVM state reads in a single ethcall
MIT License
35 stars 29 forks source link

Handle decoding errors gracefully #4

Open oilnam opened 3 years ago

oilnam commented 3 years ago

Description: Decoding errors on sub-calls should not break the entire multicall.

Current behavior: a single decoding error on a sub-call results in the whole multicall breaking, returning an error.

Proposed behavior: a single decoding error on a sub-call will mark the sub-call as failed, without impacting all other calls.

Decoding errors can happen for a variety of reasons, for example if Geth doesn't return any data. I added a test with two calls to demonstrate the new behavior, where the broken calls is targeting a contract that self-distructed.

PS thanks for open sourcing this! 🙏

bowd commented 3 years ago

@oilnam Hey, thanks for looking into this and taking the time to open the PR! Yeah what you're saying makes a lot of sense, the whole thing shouldn't error out on a single decode issue. But I think the implementation would need to satisfy two additional properties to make sense:

  1. There is a way to differentiate between the view call reverting on-chain or because of a revert error.
  2. The decode error isn't lost.

I would also not overwrite the Success property because that's tied to the response struct from the Multicall contract and changing that could lead to confusion.