Skip to content

Commit

Permalink
core: set path mode as default
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Feb 28, 2024
1 parent b7b64da commit f7e6956
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ var defaultCacheConfig = &CacheConfig{
SnapshotLimit: 256,
TriesInMemory: 128,
SnapshotWait: true,
StateScheme: rawdb.HashScheme,
StateScheme: rawdb.PathScheme,
}

// DefaultCacheConfigWithScheme returns a deep copied default cache config with
Expand Down Expand Up @@ -2035,7 +2035,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
go throwaway.TriePrefetchInAdvance(block, signer)
}

//Process block using the parent state as reference point
// Process block using the parent state as reference point
if bc.pipeCommit {
statedb.EnablePipeCommit()
}
Expand Down
6 changes: 4 additions & 2 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/pathdb"
)

// BlockGen creates blocks for testing.
Expand Down Expand Up @@ -339,8 +340,9 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
}
return nil, nil
}
// Forcibly use hash-based state scheme for retaining all nodes in disk.
triedb := trie.NewDatabase(db, trie.HashDefaults)

// Forcibly use path-based state scheme for retaining all nodes in disk.
triedb := trie.NewDatabase(db, &trie.Config{PathDB: pathdb.Defaults})
defer triedb.Close()

for i := 0; i < n; i++ {
Expand Down
8 changes: 4 additions & 4 deletions core/rawdb/accessors_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ func ParseStateScheme(provided string, disk ethdb.Database) (string, error) {
stored := ReadStateScheme(disk)
if provided == "" {
if stored == "" {
// use default scheme for empty database, flip it when
// path mode is chosen as default
log.Info("State scheme set to default", "scheme", "hash")
return HashScheme, nil
// use default scheme for empty database, now path mode
// is chosen as default
log.Info("State scheme set to default", "scheme", PathScheme)
return PathScheme, nil
}
log.Info("State scheme set to already existing disk db", "scheme", stored)
return stored, nil // reuse scheme of persistent scheme
Expand Down

0 comments on commit f7e6956

Please sign in to comment.