From 467e116b11f0641194b317b2bf292647671766a7 Mon Sep 17 00:00:00 2001 From: Ino Murko Date: Wed, 4 Dec 2024 13:15:10 +0100 Subject: [PATCH] feat(nonce): Update core_access.go adjust network nonce --- state/core_access.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/state/core_access.go b/state/core_access.go index a363577b1c..ef82f72939 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,21 @@ 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 { + log.Infof("Could not parse acount sequence log") + continue + } + 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 }