From 886fe1ab0376a7f9b2f4b0ef0682aed59f660fca Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Fri, 7 Jun 2024 12:17:42 -0700 Subject: [PATCH] trie: panic if BatchSerialize returns an error in Verkle trie Commit --- trie/verkle.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/trie/verkle.go b/trie/verkle.go index bc0c223d15..aefffce33c 100644 --- a/trie/verkle.go +++ b/trie/verkle.go @@ -219,7 +219,12 @@ func (t *VerkleTrie) Hash() common.Hash { // Commit writes all nodes to the tree's memory database. func (t *VerkleTrie) Commit(_ bool) (common.Hash, *trienode.NodeSet) { root := t.root.(*verkle.InternalNode) - nodes, _ := root.BatchSerialize() + nodes, err := root.BatchSerialize() + if err != nil { + // error return from this function indicates error in the code logic + // of BatchSerialize, and we fail catastrophically if this is the case. + panic(fmt.Errorf("BatchSerialize failed: %v", err)) + } nodeset := trienode.NewNodeSet(common.Hash{}) for _, node := range nodes { // hash parameter is not used in pathdb