Skip to content

Commit a586f0d

Browse files
authored
trie/verkle: fix identification of empty account (#447)
* trie/verkle: fix identification of empty account Signed-off-by: Ignacio Hagopian <[email protected]> * trie/verkle: add comment Signed-off-by: Ignacio Hagopian <[email protected]> --------- Signed-off-by: Ignacio Hagopian <[email protected]>
1 parent 957ca35 commit a586f0d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

trie/verkle.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,19 @@ func (t *VerkleTrie) GetAccount(addr common.Address) (*types.StateAccount, error
115115
return nil, fmt.Errorf("GetAccount (%x) error: %v", addr, err)
116116
}
117117

118-
if values == nil {
118+
// The following code is required for the MPT->VKT conversion.
119+
// An account can be partially migrated, where storage slots were moved to the VKT
120+
// but not yet the account. This means some account information as (header) storage slots
121+
// are in the VKT but basic account information must be read in the base tree (MPT).
122+
// TODO: we can simplify this logic depending if the conversion is in progress or finished.
123+
emptyAccount := true
124+
for i := 0; values != nil && i <= utils.CodeHashLeafKey && emptyAccount; i++ {
125+
emptyAccount = emptyAccount && values[i] == nil
126+
}
127+
if emptyAccount {
119128
return nil, nil
120129
}
130+
121131
if len(values[utils.NonceLeafKey]) > 0 {
122132
acc.Nonce = binary.LittleEndian.Uint64(values[utils.NonceLeafKey])
123133
}

0 commit comments

Comments
 (0)