Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pevm: fix some bad check & support to fallback to serial processor; #151

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}

galaio marked this conversation as resolved.
Show resolved Hide resolved
txNum := len(allTxs)
latestExcludedTx := -1
// Iterate over and process the individual transactions
Expand Down
Loading