From ee44cba7c20f8e394adeebc547e33e645da0aa3e Mon Sep 17 00:00:00 2001 From: bd21 Date: Tue, 21 Nov 2023 01:20:20 -0800 Subject: [PATCH] fix --- cmd/ethereum/broadcast.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/ethereum/broadcast.go b/cmd/ethereum/broadcast.go index d2dff54..a345437 100644 --- a/cmd/ethereum/broadcast.go +++ b/cmd/ethereum/broadcast.go @@ -12,6 +12,8 @@ import ( "github.com/strangelove-ventures/noble-cctp-relayer/config" "github.com/strangelove-ventures/noble-cctp-relayer/types" "math/big" + "regexp" + "strconv" "time" ) @@ -69,7 +71,19 @@ func Broadcast( } logger.Debug(fmt.Sprintf("retrying with new nonce: %d", nonce)) sequenceMap.Put(cfg.Networks.Destination.Ethereum.DomainId, nonce) + } + match, _ := regexp.MatchString("nonce too low: next nonce [0-9]+, tx nonce [0-9]+", parsedErr.Error()) + if match { + numberRegex := regexp.MustCompile("[0-9]+") + nextNonce, err := strconv.ParseInt(numberRegex.FindAllString(parsedErr.Error(), 1)[0], 10, 0) + if err != nil { + nonce, err = GetEthereumAccountNonce(cfg.Networks.Destination.Ethereum.RPC, ethereumAddress) + if err != nil { + logger.Error("unable to retrieve account number") + } + } + sequenceMap.Put(cfg.Networks.Destination.Ethereum.DomainId, nextNonce) } }