Skip to content

Commit

Permalink
bugfix: if we reach genesis, return the genesis as common
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers authored and jdowning100 committed Oct 11, 2024
1 parent b8f265a commit 33a2315
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ func FindCommonAncestor(db ethdb.Reader, a, b *types.WorkObject, nodeCtx int) (*
for bn := b.NumberU64(nodeCtx); a.NumberU64(nodeCtx) > bn; {
a = ReadHeader(db, a.NumberU64(nodeCtx)-1, a.ParentHash(nodeCtx))
if IsGenesisHash(db, a.ParentHash(nodeCtx)) {
return nil, fmt.Errorf("no common ancestor found")
return a, nil
}
if a == nil {
return nil, fmt.Errorf("unable to find hash %s", a.ParentHash(nodeCtx).String())
Expand All @@ -760,7 +760,7 @@ func FindCommonAncestor(db ethdb.Reader, a, b *types.WorkObject, nodeCtx int) (*
for an := a.NumberU64(nodeCtx); an < b.NumberU64(nodeCtx); {
b = ReadHeader(db, b.NumberU64(nodeCtx)-1, b.ParentHash(nodeCtx))
if IsGenesisHash(db, b.ParentHash(nodeCtx)) {
return nil, fmt.Errorf("no common ancestor found")
return b, nil
}
if b == nil {
return nil, fmt.Errorf("unable to find hash %s", b.ParentHash(nodeCtx).String())
Expand Down

0 comments on commit 33a2315

Please sign in to comment.