From 319a9054f742273ef3aa01cd2a510e5a3eb8caab Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Tue, 28 Apr 2026 17:26:14 +0200 Subject: [PATCH] use a constant for the default value --- core/bintrie_witness_test.go | 4 ++-- core/genesis_test.go | 2 +- eth/ethconfig/config.go | 3 ++- triedb/database.go | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/bintrie_witness_test.go b/core/bintrie_witness_test.go index 1a20063b5a..66feef0675 100644 --- a/core/bintrie_witness_test.go +++ b/core/bintrie_witness_test.go @@ -92,7 +92,7 @@ func TestProcessUBT(t *testing.T) { // genesis := gspec.MustCommit(bcdb, triedb) options := DefaultConfig().WithStateScheme(rawdb.PathScheme) options.SnapshotLimit = 0 - options.BinTrieGroupDepth = 8 + options.BinTrieGroupDepth = triedb.DefaultBinTrieGroupDepth blockchain, _ := NewBlockChain(bcdb, gspec, beacon.New(ethash.NewFaker()), options) defer blockchain.Stop() @@ -219,7 +219,7 @@ func TestProcessParentBlockHash(t *testing.T) { t.Run("UBT", func(t *testing.T) { db := rawdb.NewMemoryDatabase() cacheConfig := DefaultConfig().WithStateScheme(rawdb.PathScheme) - cacheConfig.BinTrieGroupDepth = 8 + cacheConfig.BinTrieGroupDepth = triedb.DefaultBinTrieGroupDepth cacheConfig.SnapshotLimit = 0 triedb := triedb.NewDatabase(db, cacheConfig.triedbConfig(true)) statedb, _ := state.New(types.EmptyBinaryHash, state.NewDatabase(triedb, nil)) diff --git a/core/genesis_test.go b/core/genesis_test.go index da4ccd7111..94f1b3a4fd 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -322,7 +322,7 @@ func TestBinaryGenesisCommit(t *testing.T) { triedb := triedb.NewDatabase(db, &triedb.Config{ IsUBT: true, PathDB: &config, - BinTrieGroupDepth: 8, + BinTrieGroupDepth: triedb.DefaultBinTrieGroupDepth, }) block := genesis.MustCommit(db, triedb) if !bytes.Equal(block.Root().Bytes(), expected) { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 4518ec52b1..b51b78e199 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -35,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/pathdb" ) @@ -59,7 +60,7 @@ var Defaults = Config{ StateHistory: pathdb.Defaults.StateHistory, TrienodeHistory: pathdb.Defaults.TrienodeHistory, NodeFullValueCheckpoint: pathdb.Defaults.FullValueCheckpoint, - BinTrieGroupDepth: 8, // byte-aligned groups by default + BinTrieGroupDepth: triedb.DefaultBinTrieGroupDepth, DatabaseCache: 2048, TrieCleanCache: 614, TrieDirtyCache: 1024, diff --git a/triedb/database.go b/triedb/database.go index 3cc7dea5d7..0fd3e1aa91 100644 --- a/triedb/database.go +++ b/triedb/database.go @@ -38,6 +38,8 @@ type Config struct { PathDB *pathdb.Config // Configs for experimental path-based scheme } +const DefaultBinTrieGroupDepth = 5 + // HashDefaults represents a config for using hash-based scheme with // default settings. var HashDefaults = &Config{ @@ -51,7 +53,7 @@ var HashDefaults = &Config{ var UBTDefaults = &Config{ Preimages: false, IsUBT: true, - BinTrieGroupDepth: 8, // Default to byte-aligned groups + BinTrieGroupDepth: DefaultBinTrieGroupDepth, PathDB: pathdb.Defaults, }