Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dot/babe): use bs.latestFinalised instead of using round/set id #3167

Merged
merged 6 commits into from
Mar 28, 2023
21 changes: 1 addition & 20 deletions dot/state/block_finalisation.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ func (bs *BlockState) GetFinalisedHash(round, setID uint64) (common.Hash, error)
}

func (bs *BlockState) setHighestRoundAndSetID(round, setID uint64) error {
currRound, currSetID, err := bs.GetHighestRoundAndSetID()
if err != nil {
return err
}

// higher setID takes precedence over round
if setID < currSetID || setID == currSetID && round <= currRound {
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

return bs.db.Put(highestRoundAndSetIDKey, roundAndSetIDToBytes(round, setID))
}

Expand Down Expand Up @@ -206,16 +196,7 @@ func (bs *BlockState) handleFinalisedBlock(curr common.Hash) error {
return nil
}

prev, err := bs.GetHighestFinalisedHash()
if err != nil {
return fmt.Errorf("failed to get highest finalised hash: %w", err)
}

if prev == curr {
return nil
}

subchain, err := bs.RangeInMemory(prev, curr)
subchain, err := bs.RangeInMemory(bs.lastFinalised, curr)
if err != nil {
return err
}
Expand Down