From f4b1790d3bb0dce80feefae4a2fc41ffe4c9adad Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Wed, 22 Apr 2026 17:19:28 +0200 Subject: [PATCH] fix build --- cmd/geth/bintrie_convert.go | 4 ++-- core/blockchain.go | 2 +- core/state/database_ubt.go | 2 +- core/state/reader.go | 2 +- trie/bintrie/trie.go | 4 ++++ triedb/database.go | 8 ++++---- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/geth/bintrie_convert.go b/cmd/geth/bintrie_convert.go index 43d2e629ac..46cb3aa7e4 100644 --- a/cmd/geth/bintrie_convert.go +++ b/cmd/geth/bintrie_convert.go @@ -151,7 +151,7 @@ func convertToBinaryTrie(ctx *cli.Context) error { }) defer destTriedb.Close() - binTrie, err := bintrie.NewBinaryTrie(types.EmptyBinaryHash, destTriedb) + binTrie, err := bintrie.NewBinaryTrie(types.EmptyBinaryHash, destTriedb, ctx.Int(utils.BinTrieGroupDepthFlag.Name)) if err != nil { return fmt.Errorf("failed to create binary trie: %w", err) } @@ -319,7 +319,7 @@ func commitBinaryTrie(bt *bintrie.BinaryTrie, currentRoot common.Hash, destDB *t runtime.GC() debug.FreeOSMemory() - bt, err := bintrie.NewBinaryTrie(newRoot, destDB) + bt, err := bintrie.NewBinaryTrie(newRoot, destDB, bt.GroupDepth()) if err != nil { return nil, common.Hash{}, fmt.Errorf("failed to reload binary trie: %w", err) } diff --git a/core/blockchain.go b/core/blockchain.go index dbb48ca2e4..e4421b0b95 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -262,7 +262,7 @@ func (cfg BlockChainConfig) WithNoAsyncFlush(on bool) *BlockChainConfig { func (cfg *BlockChainConfig) triedbConfig(isVerkle bool) *triedb.Config { config := &triedb.Config{ Preimages: cfg.Preimages, - IsVerkle: isVerkle, + IsUBT: isVerkle, BinTrieGroupDepth: cfg.BinTrieGroupDepth, } if cfg.StateScheme == rawdb.HashScheme { diff --git a/core/state/database_ubt.go b/core/state/database_ubt.go index 718d93df87..6bf7a07317 100644 --- a/core/state/database_ubt.go +++ b/core/state/database_ubt.go @@ -96,7 +96,7 @@ func (db *UBTDatabase) ReadersWithCacheStats(stateRoot common.Hash) (Reader, Rea // OpenTrie opens the main account trie at a specific root hash. func (db *UBTDatabase) OpenTrie(root common.Hash) (Trie, error) { - return bintrie.NewBinaryTrie(root, db.triedb) + return bintrie.NewBinaryTrie(root, db.triedb, db.triedb.Config.BinTrieGroupDepth) } // OpenStorageTrie opens the storage trie of an account. In binary trie mode, diff --git a/core/state/reader.go b/core/state/reader.go index 5df0acbb9b..0aabff8d69 100644 --- a/core/state/reader.go +++ b/core/state/reader.go @@ -255,7 +255,7 @@ type ubtTrieReader struct { // newUBTTrieReader constructs a Unified-binary-trie reader of the specific state. // An error will be returned if the associated trie specified by root is not existent. func newUBTTrieReader(root common.Hash, db *triedb.Database) (*ubtTrieReader, error) { - binTrie, binErr := bintrie.NewBinaryTrie(root, db) + binTrie, binErr := bintrie.NewBinaryTrie(root, db, db.Config.BinTrieGroupDepth) if binErr != nil { return nil, binErr } diff --git a/trie/bintrie/trie.go b/trie/bintrie/trie.go index 6b41b04cee..5a255ec126 100644 --- a/trie/bintrie/trie.go +++ b/trie/bintrie/trie.go @@ -113,6 +113,10 @@ type BinaryTrie struct { groupDepth int // Number of levels per serialized group (1-8, default 8) } +func (t *BinaryTrie) GroupDepth() int { + return t.groupDepth +} + // ToDot converts the binary trie to a DOT language representation. Useful for debugging. func (t *BinaryTrie) ToDot() string { t.store.computeHash(t.store.root) diff --git a/triedb/database.go b/triedb/database.go index ea41a48736..b7ebb6acb3 100644 --- a/triedb/database.go +++ b/triedb/database.go @@ -86,7 +86,7 @@ type backend interface { // relevant with trie nodes and node preimages. type Database struct { disk ethdb.Database - config *Config // Configuration for trie database + Config *Config // Configuration for trie database preimages *preimageStore // The store for caching preimages backend backend // The backend for managing trie nodes } @@ -104,7 +104,7 @@ func NewDatabase(diskdb ethdb.Database, config *Config) *Database { } db := &Database{ disk: diskdb, - config: config, + Config: config, preimages: preimages, } if config.HashDB != nil && config.PathDB != nil { @@ -196,7 +196,7 @@ func (db *Database) Size() (common.StorageSize, common.StorageSize, common.Stora // Scheme returns the node scheme used in the database. func (db *Database) Scheme() string { - if db.config.PathDB != nil { + if db.Config.PathDB != nil { return rawdb.PathScheme } return rawdb.HashScheme @@ -379,7 +379,7 @@ func (db *Database) IndexProgress() (uint64, uint64, error) { // IsUBT returns the indicator if the database is holding a verkle tree. func (db *Database) IsUBT() bool { - return db.config.IsUBT + return db.Config.IsUBT } // Disk returns the underlying disk database.