Skip to content

Commit 0559a9a

Browse files
authoredMay 26, 2022
cmd/geth: exit when freezer has legacy receipts (ethereum#24943)
In ethereum#24028 we flagged a warning when finding legacy receipts in the freezer. This PR nudges users a bit more strongly by preventing geth from starting in this case until receipts have been migrated. It also adds a flag --ignore-legacy-receipts which when present allows geth to start normally.

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed
 

‎cmd/geth/config.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
164164
}
165165
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
166166
// Warn users to migrate if they have a legacy freezer format.
167-
if eth != nil {
167+
if eth != nil && !ctx.GlobalIsSet(utils.IgnoreLegacyReceiptsFlag.Name) {
168168
firstIdx := uint64(0)
169169
// Hack to speed up check for mainnet because we know
170170
// the first non-empty block.
@@ -176,7 +176,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
176176
if err != nil {
177177
log.Error("Failed to check db for legacy receipts", "err", err)
178178
} else if isLegacy {
179-
log.Warn("Database has receipts with a legacy format. Please run `geth db freezer-migrate`.")
179+
stack.Close()
180+
utils.Fatalf("Database has receipts with a legacy format. Please run `geth db freezer-migrate`.")
180181
}
181182
}
182183

‎cmd/geth/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ var (
151151
utils.GpoMaxGasPriceFlag,
152152
utils.GpoIgnoreGasPriceFlag,
153153
utils.MinerNotifyFullFlag,
154+
utils.IgnoreLegacyReceiptsFlag,
154155
configFileFlag,
155156
}, utils.NetworkFlags, utils.DatabasePathFlags)
156157

‎cmd/geth/usage.go

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
227227
Flags: []cli.Flag{
228228
utils.SnapshotFlag,
229229
utils.BloomFilterSizeFlag,
230+
utils.IgnoreLegacyReceiptsFlag,
230231
cli.HelpFlag,
231232
},
232233
},

‎cmd/utils/flags.go

+4
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@ var (
566566
Name: "nocompaction",
567567
Usage: "Disables db compaction after import",
568568
}
569+
IgnoreLegacyReceiptsFlag = cli.BoolFlag{
570+
Name: "ignore-legacy-receipts",
571+
Usage: "Geth will start up even if there are legacy receipts in freezer",
572+
}
569573
// RPC settings
570574
IPCDisabledFlag = cli.BoolFlag{
571575
Name: "ipcdisable",

0 commit comments

Comments
 (0)
Please sign in to comment.