From d60aebb13192e36d975db3c119fb9af3a548ecfc Mon Sep 17 00:00:00 2001 From: StefanIliev545 Date: Mon, 20 May 2024 18:10:12 +0300 Subject: [PATCH 1/2] Use tx lock. --- go/host/l1/publisher.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go/host/l1/publisher.go b/go/host/l1/publisher.go index 2d853f66d6..57020246ef 100644 --- a/go/host/l1/publisher.go +++ b/go/host/l1/publisher.go @@ -308,6 +308,10 @@ func (p *Publisher) PublishCrossChainBundle(bundle *common.ExtCrossChainBundle) return fmt.Errorf("unable to get nonce for management contract. Cause: %w", err) } + p.logger.Info("Host preparing to send cross chain bundle transaction") + p.sendingLock.Lock() + defer p.sendingLock.Unlock() + transactor.Nonce = big.NewInt(0).SetUint64(nonce) tx, err := managementCtr.AddCrossChainMessagesRoot(transactor, [32]byte(bundle.LastBatchHash.Bytes()), bundle.L1BlockHash, bundle.L1BlockNum, bundle.CrossChainRootHashes, bundle.Signature) From ee22b6c5edc1a0c94f81c2292ddd0fa8eeecd4aa Mon Sep 17 00:00:00 2001 From: StefanIliev545 Date: Mon, 20 May 2024 18:14:02 +0300 Subject: [PATCH 2/2] ooopsie. --- go/host/l1/publisher.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/go/host/l1/publisher.go b/go/host/l1/publisher.go index 57020246ef..4c56d6761f 100644 --- a/go/host/l1/publisher.go +++ b/go/host/l1/publisher.go @@ -302,16 +302,16 @@ func (p *Publisher) PublishCrossChainBundle(bundle *common.ExtCrossChainBundle) return fmt.Errorf("unable to init") } + p.logger.Info("Host preparing to send cross chain bundle transaction") + p.sendingLock.Lock() + defer p.sendingLock.Unlock() + nonce, err := p.ethClient.EthClient().PendingNonceAt(context.Background(), p.hostWallet.Address()) if err != nil { p.logger.Error("Unable to get nonce for management contract", log.ErrKey, err) return fmt.Errorf("unable to get nonce for management contract. Cause: %w", err) } - p.logger.Info("Host preparing to send cross chain bundle transaction") - p.sendingLock.Lock() - defer p.sendingLock.Unlock() - transactor.Nonce = big.NewInt(0).SetUint64(nonce) tx, err := managementCtr.AddCrossChainMessagesRoot(transactor, [32]byte(bundle.LastBatchHash.Bytes()), bundle.L1BlockHash, bundle.L1BlockNum, bundle.CrossChainRootHashes, bundle.Signature)