Skip to content

Commit

Permalink
cmd/geth: exit when freezer has legacy receipts (ethereum#24943)
Browse files Browse the repository at this point in the history
  • Loading branch information
s1na authored and jagdeep sidhu committed May 31, 2022
1 parent a1aa2e1 commit b2d1a9e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
}
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
// Warn users to migrate if they have a legacy freezer format.
if eth != nil {
if eth != nil && !ctx.GlobalIsSet(utils.IgnoreLegacyReceiptsFlag.Name) {
firstIdx := uint64(0)
// Hack to speed up check for mainnet because we know
// the first non-empty block.
Expand All @@ -174,10 +174,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
}
isLegacy, _, err := dbHasLegacyReceipts(eth.ChainDb(), firstIdx)
if err != nil {
utils.Fatalf("Failed to check db for legacy receipts: %v", err)
}
if isLegacy {
log.Warn("Database has receipts with a legacy format. Please run `geth db freezer-migrate`.")
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`.")
}
}

Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ var (
utils.GpoMaxGasPriceFlag,
utils.GpoIgnoreGasPriceFlag,
utils.MinerNotifyFullFlag,
utils.IgnoreLegacyReceiptsFlag,
configFileFlag,
}, utils.NetworkFlags, utils.DatabasePathFlags)

Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
Flags: []cli.Flag{
utils.SnapshotFlag,
utils.BloomFilterSizeFlag,
utils.IgnoreLegacyReceiptsFlag,
cli.HelpFlag,
},
},
Expand Down
4 changes: 4 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ var (
Name: "nocompaction",
Usage: "Disables db compaction after import",
}
IgnoreLegacyReceiptsFlag = cli.BoolFlag{
Name: "ignore-legacy-receipts",
Usage: "Geth will start up even if there are legacy receipts in freezer",
}
// RPC settings
IPCDisabledFlag = cli.BoolFlag{
Name: "ipcdisable",
Expand Down

0 comments on commit b2d1a9e

Please sign in to comment.