Skip to content

Commit

Permalink
blockchain.go: Updated the skipBlock piece with requisite changes fro…
Browse files Browse the repository at this point in the history
…m geth
  • Loading branch information
shreekarashastry committed Jul 28, 2022
1 parent 2161577 commit a79d80f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
13 changes: 3 additions & 10 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2021,11 +2021,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool, setHead
fmt.Println("skip block")
reorg, err = bc.forker.ReorgNeeded(current.Header(), block.Header())
if err != nil {
fmt.Println("skipblock future blcok catch", err)
if errors.Is(err, consensus.ErrFutureBlock) {
fmt.Println("skipblock inside if", err)
break
}
return it.index, err
}
if reorg {
Expand Down Expand Up @@ -2086,7 +2081,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool, setHead
return it.index, nil

// Some other error occurred, abort
case err != nil:
case err != nil && !errors.Is(err, ErrKnownBlock):
bc.futureBlocks.Remove(block.Hash())
stats.ignored += len(it.chain)
bc.reportBlock(block, nil, err)
Expand All @@ -2105,7 +2100,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool, setHead
}
}()

for ; block != nil && err == nil || err == ErrKnownBlock; block, err = it.next() {
for ; block != nil && err == nil || errors.Is(err, ErrKnownBlock); block, err = it.next() {
// If the chain is terminating, stop processing blocks
if bc.insertStopped() {
log.Debug("Abort during block processing")
Expand All @@ -2121,7 +2116,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool, setHead
// older block might complete the state of the subsequent one. In this case,
// just skip the block (we already validated it once fully (and crashed), since
// its header and body was already in the database).
if err == ErrKnownBlock {
if bc.skipBlock(err, it) {
logger := log.Debug
if bc.chainConfig.Clique == nil {
logger = log.Warn
Expand Down Expand Up @@ -2160,9 +2155,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool, setHead

parent := it.previous()
if parent == nil {
fmt.Println("parent is nil for block ", block, block.ParentHash())
parentBlock := bc.GetBlockByHash(block.ParentHash())

if parentBlock == nil {
return it.index, errors.New("parent is nil")
}
Expand Down
16 changes: 8 additions & 8 deletions core/forkchoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, header *types.Header) (b
}
}

if reorg && types.QuaiNetworkContext != params.PRIME {
domReorg, err := f.chain.DomReorgNeeded(header)
fmt.Println("domReorg", err)
if err != nil {
return false, err
}
reorg = domReorg
}
// if reorg && types.QuaiNetworkContext != params.PRIME {
// domReorg, err := f.chain.DomReorgNeeded(header)
// fmt.Println("domReorg", err)
// if err != nil {
// return false, err
// }
// reorg = domReorg
// }

return reorg, nil
}
Expand Down

0 comments on commit a79d80f

Please sign in to comment.