diff --git a/state/core_access.go b/state/core_access.go index a363577b1c..5d3726cae1 100644 --- a/state/core_access.go +++ b/state/core_access.go @@ -6,6 +6,9 @@ import ( "fmt" "sync" "time" + "strings" + "regexp" + "strconv" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" @@ -267,6 +270,20 @@ func (ca *CoreAccessor) SubmitPayForBlob( continue } + //https://github.com/celestiaorg/celestia-app/pull/4067 ? + if err != nil && strings.Contains(err.Error(), "incorrect account sequence") { + regexpInt := regexp.MustCompile(`[0-9]+`) + numbers := regexpInt.FindAllString(err.Error(), -1) + log.Infof("Received nonce correction message from the network %w", err.Error()) + if len(numbers) != 2 { + return nil, fmt.Errorf("unexpected wrong sequence error: %w", err) + } + nonce, _ := strconv.ParseUint(numbers[0], 10, 64) + log.Infof("Adjusting nonce to %d", nonce) + ca.client.Signer().SetSequence(accName, nonce) + continue + } + if err != nil { return nil, err }