Skip to content

Commit

Permalink
Merge pull request #82 from junnmm/upstream-issue-25498-fix
Browse files Browse the repository at this point in the history
cmd/geth: fix legacy receipt detection for empty db (ethereum#25609)
  • Loading branch information
viaweb3 authored Feb 24, 2023
2 parents ca6b43f + c976608 commit b95df24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,13 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
if cfg.Eth.NetworkId == 1 && ghash == params.MainnetGenesisHash {
firstIdx = 46147
}
isLegacy, _, err := dbHasLegacyReceipts(eth.ChainDb(), firstIdx)
isLegacy, firstLegacy, err := dbHasLegacyReceipts(eth.ChainDb(), firstIdx)
if err != nil {
log.Error("Failed to check db for legacy receipts", "err", err)
} else if isLegacy {
stack.Close()
utils.Fatalf("Database has receipts with a legacy format. Please run `geth db freezer-migrate`.")
log.Error("Database has receipts with a legacy format", "firstLegacy", firstLegacy)
utils.Fatalf("Aborting. Please run `geth db freezer-migrate`.")
}
}

Expand Down
6 changes: 5 additions & 1 deletion cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,15 @@ func dbHasLegacyReceipts(db ethdb.Database, firstIdx uint64) (bool, uint64, erro
}
}
}
// Is first non-empty receipt legacy?
first, err := db.Ancient("receipts", firstIdx)
if err != nil {
return false, 0, err
}
// We looped over all receipts and they were all empty
if bytes.Equal(first, emptyRLPList) {
return false, 0, nil
}
// Is first non-empty receipt legacy?
legacy, err = types.IsLegacyStoredReceipts(first)
return legacy, firstIdx, err
}

0 comments on commit b95df24

Please sign in to comment.