[download.v2] Prevent deadlock by starting txPool early (#1860)

* Prevent deadlock by starting txPool early

* Reduce error levels in the logs

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
ledgerwatch 2021-05-02 12:15:53 +01:00 committed by GitHub
parent 4432618cb9
commit 39d3314b99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -440,6 +440,7 @@ func New(stack *node.Node, config *ethconfig.Config, gitCommit string) (*Ethereu
eth.txPoolServer.TxFetcher = fetcher.NewTxFetcher(eth.txPool.Has, eth.txPool.AddRemotes, fetchTx)
eth.txPoolServer.TxFetcher.Start()
eth.txPool.Start(0, 0) // Start tx pool to avoid deadlocks in the initial stages (before TxPool stage starts working)
bodyDownloadTimeoutSeconds := 30 // TODO: convert to duration, make configurable
eth.stagedSync2, err = download.NewStagedSync(

View File

@ -416,7 +416,7 @@ func InitPreverifiedHashes(chain *big.Int) (map[common.Hash]struct{}, uint64) {
encodings = ropstenPreverifiedHashes
height = ropstenPreverifiedHeight
default:
log.Error("Preverified hashes not found for", "chain", chain)
log.Warn("Preverified hashes not found for", "chain", chain)
return nil, 0
}
return DecodeHashes(encodings), height
@ -548,7 +548,7 @@ func (hd *HeaderDownload) InsertHeaders(hf func(header *types.Header, blockHeigh
}
if !link.preverified {
if err := hd.engine.VerifyHeader(hd.headerReader, link.header, true /* seal */); err != nil {
log.Error("Verification failed for header", "hash", link.header.Hash(), "height", link.blockHeight, "error", err)
log.Warn("Verification failed for header", "hash", link.header.Hash(), "height", link.blockHeight, "error", err)
// skip this link and its children
continue
}
@ -649,7 +649,7 @@ func (hi *HeaderInserter) FeedHeader(header *types.Header, blockHeight uint64) e
// Load parent header
parent := rawdb.ReadHeader(hi.batch, header.ParentHash, blockHeight-1)
if parent == nil {
log.Error(fmt.Sprintf("Could not find parent with hash %x and height %d for header %x %d", header.ParentHash, blockHeight-1, hash, blockHeight))
log.Warn(fmt.Sprintf("Could not find parent with hash %x and height %d for header %x %d", header.ParentHash, blockHeight-1, hash, blockHeight))
// Skip headers without parents
return nil
}
@ -760,14 +760,14 @@ func (hd *HeaderDownload) ProcessSegment(segment *ChainSegment, newBlock bool) (
if foundTip {
// Connect
if err := hd.connect(segment, start, end); err != nil {
log.Error("Connect failed", "error", err)
log.Debug("Connect failed", "error", err)
return
}
log.Debug("Connected", "start", startNum, "end", endNum)
} else {
// ExtendDown
if err := hd.extendDown(segment, start, end); err != nil {
log.Error("ExtendDown failed", "error", err)
log.Debug("ExtendDown failed", "error", err)
return
}
requestMore = true
@ -777,7 +777,7 @@ func (hd *HeaderDownload) ProcessSegment(segment *ChainSegment, newBlock bool) (
if end > 0 {
// ExtendUp
if err := hd.extendUp(segment, start, end); err != nil {
log.Error("ExtendUp failed", "error", err)
log.Debug("ExtendUp failed", "error", err)
return
}
log.Debug("Extended Up", "start", startNum, "end", endNum)
@ -785,7 +785,7 @@ func (hd *HeaderDownload) ProcessSegment(segment *ChainSegment, newBlock bool) (
} else {
// NewAnchor
if err := hd.newAnchor(segment, start, end); err != nil {
log.Error("NewAnchor failed", "error", err)
log.Debug("NewAnchor failed", "error", err)
return
}
requestMore = true