Skip to content

Commit

Permalink
[R4R]fix prefetcher related bugs (#491)
Browse files Browse the repository at this point in the history
* fix goroutine leak in prefetcher

Signed-off-by: Keefe-Liu <bianze.kernel@gmail.com>

* wait all goroutine done to avoid prefetcher close panic

Signed-off-by: Keefe-Liu <bianze.kernel@gmail.com>
  • Loading branch information
keefel authored Nov 1, 2021
1 parent 98c4e81 commit 797ba71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
validateRes <- tmpFunc()
}()
}

var err error
for i := 0; i < len(validateFuns); i++ {
r := <-validateRes
if r != nil {
return r
if r != nil && err == nil {
err = r
}
}
return nil
return err
}

// CalcGasLimit computes the gas limit of the next block after parent. It aims
Expand Down
1 change: 1 addition & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
// goes into transaction receipts.
func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
if s.lightProcessed {
s.StopPrefetcher()
return s.trie.Hash()
}
// Finalise all the dirty storage states and write them into the tries
Expand Down

0 comments on commit 797ba71

Please sign in to comment.