Re-execute parallel tasks when there is a read in coinbase or burn address

This commit is contained in:
Jerry 2022-07-27 19:35:23 +00:00
parent 61accb021a
commit ab3ebebcca
2 changed files with 34 additions and 11 deletions

View file

@ -55,17 +55,18 @@ type ExecutionTask struct {
msg types.Message
config *params.ChainConfig
gasLimit uint64
blockNumber *big.Int
blockHash common.Hash
blockContext vm.BlockContext
tx *types.Transaction
index int
statedb *state.StateDB // State database that stores the modified values after tx execution.
cleanStateDB *state.StateDB // A clean copy of the initial statedb. It should not be modified.
evmConfig vm.Config
result *ExecutionResult
shouldDelayFeeCal *bool
gasLimit uint64
blockNumber *big.Int
blockHash common.Hash
blockContext vm.BlockContext
tx *types.Transaction
index int
statedb *state.StateDB // State database that stores the modified values after tx execution.
cleanStateDB *state.StateDB // A clean copy of the initial statedb. It should not be modified.
evmConfig vm.Config
result *ExecutionResult
shouldDelayFeeCal *bool
shouldRerunWithoutFeeDelay bool
}
func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (err error) {
@ -94,6 +95,14 @@ func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (er
// Apply the transaction to the current state (included in the env).
if *task.shouldDelayFeeCal {
task.result, err = ApplyMessageNoFeeBurnOrTip(evm, task.msg, new(GasPool).AddGas(task.gasLimit))
if _, ok := task.statedb.MVReadMap()[string(task.blockContext.Coinbase.Bytes())]; ok {
task.shouldRerunWithoutFeeDelay = true
}
if _, ok := task.statedb.MVReadMap()[string(task.result.BurntContractAddress.Bytes())]; ok {
task.shouldRerunWithoutFeeDelay = true
}
} else {
task.result, err = ApplyMessage(evm, task.msg, new(GasPool).AddGas(task.gasLimit))
}
@ -180,6 +189,16 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
_, err := blockstm.ExecuteParallel(tasks)
for _, task := range tasks {
task := task.(*ExecutionTask)
if task.shouldRerunWithoutFeeDelay {
shouldDelayFeeCal = false
_, err = blockstm.ExecuteParallel(tasks)
break
}
}
if err != nil {
log.Error("blockstm error executing block", "err", err)
return nil, nil, 0, err

View file

@ -201,6 +201,10 @@ func (s *StateDB) MVFullWriteList() []blockstm.WriteDescriptor {
return writes
}
func (s *StateDB) MVReadMap() map[string]blockstm.ReadDescriptor {
return s.readMap
}
func (s *StateDB) MVReadList() []blockstm.ReadDescriptor {
reads := make([]blockstm.ReadDescriptor, 0, len(s.readMap))