Skip to content

Commit

Permalink
test: fix pathdb unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Sep 11, 2024
1 parent cd3f27d commit ae5f144
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
3 changes: 0 additions & 3 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ func initGenesis(ctx *cli.Context) error {
defer chaindb.Close()

triedb := utils.MakeTrieDatabase(ctx, stack, chaindb, ctx.Bool(utils.CachePreimagesFlag.Name), false, genesis.IsVerkle())
if triedb.Config().PathDB != nil {
triedb.Config().PathDB.UseBase = true
}
defer triedb.Close()

_, hash, err := core.SetupGenesisBlockWithOverride(chaindb, triedb, genesis, &overrides)
Expand Down
4 changes: 0 additions & 4 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,8 @@ func flushAlloc(ga *types.GenesisAlloc, db ethdb.Database, triedb *triedb.Databa
if err != nil {
return err
}
log.Info("m2mdf223")
// Commit newly generated states into disk if it's not empty.
if root != types.EmptyRootHash {
log.Info("flushAlloc", "use base", triedb.Config().PathDB.UseBase)
if err := triedb.Commit(root, true); err != nil {
return err
}
Expand Down Expand Up @@ -319,7 +317,6 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
} else {
log.Info("Writing custom genesis block")
}
log.Info("23n8923u8u23r3", "db use base", triedb.Config().PathDB.UseBase)
applyOverrides(genesis.Config)
block, err := genesis.Commit(db, triedb)
if err != nil {
Expand Down Expand Up @@ -549,7 +546,6 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *triedb.Database) (*types.Blo
// All the checks has passed, flushAlloc the states derived from the genesis
// specification as well as the specification itself into the provided
// database.
log.Info("before flush", "use base", triedb.Config().PathDB.UseBase)
if err := flushAlloc(&g.Alloc, db, triedb, block.Hash()); err != nil {
return nil, err
}
Expand Down
8 changes: 6 additions & 2 deletions triedb/pathdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"sync"
"time"

Expand Down Expand Up @@ -181,10 +182,14 @@ func New(diskdb ethdb.Database, config *Config) *Database {
useBase: config.UseBase,
}

log.Info("d2nid23nf390293", "db use base", db.useBase, "config use base", 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))
db.fastRecovery = checkAncientAndNodeBuffer(ancient, config.TrieNodeBufferType)
freezer, err := rawdb.NewStateFreezer(ancient, false, db.fastRecovery)
if err != nil {
Expand Down Expand Up @@ -299,7 +304,6 @@ func (db *Database) Commit(root common.Hash, report bool) error {
defer db.lock.Unlock()
defer db.capLock.Unlock()

log.Info("pathdb commit", "use base", db.useBase)
// Short circuit if the mutation is not allowed.
if err := db.modifyAllowed(); err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func newNodeBufferList(
keepFunc: keepFunc,
}
nf.useBase.Store(useBase)
log.Info("23hd312hnud91e9dnm", "nf use base", useBase, "load", nf.useBase.Load())
}

go nf.loop()
Expand Down Expand Up @@ -446,7 +445,6 @@ func (nf *nodebufferlist) flush(db ethdb.KeyValueStore, clean *fastcache.Cache,
nf.forceKeepCh <- struct{}{}
<-nf.waitForceKeepCh

log.Info("23nu2fnuef2ju", "use base", nf.useBase.Load())
// hang user read/write and background write
nf.mux.Lock()
nf.baseMux.Lock()
Expand Down

0 comments on commit ae5f144

Please sign in to comment.