mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 14:33:52 +00:00
Re-execute parallel tasks when there is a read in coinbase or burn address
This commit is contained in:
parent
61accb021a
commit
ab3ebebcca
2 changed files with 34 additions and 11 deletions
|
|
@ -55,17 +55,18 @@ type ExecutionTask struct {
|
||||||
msg types.Message
|
msg types.Message
|
||||||
config *params.ChainConfig
|
config *params.ChainConfig
|
||||||
|
|
||||||
gasLimit uint64
|
gasLimit uint64
|
||||||
blockNumber *big.Int
|
blockNumber *big.Int
|
||||||
blockHash common.Hash
|
blockHash common.Hash
|
||||||
blockContext vm.BlockContext
|
blockContext vm.BlockContext
|
||||||
tx *types.Transaction
|
tx *types.Transaction
|
||||||
index int
|
index int
|
||||||
statedb *state.StateDB // State database that stores the modified values after tx execution.
|
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.
|
cleanStateDB *state.StateDB // A clean copy of the initial statedb. It should not be modified.
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -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))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue