Skip to content

Commit

Permalink
fix: pbss snapshot inconsistent status fix
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr committed Sep 27, 2024
1 parent 651bba6 commit 581ea90
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,24 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
// if there is no available state, waiting for state sync.
head := bc.CurrentBlock()

//fix pbss snapshot if needed
// Fix pbss snapshot if needed
if bc.triedb.Scheme() == rawdb.PathScheme {
log.Info("pbss snapshot validation")
log.Debug("pbss snapshot validation")
currentSafe := bc.CurrentSafeBlock()
currentFinalize := bc.CurrentFinalBlock()

// Check if either safe or finalized block is ahead of the head block
if currentSafe.Number.Uint64() > head.Number.Uint64() || currentFinalize.Number.Uint64() > head.Number.Uint64() {
log.Info("current unsafe is behind safe, reset")
bc.hc.SetHead(head.Number.Uint64(), nil, createDelFn(bc))
//想办法
bc.SetSafe(head)
bc.SetFinalized(head)

// Update the safe and finalized block conditionally
if currentSafe.Number.Uint64() > head.Number.Uint64() {
bc.SetSafe(head)
}
if currentFinalize.Number.Uint64() > head.Number.Uint64() {
bc.SetFinalized(head)
}
}
}

Expand Down

0 comments on commit 581ea90

Please sign in to comment.