From 3f3e8f753e06c5cc93844ae9d9afc4f213842267 Mon Sep 17 00:00:00 2001 From: perror <23651751+perrornet@users.noreply.github.com> Date: Sat, 15 Jun 2024 15:34:55 +0800 Subject: [PATCH] Add mutex for safe global operations --- utils/wallets/safe/utils.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/wallets/safe/utils.go b/utils/wallets/safe/utils.go index c2bf19a..48c4ec7 100644 --- a/utils/wallets/safe/utils.go +++ b/utils/wallets/safe/utils.go @@ -26,6 +26,7 @@ import ( "omni-balance/utils/safe_api/client/transactions" "omni-balance/utils/wallets/safe/safe_abi" "strings" + "sync" "time" ) @@ -44,6 +45,7 @@ var ( constant.Zksync: "safe-transaction-zkevm.safe.global", constant.Sepolia: "safe-transaction-sepolia.safe.global", } + safeGlobalLocker sync.Mutex ) type SafeResp struct { @@ -206,6 +208,8 @@ func (s *Safe) nonce(ctx context.Context) (int64, error) { } func (s *Safe) proposeTransaction(ctx context.Context, tx *types.LegacyTx) (common.Hash, error) { + safeGlobalLocker.Lock() + defer safeGlobalLocker.Unlock() nonce, err := s.nonce(ctx) if err != nil { return common.Hash{}, errors.Wrap(err, "get nonce error")