Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Jun 20, 2023
1 parent 7483173 commit 979f210
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
28 changes: 28 additions & 0 deletions packages/relayer/message/errors.go
Original file line number Diff line number Diff line change
@@ -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(),
)
}
14 changes: 9 additions & 5 deletions packages/relayer/message/process_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 979f210

Please sign in to comment.