Skip to content

Commit

Permalink
consensus/parlia: modify the offset
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 committed Aug 7, 2024
1 parent 49abffd commit 16f28bd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
// If we're at the genesis, snapshot the initial state. Alternatively if we have
// piled up more headers than allowed to be reorged (chain reinit from a freezer),
// consider the checkpoint trusted and snapshot it.
// even BEP-341 enabled, an offset `p.config.Epoch/2` can ensure getting the right validators.
if number == 0 || (number%p.config.Epoch == p.config.Epoch/2 && (len(headers) > int(params.FullImmutabilityThreshold))) {
// An offset `p.config.Epoch - 1` can ensure getting the right validators.
if number == 0 || ((number+1)%p.config.Epoch == 0 && (len(headers) > int(params.FullImmutabilityThreshold))) {
var (
checkpoint *types.Header
blockHash common.Hash
Expand All @@ -754,7 +754,7 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
blockHash = checkpoint.Hash()
}
} else {
checkpoint = chain.GetHeaderByNumber(number - p.config.Epoch/2)
checkpoint = chain.GetHeaderByNumber(number + 1 - p.config.Epoch)
blockHeader := chain.GetHeaderByNumber(number)
if blockHeader != nil {
blockHash = blockHeader.Hash()
Expand Down

0 comments on commit 16f28bd

Please sign in to comment.