From 0353423a51bb4ae509bef778f1212f17c352f172 Mon Sep 17 00:00:00 2001 From: Roshan Date: Tue, 2 Apr 2024 15:53:42 +0800 Subject: [PATCH] fix: concurrent map write issue --- miner/worker_builder.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/miner/worker_builder.go b/miner/worker_builder.go index bb4c32e7d1..f6feabfd9f 100644 --- a/miner/worker_builder.go +++ b/miner/worker_builder.go @@ -284,6 +284,7 @@ func (w *worker) simulateBundles(env *environment, bundles []*types.Bundle) ([]* simResult := make(map[common.Hash]*types.SimulatedBundle) var wg sync.WaitGroup + var mu sync.Mutex for i, bundle := range bundles { if simmed, ok := simCache.GetSimulatedBundle(bundle.Hash()); ok { simResult[bundle.Hash()] = simmed @@ -301,6 +302,8 @@ func (w *worker) simulateBundles(env *environment, bundles []*types.Bundle) ([]* return } + mu.Lock() + defer mu.Unlock() simResult[bundle.Hash()] = simmed }(i, bundle, env.state.Copy()) }