web3-multicall-go icon indicating copy to clipboard operation
web3-multicall-go copied to clipboard

Handle decoding errors gracefully

Open oilnam opened this issue 3 years ago • 1 comments

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! 🙏

oilnam avatar May 11 '21 12:05 oilnam

@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.

bowd avatar May 19 '21 03:05 bowd