fix: avoid accidentally sharing a tracer between goroutines (#768)

Avoid accidentally sharing a tracer between goroutines

Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
Ömer Faruk Irmak 2024-06-05 17:55:05 +03:00 committed by GitHub
parent 6229ef11da
commit d0860229c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View file

@ -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 {

View file

@ -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