Revert "cmd/geth: make chain database should open ancient or not"

This reverts commit e445ec6937077f0f79f91f37a016b59f4d712c0f.

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-09-26 07:51:27 +08:00
parent 047c4774fe
commit ccbe041f99
3 changed files with 28 additions and 27 deletions

View file

@ -108,7 +108,7 @@ a data corruption.`,
utils.CacheFlag, utils.CacheFlag,
utils.CacheDatabaseFlag, utils.CacheDatabaseFlag,
}, utils.NetworkFlags, utils.DatabaseFlags), }, utils.NetworkFlags, utils.DatabaseFlags),
Description: `This command performs a database compaction. Description: `This command performs a database compaction.
WARNING: This operation may take a very long time to finish, and may cause database WARNING: This operation may take a very long time to finish, and may cause database
corruption if it is aborted during execution'!`, corruption if it is aborted during execution'!`,
} }
@ -130,7 +130,7 @@ corruption if it is aborted during execution'!`,
Flags: flags.Merge([]cli.Flag{ Flags: flags.Merge([]cli.Flag{
utils.SyncModeFlag, utils.SyncModeFlag,
}, utils.NetworkFlags, utils.DatabaseFlags), }, utils.NetworkFlags, utils.DatabaseFlags),
Description: `This command deletes the specified database key from the database. Description: `This command deletes the specified database key from the database.
WARNING: This is a low-level operation which may cause database corruption!`, WARNING: This is a low-level operation which may cause database corruption!`,
} }
dbPutCmd = &cli.Command{ dbPutCmd = &cli.Command{
@ -141,7 +141,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Flags: flags.Merge([]cli.Flag{ Flags: flags.Merge([]cli.Flag{
utils.SyncModeFlag, utils.SyncModeFlag,
}, utils.NetworkFlags, utils.DatabaseFlags), }, utils.NetworkFlags, utils.DatabaseFlags),
Description: `This command sets a given database key to the given value. Description: `This command sets a given database key to the given value.
WARNING: This is a low-level operation which may cause database corruption!`, WARNING: This is a low-level operation which may cause database corruption!`,
} }
dbGetSlotsCmd = &cli.Command{ dbGetSlotsCmd = &cli.Command{
@ -280,7 +280,7 @@ func inspect(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, true, false) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
return rawdb.InspectDatabase(db, prefix, start) return rawdb.InspectDatabase(db, prefix, start)
@ -304,7 +304,7 @@ func checkStateContent(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, true, true) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
var ( var (
it = rawdb.NewKeyLengthIterator(db.NewIterator(prefix, start), 32) it = rawdb.NewKeyLengthIterator(db.NewIterator(prefix, start), 32)
@ -357,7 +357,7 @@ func dbStats(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, true, true) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
showLeveldbStats(db) showLeveldbStats(db)
@ -368,7 +368,7 @@ func dbCompact(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, false, true) db := utils.MakeChainDatabase(ctx, stack, false)
defer db.Close() defer db.Close()
log.Info("Stats before compaction") log.Info("Stats before compaction")
@ -392,7 +392,7 @@ func dbGet(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, true, true) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
key, err := common.ParseHexOrString(ctx.Args().Get(0)) key, err := common.ParseHexOrString(ctx.Args().Get(0))
@ -418,7 +418,7 @@ func dbDelete(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, false, true) db := utils.MakeChainDatabase(ctx, stack, false)
defer db.Close() defer db.Close()
key, err := common.ParseHexOrString(ctx.Args().Get(0)) key, err := common.ParseHexOrString(ctx.Args().Get(0))
@ -445,7 +445,7 @@ func dbPut(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, false, true) db := utils.MakeChainDatabase(ctx, stack, false)
defer db.Close() defer db.Close()
var ( var (
@ -479,7 +479,7 @@ func dbDumpTrie(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, true, true) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
triedb := utils.MakeTrieDatabase(ctx, db, false, true) triedb := utils.MakeTrieDatabase(ctx, db, false, true)
@ -593,7 +593,7 @@ func importLDBdata(ctx *cli.Context) error {
} }
close(stop) close(stop)
}() }()
db := utils.MakeChainDatabase(ctx, stack, false, true) db := utils.MakeChainDatabase(ctx, stack, false)
defer db.Close() defer db.Close()
return utils.ImportLDBData(db, fName, int64(start), stop) return utils.ImportLDBData(db, fName, int64(start), stop)
} }
@ -690,7 +690,7 @@ func exportChaindata(ctx *cli.Context) error {
} }
close(stop) close(stop)
}() }()
db := utils.MakeChainDatabase(ctx, stack, true, true) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
return utils.ExportChaindata(ctx.Args().Get(1), kind, exporter(db), stop) return utils.ExportChaindata(ctx.Args().Get(1), kind, exporter(db), stop)
} }
@ -698,8 +698,9 @@ func exportChaindata(ctx *cli.Context) error {
func showMetaData(ctx *cli.Context) error { func showMetaData(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, true, false) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
ancients, err := db.Ancients() ancients, err := db.Ancients()
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Error accessing ancients: %v", err) fmt.Fprintf(os.Stderr, "Error accessing ancients: %v", err)

View file

@ -84,8 +84,8 @@ In other words, this command does the snapshot to trie conversion.
Action: checkDanglingStorage, Action: checkDanglingStorage,
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags), Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
Description: ` Description: `
geth snapshot check-dangling-storage <state-root> traverses the snap storage geth snapshot check-dangling-storage <state-root> traverses the snap storage
data, and verifies that all snapshot storage data has a corresponding account. data, and verifies that all snapshot storage data has a corresponding account.
`, `,
}, },
{ {
@ -96,7 +96,7 @@ data, and verifies that all snapshot storage data has a corresponding account.
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags), Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
Description: ` Description: `
geth snapshot inspect-account <address | hash> checks all snapshot layers and prints out geth snapshot inspect-account <address | hash> checks all snapshot layers and prints out
information about the specified address. information about the specified address.
`, `,
}, },
{ {
@ -125,7 +125,7 @@ geth snapshot traverse-rawstate <state-root>
will traverse the whole state from the given root and will abort if any referenced will traverse the whole state from the given root and will abort if any referenced
trie node or contract code is missing. This command can be used for state integrity trie node or contract code is missing. This command can be used for state integrity
verification. The default checking target is the HEAD state. It's basically identical verification. The default checking target is the HEAD state. It's basically identical
to traverse-state, but the check granularity is smaller. to traverse-state, but the check granularity is smaller.
It's also usable without snapshot enabled. It's also usable without snapshot enabled.
`, `,
@ -143,7 +143,7 @@ It's also usable without snapshot enabled.
}, utils.NetworkFlags, utils.DatabaseFlags), }, utils.NetworkFlags, utils.DatabaseFlags),
Description: ` Description: `
This command is semantically equivalent to 'geth dump', but uses the snapshots This command is semantically equivalent to 'geth dump', but uses the snapshots
as the backend data source, making this command a lot faster. as the backend data source, making this command a lot faster.
The argument is interpreted as block number or hash. If none is provided, the latest The argument is interpreted as block number or hash. If none is provided, the latest
block is used. block is used.
@ -159,7 +159,7 @@ func pruneState(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
chaindb := utils.MakeChainDatabase(ctx, stack, false, true) chaindb := utils.MakeChainDatabase(ctx, stack, false)
defer chaindb.Close() defer chaindb.Close()
if rawdb.ReadStateScheme(chaindb) != rawdb.HashScheme { if rawdb.ReadStateScheme(chaindb) != rawdb.HashScheme {
@ -197,7 +197,7 @@ func verifyState(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
chaindb := utils.MakeChainDatabase(ctx, stack, true, true) chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close() defer chaindb.Close()
headBlock := rawdb.ReadHeadBlock(chaindb) headBlock := rawdb.ReadHeadBlock(chaindb)
@ -245,7 +245,7 @@ func checkDanglingStorage(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
db := utils.MakeChainDatabase(ctx, stack, true, true) db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close() defer db.Close()
return snapshot.CheckDanglingStorage(db) return snapshot.CheckDanglingStorage(db)
} }
@ -257,7 +257,7 @@ func traverseState(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
chaindb := utils.MakeChainDatabase(ctx, stack, true, true) chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close() defer chaindb.Close()
triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true) triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true)
@ -366,7 +366,7 @@ func traverseRawState(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
chaindb := utils.MakeChainDatabase(ctx, stack, true, true) chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close() defer chaindb.Close()
triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true) triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true)
@ -625,7 +625,7 @@ func checkAccount(ctx *cli.Context) error {
} }
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
chaindb := utils.MakeChainDatabase(ctx, stack, true, true) chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close() defer chaindb.Close()
start := time.Now() start := time.Now()
log.Info("Checking difflayer journal", "address", addr, "hash", hash) log.Info("Checking difflayer journal", "address", addr, "hash", hash)

View file

@ -114,7 +114,7 @@ func verifyVerkle(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
chaindb := utils.MakeChainDatabase(ctx, stack, true, false) chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close() defer chaindb.Close()
headBlock := rawdb.ReadHeadBlock(chaindb) headBlock := rawdb.ReadHeadBlock(chaindb)
if headBlock == nil { if headBlock == nil {
@ -163,7 +163,7 @@ func expandVerkle(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx) stack, _ := makeConfigNode(ctx)
defer stack.Close() defer stack.Close()
chaindb := utils.MakeChainDatabase(ctx, stack, true, true) chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close() defer chaindb.Close()
var ( var (
rootC common.Hash rootC common.Hash