From cd0ddad4bba2e0d1a7451343ed18661fc563b2c8 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:15:46 +0100 Subject: [PATCH 1/2] fix: support a verkle pre-tree at the conversion block --- consensus/beacon/consensus.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 2ca701c42f56..390e56013cbb 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -423,7 +423,15 @@ 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 { From cc61f5c3f92472bbb2479d3c5129f6b1a18f3e01 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:49:51 +0100 Subject: [PATCH 2/2] make linter happy --- consensus/beacon/consensus.go | 1 - 1 file changed, 1 deletion(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 390e56013cbb..c2181fca9bda 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -431,7 +431,6 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea post := state.GetTrie().(*trie.TransitionTrie) vtrpost = post.Overlay() okpost = true - } if okpre && okpost { if len(keys) > 0 {