From 5860b8e89cdc8b4ef0a539a8925f8609af006754 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 18 Apr 2023 15:17:48 -0700 Subject: [PATCH] Create new block context for each parallel task --- core/parallel_state_processor.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index 456f97d691..805a89646d 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -88,8 +88,7 @@ type ExecutionTask struct { // next k elements in dependencies -> transaction indexes on which transaction i is dependent on dependencies []int - blockContext vm.BlockContext - coinbase common.Address + coinbase common.Address } func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (err error) { @@ -98,7 +97,9 @@ func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (er task.statedb.SetMVHashmap(mvh) task.statedb.SetIncarnation(incarnation) - evm := vm.NewEVM(task.blockContext, vm.TxContext{}, task.statedb, task.config, task.evmConfig) + blockContext := NewEVMBlockContext(task.header, task.blockChain, nil) + + evm := vm.NewEVM(blockContext, vm.TxContext{}, task.statedb, task.config, task.evmConfig) // Create a new context to be used in the EVM environment. txContext := NewEVMTxContext(task.msg) @@ -125,8 +126,8 @@ func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (er reads := task.statedb.MVReadMap() - if _, ok := reads[blockstm.NewSubpathKey(task.blockContext.Coinbase, state.BalancePath)]; ok { - log.Info("Coinbase is in MVReadMap", "address", task.blockContext.Coinbase) + if _, ok := reads[blockstm.NewSubpathKey(blockContext.Coinbase, state.BalancePath)]; ok { + log.Info("Coinbase is in MVReadMap", "address", blockContext.Coinbase) task.shouldRerunWithoutFeeDelay = true } @@ -304,8 +305,6 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat metadata = true } - blockContext := NewEVMBlockContext(header, p.bc, nil) - // Iterate over and process the individual transactions for i, tx := range block.Transactions() { msg, err := tx.AsMessage(types.MakeSigner(p.config, header.Number), header.BaseFee) @@ -340,8 +339,6 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat receipts: &receipts, allLogs: &allLogs, dependencies: deps[i], - blockContext: blockContext, - coinbase: coinbase, } tasks = append(tasks, task) @@ -365,7 +362,6 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat receipts: &receipts, allLogs: &allLogs, dependencies: nil, - blockContext: blockContext, coinbase: coinbase, } @@ -419,7 +415,10 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat } if err != nil { - log.Error("blockstm error executing block", "err", err) + if err != context.Canceled { + log.Error("blockstm error executing block", "err", err) + } + return nil, nil, 0, err }