Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bd21 committed Nov 21, 2023
1 parent 860abc6 commit ee44cba
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/ethereum/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit ee44cba

Please sign in to comment.