miner: avoid data race in miner (#24349)

This commit is contained in:
rjl493456442 2022-02-08 01:34:13 +08:00 committed by GitHub
parent 6ce4670bc0
commit 2d20fed893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1134,6 +1134,9 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti
if interval != nil { if interval != nil {
interval() interval()
} }
// Create a local environment copy, avoid the data race with snapshot state.
// https://github.com/ethereum/go-ethereum/issues/24299
env := env.copy()
block, err := w.engine.FinalizeAndAssemble(w.chain, env.header, env.state, env.txs, env.unclelist(), env.receipts) block, err := w.engine.FinalizeAndAssemble(w.chain, env.header, env.state, env.txs, env.unclelist(), env.receipts)
if err != nil { if err != nil {
return err return err