From 609c97369bf69bd4da4db58321f2000539a72da7 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:52:45 +0100 Subject: [PATCH] fix: support a verkle pre-tree at the conversion block (#313) * fix: support a verkle pre-tree at the conversion block * make linter happy --- consensus/beacon/consensus.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index ef483c8d328e..35a7ed2b56d0 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -418,7 +418,14 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea vtrpost = post.Overlay() okpost = true default: - panic("invalid tree type") + // This should only happen for the first block of the + // conversion, when the previous tree is a merkle tree. + // Logically, the "previous" verkle tree is an empty tree. + okpre = true + vtrpre = trie.NewVerkleTrie(verkle.New(), state.Database().TrieDB(), utils.NewPointCache(), false) + post := state.GetTrie().(*trie.TransitionTrie) + vtrpost = post.Overlay() + okpost = true } if okpre && okpost { if len(keys) > 0 {