@@ -27,6 +27,7 @@ import (
2727 "github.com/ethereum/go-ethereum/core/types"
2828 "github.com/ethereum/go-ethereum/params"
2929 "github.com/ethereum/go-ethereum/trie"
30+ "github.com/ethereum/go-ethereum/trie/utils"
3031 "github.com/ethereum/go-verkle"
3132)
3233
@@ -152,7 +153,20 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
152153 return fmt .Errorf ("invalid merkle root (remote: %x local: %x) dberr: %w" , header .Root , root , statedb .Error ())
153154 }
154155 if blockEw := block .ExecutionWitness (); blockEw != nil {
155- err := trie .AddPostValuesToProof (statedb .GetTrie ().(* trie.VerkleTrie ), proof )
156+ tr := statedb .GetTrie ()
157+ var vtr * trie.VerkleTrie
158+ switch pre := tr .(type ) {
159+ case * trie.VerkleTrie :
160+ vtr = pre
161+ case * trie.TransitionTrie :
162+ vtr = pre .Overlay ()
163+ default :
164+ // This should only happen for the first block of the
165+ // conversion, when the previous tree is a merkle tree.
166+ // Logically, the "previous" verkle tree is an empty tree.
167+ vtr = trie .NewVerkleTrie (verkle .New (), statedb .Database ().TrieDB (), utils .NewPointCache (), false )
168+ }
169+ err := trie .AddPostValuesToProof (vtr , proof )
156170 if err != nil {
157171 return fmt .Errorf ("error adding post values to proof: %w" , err )
158172 }
0 commit comments