taiko-mono icon indicating copy to clipboard operation
taiko-mono copied to clipboard

fix(relayer): return revert error instead of nil

Open bufrr opened this issue 9 months ago • 4 comments

Fixed condition that checks receipt status in function, ensuring revert in case of unsuccessful transactions

bufrr avatar May 05 '24 06:05 bufrr

We are not returning nil, we are returning err.

cyberhorsey avatar May 06 '24 01:05 cyberhorsey

We are not returning nil, we are returning err.

err will definitely be nil in this scenario, please review again @cyberhorsey

bufrr avatar May 06 '24 01:05 bufrr

We are not returning nil, we are returning err.

err will definitely be nil in this scenario, please review again @cyberhorsey

Ah, you're correct. However, we should try and get the actual revert reason here, and not return a generic error, as the proper fix. And then slog.Error the revert reason, if it was able to be decoded.

cyberhorsey avatar May 06 '24 01:05 cyberhorsey

We are not returning nil, we are returning err.

err will definitely be nil in this scenario, please review again @cyberhorsey

Ah, you're correct. However, we should try and get the actual revert reason here, and not return a generic error, as the proper fix. And then slog.Error the revert reason, if it was able to be decoded.

Sure, let me update the fix

bufrr avatar May 06 '24 01:05 bufrr

After looking at this code, this branch can not be hit. Because in sendProcessMessageCall, we have this:

	if receipt.Status != types.ReceiptStatusSuccessful {
		relayer.MessageSentEventsProcessedReverted.Inc()

		return nil, errTxReverted
	}

and thus:

	receipt, err := p.sendProcessMessageCall(ctx, msgBody.Event, encodedSignalProof)
	if err != nil {
		return false, msgBody.TimesRetried, err
	}

Will capture the scneario where the receipt status is not successful.

So, the above scenario is actually a duplicate status check left from a refactor, and if any improvement is to be made here, it would be to remove the top-level check, and replace it with decoding a revert reason and logging it.

cyberhorsey avatar May 06 '24 02:05 cyberhorsey