From 5c29c7c0d4c35c6cd0b000240b8b050659089435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= Date: Thu, 19 Sep 2024 09:37:55 +0200 Subject: [PATCH] fix nonce too low --- ethtxmanager/ethtxmanager.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ethtxmanager/ethtxmanager.go b/ethtxmanager/ethtxmanager.go index d5afcf6..5ba6b79 100644 --- a/ethtxmanager/ethtxmanager.go +++ b/ethtxmanager/ethtxmanager.go @@ -44,10 +44,11 @@ type Client struct { ctx context.Context cancel context.CancelFunc - cfg Config - etherman ethermanInterface - storage storageInterface - from common.Address + cfg Config + etherman ethermanInterface + storage storageInterface + from common.Address + nonceMutex sync.Mutex } type pending struct { @@ -154,6 +155,8 @@ func pendingL1Txs(URL string, from common.Address, httpHeaders map[string]string // getTxNonce get the nonce for the given account func (c *Client) getTxNonce(ctx context.Context, from common.Address) (uint64, error) { + c.nonceMutex.Lock() + defer c.nonceMutex.Unlock() // Get created transactions from the database for the given account createdTxs, err := c.storage.GetByStatus(ctx, []MonitoredTxStatus{MonitoredTxStatusCreated}) if err != nil {