From 4b6f6ffe2389cc2a62a10e9e8014101e3b0a595b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 29 Apr 2020 18:00:29 +0300 Subject: [PATCH] core/state/snapshot: fix journal nil deserialziation --- core/state/snapshot/journal.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/state/snapshot/journal.go b/core/state/snapshot/journal.go index 66c7aee0ac..0e73454168 100644 --- a/core/state/snapshot/journal.go +++ b/core/state/snapshot/journal.go @@ -158,7 +158,11 @@ func loadDiffLayer(parent snapshot, r *rlp.Stream) (snapshot, error) { } accountData := make(map[common.Hash][]byte) for _, entry := range accounts { - accountData[entry.Hash] = entry.Blob + if len(entry.Blob) > 0 { // RLP loses nil-ness, but `[]byte{}` is not a valid item, so reinterpret that + accountData[entry.Hash] = entry.Blob + } else { + accountData[entry.Hash] = nil + } } var storage []journalStorage if err := r.Decode(&storage); err != nil { @@ -168,7 +172,11 @@ func loadDiffLayer(parent snapshot, r *rlp.Stream) (snapshot, error) { for _, entry := range storage { slots := make(map[common.Hash][]byte) for i, key := range entry.Keys { - slots[key] = entry.Vals[i] + if len(entry.Vals[i]) > 0 { // RLP loses nil-ness, but `[]byte{}` is not a valid item, so reinterpret that + slots[key] = entry.Vals[i] + } else { + slots[key] = nil + } } storageData[entry.Hash] = slots }