From 6a2fe45dc44b80b1af803d9ab5a1df9c2ed219d0 Mon Sep 17 00:00:00 2001 From: gop Date: Mon, 2 Oct 2023 19:22:50 -0500 Subject: [PATCH] bugfix: add to append queue if not append the parent block in service blocks --- core/core.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/core.go b/core/core.go index 0ef6637c1d..d2bda6d157 100644 --- a/core/core.go +++ b/core/core.go @@ -232,22 +232,23 @@ func (c *Core) serviceBlocks(hashNumberList []types.HashAndNumber) { c.appendQueue.Add(block.Hash(), numberAndRetryCounter) } } - parentHeader := c.sl.hc.GetHeaderOrCandidate(block.ParentHash(), block.NumberU64()-1) - if parentHeader != nil { + parentBlock := c.sl.hc.GetBlockOrCandidate(block.ParentHash(), block.NumberU64()-1) + if parentBlock != nil { // If parent header is dom, send a signal to dom to request for the block if it doesnt have it - _, parentHeaderOrder, err := c.sl.engine.CalcOrder(parentHeader) + _, parentHeaderOrder, err := c.sl.engine.CalcOrder(parentBlock.Header()) if err != nil { - log.Warn("Error calculating the parent block order in serviceBlocks", "Hash", parentHeader.Hash(), "Number", parentHeader.NumberArray()) + log.Warn("Error calculating the parent block order in serviceBlocks", "Hash", parentBlock.Hash(), "Number", parentBlock.Header().NumberArray()) continue } nodeCtx := common.NodeLocation.Context() - if parentHeaderOrder < nodeCtx && c.GetHeaderByHash(parentHeader.Hash()) == nil { - log.Info("Requesting the dom to get the block if it doesnt have and try to append", "Hash", parentHeader.Hash(), "Order", parentHeaderOrder) + if parentHeaderOrder < nodeCtx && c.GetHeaderByHash(parentBlock.Hash()) == nil { + log.Info("Requesting the dom to get the block if it doesnt have and try to append", "Hash", parentBlock.Hash(), "Order", parentHeaderOrder) if c.sl.domClient != nil { // send a signal to the required dom to fetch the block if it doesnt have it, or its not in its appendqueue - go c.sl.domClient.RequestDomToAppendOrFetch(context.Background(), parentHeader.Hash(), parentHeader.ParentEntropy(), parentHeaderOrder) + go c.sl.domClient.RequestDomToAppendOrFetch(context.Background(), parentBlock.Hash(), parentBlock.ParentEntropy(), parentHeaderOrder) } } + c.addToQueueIfNotAppended(parentBlock) c.InsertChain([]*types.Block{block}) } else { c.sl.missingBlockFeed.Send(types.BlockRequest{Hash: block.ParentHash(), Entropy: block.ParentEntropy()})