From d0860229c2fd718aa4767dce3ba7baa02684c527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Wed, 5 Jun 2024 17:55:05 +0300 Subject: [PATCH] fix: avoid accidentally sharing a tracer between goroutines (#768) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid accidentally sharing a tracer between goroutines Co-authored-by: Péter Garamvölgyi --- miner/scroll_worker.go | 2 +- rollup/pipeline/pipeline.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 69508ddd1d..b815b33562 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -521,7 +521,7 @@ func (w *worker) startNewPipeline(timestamp int64) { if !w.isRunning() { pipelineCCC = nil } - w.currentPipeline = pipeline.NewPipeline(w.chain, w.chain.GetVMConfig(), parentState, header, nextL1MsgIndex, pipelineCCC).WithBeforeTxHook(w.beforeTxHook) + w.currentPipeline = pipeline.NewPipeline(w.chain, *w.chain.GetVMConfig(), parentState, header, nextL1MsgIndex, pipelineCCC).WithBeforeTxHook(w.beforeTxHook) deadline := time.Unix(int64(header.Time), 0) if w.chainConfig.Clique != nil && w.chainConfig.Clique.RelaxedPeriod { diff --git a/rollup/pipeline/pipeline.go b/rollup/pipeline/pipeline.go index 0802e73ff4..c3c7b996fe 100644 --- a/rollup/pipeline/pipeline.go +++ b/rollup/pipeline/pipeline.go @@ -47,7 +47,7 @@ var ( type Pipeline struct { chain *core.BlockChain - vmConfig *vm.Config + vmConfig vm.Config parent *types.Block start time.Time @@ -73,13 +73,16 @@ type Pipeline struct { func NewPipeline( chain *core.BlockChain, - vmConfig *vm.Config, + vmConfig vm.Config, state *state.StateDB, header *types.Header, nextL1MsgIndex uint64, ccc *circuitcapacitychecker.CircuitCapacityChecker, ) *Pipeline { + // make sure we are not sharing a tracer with the caller and not in debug mode + vmConfig.Tracer = nil + vmConfig.Debug = false return &Pipeline{ chain: chain, vmConfig: vmConfig, @@ -417,7 +420,7 @@ func (p *Pipeline) traceAndApply(tx *types.Transaction) (*types.Receipt, *types. var receipt *types.Receipt receipt, err = core.ApplyTransaction(p.chain.Config(), p.chain, nil /* coinbase will default to chainConfig.Scroll.FeeVaultAddress */, p.gasPool, - p.state, &p.Header, tx, &p.Header.GasUsed, *p.vmConfig) + p.state, &p.Header, tx, &p.Header.GasUsed, p.vmConfig) if err != nil { p.state.RevertToSnapshot(snap) return nil, trace, err