diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 980c7011b01c..6d2bb2bcb622 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -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. @@ -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`.") } } diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 493d7265b518..fd6a6fe091aa 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -153,6 +153,7 @@ var ( utils.GpoMaxGasPriceFlag, utils.GpoIgnoreGasPriceFlag, utils.MinerNotifyFullFlag, + utils.IgnoreLegacyReceiptsFlag, configFileFlag, }, utils.NetworkFlags, utils.DatabasePathFlags) diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index f01321afc98b..ee830f0c4471 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -228,6 +228,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ Flags: []cli.Flag{ utils.SnapshotFlag, utils.BloomFilterSizeFlag, + utils.IgnoreLegacyReceiptsFlag, cli.HelpFlag, }, }, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ce854fd4fd70..671de9a8d8d3 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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",