diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 7421b21622..3377dfe0f9 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -227,7 +227,7 @@ func initGenesis(ctx *cli.Context) error { } defer chaindb.Close() - triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, ctx.Bool(utils.CachePreimagesFlag.Name), false, genesis.IsVerkle()) + triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, ctx.Bool(utils.CachePreimagesFlag.Name), false, genesis.IsVerkle(), true) defer triedb.Close() _, hash, err := core.SetupGenesisBlockWithOverride(chaindb, triedb, genesis, &overrides) @@ -582,7 +582,7 @@ func dump(ctx *cli.Context) error { if err != nil { return err } - triedb := utils.MakeTrieDatabase(ctx, stack, db, true, true, false) // always enable preimage lookup + triedb := utils.MakeTrieDatabase(ctx, stack, db, true, true, false, false) // always enable preimage lookup defer triedb.Close() state, err := state.New(root, state.NewDatabaseWithNodeDB(db, triedb), nil) diff --git a/cmd/geth/dbcmd.go b/cmd/geth/dbcmd.go index c0746f8963..1bc8e71c8b 100644 --- a/cmd/geth/dbcmd.go +++ b/cmd/geth/dbcmd.go @@ -797,7 +797,7 @@ func dbDumpTrie(ctx *cli.Context) error { db := utils.MakeChainDatabase(ctx, stack, true) defer db.Close() - triedb := utils.MakeTrieDatabase(ctx, stack, db, false, true, false) + triedb := utils.MakeTrieDatabase(ctx, stack, db, false, true, false, false) defer triedb.Close() var ( diff --git a/cmd/geth/snapshot.go b/cmd/geth/snapshot.go index daacdf7721..35dd711ade 100644 --- a/cmd/geth/snapshot.go +++ b/cmd/geth/snapshot.go @@ -244,7 +244,7 @@ func verifyState(ctx *cli.Context) error { log.Error("Failed to load head block") return errors.New("no head block") } - triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false) + triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false, false) defer triedb.Close() snapConfig := snapshot.Config{ @@ -299,7 +299,7 @@ func traverseState(ctx *cli.Context) error { chaindb := utils.MakeChainDatabase(ctx, stack, true) defer chaindb.Close() - triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false) + triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false, false) defer triedb.Close() headBlock := rawdb.ReadHeadBlock(chaindb) @@ -408,7 +408,7 @@ func traverseRawState(ctx *cli.Context) error { chaindb := utils.MakeChainDatabase(ctx, stack, true) defer chaindb.Close() - triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false) + triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false, false) defer triedb.Close() headBlock := rawdb.ReadHeadBlock(chaindb) @@ -573,7 +573,7 @@ func dumpState(ctx *cli.Context) error { return err } defer db.Close() - triedb := utils.MakeTrieDatabase(ctx, stack, db, false, true, false) + triedb := utils.MakeTrieDatabase(ctx, stack, db, false, true, false, false) defer triedb.Close() snapConfig := snapshot.Config{ @@ -655,7 +655,7 @@ func snapshotExportPreimages(ctx *cli.Context) error { chaindb := utils.MakeChainDatabase(ctx, stack, true) defer chaindb.Close() - triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false) + triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, false, true, false, false) defer triedb.Close() var root common.Hash diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index e9d52c972b..4870f58d27 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -2508,7 +2508,8 @@ func MakeConsolePreloads(ctx *cli.Context) []string { } // MakeTrieDatabase constructs a trie database based on the configured scheme. -func MakeTrieDatabase(ctx *cli.Context, stack *node.Node, disk ethdb.Database, preimage bool, readOnly bool, isVerkle bool) *triedb.Database { +func MakeTrieDatabase(ctx *cli.Context, stack *node.Node, disk ethdb.Database, preimage bool, readOnly bool, isVerkle bool, + useBase bool) *triedb.Database { config := &triedb.Config{ Preimages: preimage, IsVerkle: isVerkle, @@ -2529,6 +2530,7 @@ func MakeTrieDatabase(ctx *cli.Context, stack *node.Node, disk ethdb.Database, p } else { config.PathDB = pathdb.Defaults } + config.PathDB.UseBase = useBase config.PathDB.JournalFilePath = fmt.Sprintf("%s/%s", stack.ResolvePath("chaindata"), eth.JournalFileName) return triedb.NewDatabase(disk, config) } diff --git a/triedb/pathdb/database.go b/triedb/pathdb/database.go index 032f0c5872..9010e21036 100644 --- a/triedb/pathdb/database.go +++ b/triedb/pathdb/database.go @@ -21,7 +21,6 @@ import ( "fmt" "io" "os" - "path/filepath" "sync" "time" @@ -182,14 +181,13 @@ func New(diskdb ethdb.Database, config *Config) *Database { useBase: config.UseBase, } - if db.useBase { - - } - // Open the freezer for state history if the passed database contains an // ancient store. Otherwise, all the relevant functionalities are disabled. if ancient, err := diskdb.AncientDatadir(); err == nil && ancient != "" && !db.readOnly { - db.useBase = !common.FileExist(filepath.Join(ancient, rawdb.StateFreezerName)) + // fmt.Println("je238e8238", db.useBase) + // fmt.Println("2132132", ancient) + // db.useBase = !common.FileExist(filepath.Join(ancient, rawdb.StateFreezerName)) + // fmt.Println("uuuu", db.useBase) db.fastRecovery = checkAncientAndNodeBuffer(ancient, config.TrieNodeBufferType) freezer, err := rawdb.NewStateFreezer(ancient, false, db.fastRecovery) if err != nil {