use a constant for the default value

This commit is contained in:
Guillaume Ballet 2026-04-28 17:26:14 +02:00
parent b7c1d9166b
commit 319a9054f7
No known key found for this signature in database
4 changed files with 8 additions and 5 deletions

View file

@ -92,7 +92,7 @@ func TestProcessUBT(t *testing.T) {
// genesis := gspec.MustCommit(bcdb, triedb) // genesis := gspec.MustCommit(bcdb, triedb)
options := DefaultConfig().WithStateScheme(rawdb.PathScheme) options := DefaultConfig().WithStateScheme(rawdb.PathScheme)
options.SnapshotLimit = 0 options.SnapshotLimit = 0
options.BinTrieGroupDepth = 8 options.BinTrieGroupDepth = triedb.DefaultBinTrieGroupDepth
blockchain, _ := NewBlockChain(bcdb, gspec, beacon.New(ethash.NewFaker()), options) blockchain, _ := NewBlockChain(bcdb, gspec, beacon.New(ethash.NewFaker()), options)
defer blockchain.Stop() defer blockchain.Stop()
@ -219,7 +219,7 @@ func TestProcessParentBlockHash(t *testing.T) {
t.Run("UBT", func(t *testing.T) { t.Run("UBT", func(t *testing.T) {
db := rawdb.NewMemoryDatabase() db := rawdb.NewMemoryDatabase()
cacheConfig := DefaultConfig().WithStateScheme(rawdb.PathScheme) cacheConfig := DefaultConfig().WithStateScheme(rawdb.PathScheme)
cacheConfig.BinTrieGroupDepth = 8 cacheConfig.BinTrieGroupDepth = triedb.DefaultBinTrieGroupDepth
cacheConfig.SnapshotLimit = 0 cacheConfig.SnapshotLimit = 0
triedb := triedb.NewDatabase(db, cacheConfig.triedbConfig(true)) triedb := triedb.NewDatabase(db, cacheConfig.triedbConfig(true))
statedb, _ := state.New(types.EmptyBinaryHash, state.NewDatabase(triedb, nil)) statedb, _ := state.New(types.EmptyBinaryHash, state.NewDatabase(triedb, nil))

View file

@ -322,7 +322,7 @@ func TestBinaryGenesisCommit(t *testing.T) {
triedb := triedb.NewDatabase(db, &triedb.Config{ triedb := triedb.NewDatabase(db, &triedb.Config{
IsUBT: true, IsUBT: true,
PathDB: &config, PathDB: &config,
BinTrieGroupDepth: 8, BinTrieGroupDepth: triedb.DefaultBinTrieGroupDepth,
}) })
block := genesis.MustCommit(db, triedb) block := genesis.MustCommit(db, triedb)
if !bytes.Equal(block.Root().Bytes(), expected) { if !bytes.Equal(block.Root().Bytes(), expected) {

View file

@ -35,6 +35,7 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/triedb"
"github.com/ethereum/go-ethereum/triedb/pathdb" "github.com/ethereum/go-ethereum/triedb/pathdb"
) )
@ -59,7 +60,7 @@ var Defaults = Config{
StateHistory: pathdb.Defaults.StateHistory, StateHistory: pathdb.Defaults.StateHistory,
TrienodeHistory: pathdb.Defaults.TrienodeHistory, TrienodeHistory: pathdb.Defaults.TrienodeHistory,
NodeFullValueCheckpoint: pathdb.Defaults.FullValueCheckpoint, NodeFullValueCheckpoint: pathdb.Defaults.FullValueCheckpoint,
BinTrieGroupDepth: 8, // byte-aligned groups by default BinTrieGroupDepth: triedb.DefaultBinTrieGroupDepth,
DatabaseCache: 2048, DatabaseCache: 2048,
TrieCleanCache: 614, TrieCleanCache: 614,
TrieDirtyCache: 1024, TrieDirtyCache: 1024,

View file

@ -38,6 +38,8 @@ type Config struct {
PathDB *pathdb.Config // Configs for experimental path-based scheme PathDB *pathdb.Config // Configs for experimental path-based scheme
} }
const DefaultBinTrieGroupDepth = 5
// HashDefaults represents a config for using hash-based scheme with // HashDefaults represents a config for using hash-based scheme with
// default settings. // default settings.
var HashDefaults = &Config{ var HashDefaults = &Config{
@ -51,7 +53,7 @@ var HashDefaults = &Config{
var UBTDefaults = &Config{ var UBTDefaults = &Config{
Preimages: false, Preimages: false,
IsUBT: true, IsUBT: true,
BinTrieGroupDepth: 8, // Default to byte-aligned groups BinTrieGroupDepth: DefaultBinTrieGroupDepth,
PathDB: pathdb.Defaults, PathDB: pathdb.Defaults,
} }