core/state/snapshot: fix journal nil deserialziation

parent 26d271df
...@@ -158,7 +158,11 @@ func loadDiffLayer(parent snapshot, r *rlp.Stream) (snapshot, error) { ...@@ -158,7 +158,11 @@ func loadDiffLayer(parent snapshot, r *rlp.Stream) (snapshot, error) {
} }
accountData := make(map[common.Hash][]byte) accountData := make(map[common.Hash][]byte)
for _, entry := range accounts { 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 var storage []journalStorage
if err := r.Decode(&storage); err != nil { if err := r.Decode(&storage); err != nil {
...@@ -168,7 +172,11 @@ func loadDiffLayer(parent snapshot, r *rlp.Stream) (snapshot, error) { ...@@ -168,7 +172,11 @@ func loadDiffLayer(parent snapshot, r *rlp.Stream) (snapshot, error) {
for _, entry := range storage { for _, entry := range storage {
slots := make(map[common.Hash][]byte) slots := make(map[common.Hash][]byte)
for i, key := range entry.Keys { 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 storageData[entry.Hash] = slots
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment