Skip to content

Commit

Permalink
pevm: fix some bad check & support to fallback to serial processor;
Browse files Browse the repository at this point in the history
  • Loading branch information
galaio committed Aug 27, 2024
1 parent 5bbd82b commit 8bcaeec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
// Process block using the parent state as reference point
pstart = time.Now()
receipts, logs, usedGas, err = bc.processor.Process(block, statedb, bc.vmConfig)
if err == FallbackToSerialProcessorErr {
bc.UseSerialProcessor()
receipts, logs, usedGas, err = bc.processor.Process(block, statedb, bc.vmConfig)
}
if err != nil {
bc.reportBlock(block, receipts, err)
followupInterrupt.Store(true)
Expand Down
14 changes: 8 additions & 6 deletions core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const (
stage2AheadNum = 3 // enter ConfirmStage2 in advance to avoid waiting for Fat Tx
)

var (
FallbackToSerialProcessorErr = errors.New("fallback to serial processor")
)

type ParallelStateProcessor struct {
StateProcessor
parallelNum int // leave a CPU to dispatcher
Expand Down Expand Up @@ -571,11 +575,6 @@ func (p *ParallelStateProcessor) runQuickMergeSlotLoop(slotIndex int, slotType i
if txReq.txIndex <= int(p.mergedTxIndex.Load()) {
continue
}

if txReq.txIndex != next {
log.Warn("query next txReq wrong", "slot", slotIndex, "next", next, "actual", txReq.txIndex)
break
}
if !atomic.CompareAndSwapInt32(&txReq.runnable, 1, 0) {
continue
}
Expand Down Expand Up @@ -782,7 +781,6 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
if p.bc.txDAGReader != nil {
// load cache txDAG from file first
txDAG = p.bc.txDAGReader.TxDAG(block.NumberU64())

} else {
// load TxDAG from block
txDAG, err = types.GetTxDAG(block)
Expand All @@ -797,6 +795,10 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
}
}

if txDAG != nil && txDAG.Type() == types.EmptyTxDAGType {
return nil, nil, 0, FallbackToSerialProcessorErr
}

txNum := len(allTxs)
latestExcludedTx := -1
// Iterate over and process the individual transactions
Expand Down

0 comments on commit 8bcaeec

Please sign in to comment.