From 57048c6a06c82918215a0b2f0fae01854d731ba0 Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Fri, 2 Sep 2022 10:13:02 +0300 Subject: [PATCH] fix statedb copy (#22) --- miner/worker.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 7c0ff5f7fdc53..3546f7c07d09e 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -973,6 +973,9 @@ func (w *worker) commitTransaction(env *environment, tx *types.Transaction) ([]* stateDB = env.state } + // It's important to copy then .Prepare() - don't reorder. + stateDB.Prepare(tx.Hash(), env.tcount) + snapshot := stateDB.Snapshot() gasPrice, err := tx.EffectiveGasTip(env.header.BaseFee) @@ -1060,8 +1063,6 @@ func (w *worker) commitBundle(env *environment, txs types.Transactions, interrup log.Trace("Ignoring reply protected transaction", "hash", tx.Hash(), "eip155", w.chainConfig.EIP155Block) return errCouldNotApplyTransaction } - // Start executing the transaction - env.state.Prepare(tx.Hash(), env.tcount) logs, err := w.commitTransaction(env, tx) switch { @@ -1384,7 +1385,6 @@ func (w *worker) fillTransactions(interrupt *int32, env *environment, validatorC } if tx != nil { log.Info("Proposer payout create tx succeeded, proceeding to commit tx") - env.state.Prepare(tx.Hash(), env.tcount) _, err = w.commitTransaction(env, tx) if err != nil { log.Error("Proposer payout commit tx failed", "hash", tx.Hash().String(), "err", err)