trie/pathdb: decode verkle node in loadLayer

This commit is contained in:
Guillaume Ballet 2024-12-06 21:16:08 +01:00
parent 08e6bdb550
commit 65255f1651

View file

@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-verkle"
) )
var ( var (
@ -95,8 +96,16 @@ func (db *Database) loadLayers() layer {
// Retrieve the root node of persistent state. // Retrieve the root node of persistent state.
var root = types.EmptyRootHash var root = types.EmptyRootHash
if blob := rawdb.ReadAccountTrieNode(db.diskdb, nil); len(blob) > 0 { if blob := rawdb.ReadAccountTrieNode(db.diskdb, nil); len(blob) > 0 {
if db.isVerkle {
rootnode, err := verkle.ParseNode(blob, 0)
if err != nil {
log.Crit("Could not decode verkle root node")
}
root = rootnode.Commit().Bytes()
} else {
root = crypto.Keccak256Hash(blob) root = crypto.Keccak256Hash(blob)
} }
}
// Load the layers by resolving the journal // Load the layers by resolving the journal
head, err := db.loadJournal(root) head, err := db.loadJournal(root)
if err == nil { if err == nil {