e3: apply inline-retry (#6336)

This commit is contained in:
Alex Sharov 2022-12-16 14:14:00 +07:00 committed by GitHub
parent 43f83cd7d8
commit d95f0ca51e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -70,11 +70,17 @@ func NewWorker(lock sync.Locker, ctx context.Context, background bool, chainDb k
starkNetEvm: &vm.CVMAdapter{Cvm: vm.NewCVM(nil)},
evm: vm.NewEVM(evmtypes.BlockContext{}, evmtypes.TxContext{}, nil, chainConfig, vm.Config{}),
}
w.getHeader = func(hash common.Hash, number uint64) *types.Header {
h, err := blockReader.Header(ctx, w.chainTx, hash, number)
if err != nil {
panic(err)
}
return h
}
w.ibs = state.New(w.stateReader)
w.posa, w.isPoSA = engine.(consensus.PoSA)
return w
}
@ -186,7 +192,12 @@ func (rw *Worker) RunTxTask(txTask *exec22.TxTask) {
rw.starkNetEvm.Reset(evmtypes.TxContext{}, ibs)
vmenv = rw.starkNetEvm
} else {
rw.evm.ResetBetweenBlocks(txTask.EvmBlockContext, core.NewEVMTxContext(msg), ibs, vmConfig, txTask.Rules)
blockContext := txTask.EvmBlockContext
if !rw.background {
getHashFn := core.GetHashFn(header, rw.getHeader)
blockContext = core.NewEVMBlockContext(header, getHashFn, rw.engine, nil /* author */)
}
rw.evm.ResetBetweenBlocks(blockContext, core.NewEVMTxContext(msg), ibs, vmConfig, txTask.Rules)
vmenv = rw.evm
}
applyRes, err := core.ApplyMessage(vmenv, msg, gp, true /* refunds */, false /* gasBailout */)

View File

@ -717,10 +717,15 @@ func processResultQueue(rws *exec22.TxTaskQueue, outputTxNum *atomic2.Uint64, rs
txTask = heap.Pop(rws).(*exec22.TxTask)
resultsSize.Add(-txTask.ResultsSize)
if txTask.Error != nil || !rs.ReadsValid(txTask.ReadLists) {
rs.AddWork(txTask)
repeatCount.Inc()
continue
//fmt.Printf("Rolled back %d block %d txIndex %d\n", txTask.TxNum, txTask.BlockNum, txTask.TxIndex)
// immediately retry once
applyWorker.RunTxTask(txTask)
if txTask.Error != nil {
//log.Info("second fail", "blk", txTask.BlockNum, "txn", txTask.BlockNum)
rs.AddWork(txTask)
continue
}
}
if err := rs.ApplyState(applyTx, txTask, agg); err != nil {