Skip to content

Commit

Permalink
cmd/geth: exit when freezer has legacy receipts (#24943)
Browse files Browse the repository at this point in the history
In #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.
  • Loading branch information
s1na committed May 26, 2022
1 parent d575a2d commit 0559a9a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/geth/config.go
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 @@ -176,7 +176,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
if err != nil {
log.Error("Failed to check db for legacy receipts", "err", err)
} else if isLegacy {
log.Warn("Database has receipts with a legacy format. Please run `geth db freezer-migrate`.")
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
Expand Up @@ -151,6 +151,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
Expand Up @@ -227,6 +227,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
Expand Up @@ -566,6 +566,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

1 comment on commit 0559a9a

@Nooknick7899
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ประโยชน์ _ GpoMaxGasPriceFlag ,
ประโยชน์ _ GpoIgnoreGasPriceFlag ,
ประโยชน์ _ MinerNotifyFullFlag ,
ประโยชน์ _ ละเว้นLegacyReceiptsFlag ,
configFileFlag ,
}, utils . NetworkFlags , utils . DatabasePathFlags )

Please sign in to comment.