taikoxyz / taiko-mono

A based rollup. 🥁
https://taiko.xyz
MIT License
4.16k stars 1.99k forks source link

fix(relayer): return revert error instead of nil #16995

Closed bufrr closed 1 week ago

bufrr commented 1 week ago

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

cyberhorsey commented 1 week ago

We are not returning nil, we are returning err.

bufrr commented 1 week ago

We are not returning nil, we are returning err.

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

cyberhorsey commented 1 week ago

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.

bufrr commented 1 week ago

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

cyberhorsey commented 1 week ago

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.