fix build

This commit is contained in:
Guillaume Ballet 2026-04-22 17:19:28 +02:00
parent 9b9143b14b
commit f4b1790d3b
No known key found for this signature in database
6 changed files with 13 additions and 9 deletions

View file

@ -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)
}

View file

@ -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 {

View file

@ -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,

View file

@ -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
}

View file

@ -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)

View file

@ -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.