Skip to content

Commit

Permalink
Settle execution task after all tasks are completed
Browse files Browse the repository at this point in the history
This commit prevents different goroutines from reading the same statedb at the same time, resulting a concurrent read/write panic from trie tracer.
  • Loading branch information
cffls committed Sep 15, 2023
1 parent 67fc4d8 commit 397f84d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 0 additions & 10 deletions core/blockstm/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,6 @@ func (pe *ParallelExecutor) Prepare() error {
}(i)
}

pe.settleWg.Add(1)

go func() {
for t := range pe.chSettle {
pe.tasks[t].Settle()
}

pe.settleWg.Done()
}()

// bootstrap first execution
tx := pe.execTasks.takeNextPending()

Expand Down
4 changes: 4 additions & 0 deletions core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
return nil, nil, 0, err
}

for _, task := range tasks {
task.Settle()
}

// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles(), nil)

Expand Down

0 comments on commit 397f84d

Please sign in to comment.