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

@ -66,6 +66,7 @@ type ExecutionTask struct {
evmConfig vm.Config evmConfig vm.Config
result *ExecutionResult result *ExecutionResult
shouldDelayFeeCal *bool shouldDelayFeeCal *bool
shouldRerunWithoutFeeDelay bool
} }
func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (err error) { 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). // Apply the transaction to the current state (included in the env).
if *task.shouldDelayFeeCal { if *task.shouldDelayFeeCal {
task.result, err = ApplyMessageNoFeeBurnOrTip(evm, task.msg, new(GasPool).AddGas(task.gasLimit)) 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 { } else {
task.result, err = ApplyMessage(evm, task.msg, new(GasPool).AddGas(task.gasLimit)) 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) _, err := blockstm.ExecuteParallel(tasks)
for _, task := range tasks {
task := task.(*ExecutionTask)
if task.shouldRerunWithoutFeeDelay {
shouldDelayFeeCal = false
_, err = blockstm.ExecuteParallel(tasks)
break
}
}
if err != nil { if err != nil {
log.Error("blockstm error executing block", "err", err) log.Error("blockstm error executing block", "err", err)
return nil, nil, 0, err return nil, nil, 0, err

View file

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