From 979f210828cc5aba2ce1b202d37d3b3a8335b6dd Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Tue, 20 Jun 2023 13:52:13 -0700 Subject: [PATCH] error handling --- packages/relayer/message/errors.go | 28 +++++++++++++++++++++ packages/relayer/message/process_message.go | 14 +++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 packages/relayer/message/errors.go diff --git a/packages/relayer/message/errors.go b/packages/relayer/message/errors.go new file mode 100644 index 00000000000..0bf2d406aeb --- /dev/null +++ b/packages/relayer/message/errors.go @@ -0,0 +1,28 @@ +package message + +import ( + "math/big" + "strings" + + "github.com/pkg/errors" +) + +var ( + //lint:ignore ST1005 allow `errMaxPriorityFeePerGasNotFound` to be capitalized. + errMaxPriorityFeePerGasNotFound = errors.New( + "Method eth_maxPriorityFeePerGas not found", + ) + + // FallbackGasTipCap is the default fallback gasTipCap used when we are + // unable to query an L1 backend for a suggested gasTipCap. + FallbackGasTipCap = big.NewInt(1500000000) +) + +// IsMaxPriorityFeePerGasNotFoundError returns true if the provided error +// signals that the backend does not support the eth_maxPrirorityFeePerGas +// method. In this case, the caller should fallback to using the constant above. +func IsMaxPriorityFeePerGasNotFoundError(err error) bool { + return strings.Contains( + err.Error(), errMaxPriorityFeePerGasNotFound.Error(), + ) +} diff --git a/packages/relayer/message/process_message.go b/packages/relayer/message/process_message.go index 6f5b635f7b2..b6b426fcb55 100644 --- a/packages/relayer/message/process_message.go +++ b/packages/relayer/message/process_message.go @@ -207,12 +207,16 @@ func (p *Processor) sendProcessMessageCall( gasTipCap, err := p.destEthClient.SuggestGasTipCap(ctx) if err != nil { - gasPrice, err := p.destEthClient.SuggestGasPrice(context.Background()) - if err != nil { - return nil, errors.Wrap(err, "p.destBridge.SuggestGasPrice") - } + if IsMaxPriorityFeePerGasNotFoundError(err) { + auth.GasTipCap = FallbackGasTipCap + } else { + gasPrice, err := p.destEthClient.SuggestGasPrice(context.Background()) + if err != nil { + return nil, errors.Wrap(err, "p.destBridge.SuggestGasPrice") + } - auth.GasPrice = gasPrice + auth.GasPrice = gasPrice + } } else { auth.GasTipCap = gasTipCap }