From d2edbac21ec563acc70714ef854645a304c7b95a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CGheisMohammadi=E2=80=9D?= <36589218+GheisMohammadi@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:46:31 +0800 Subject: [PATCH] add support for validator code prefix in snapshot --- core/state/snapshot/conversion.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/state/snapshot/conversion.go b/core/state/snapshot/conversion.go index fd4216737..032d9189a 100644 --- a/core/state/snapshot/conversion.go +++ b/core/state/snapshot/conversion.go @@ -78,9 +78,15 @@ func GenerateTrie(snaptree *Tree, root common.Hash, src ethdb.Database, dst ethd if codeHash != types.EmptyCodeHash { code := rawdb.ReadCode(src, codeHash) if len(code) == 0 { - return common.Hash{}, errors.New("failed to read code") + code = rawdb.ReadValidatorCode(src, codeHash) + if len(code) == 0 { + return common.Hash{}, errors.New("failed to read code") + } else { + rawdb.WriteValidatorCode(dst, codeHash, code) + } + } else { + rawdb.WriteCode(dst, codeHash, code) } - rawdb.WriteCode(dst, codeHash, code) } // Then migrate all storage trie nodes into the tmp db. storageIt, err := snaptree.StorageIterator(root, accountHash, common.Hash{})