From 5f78bb296788633ce223e1d7a07a5b23937c7bf8 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Tue, 13 Jun 2023 10:02:17 +0200 Subject: [PATCH] fix: copy balance leaf to new buffer in TryGetAccount --- trie/verkle.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/trie/verkle.go b/trie/verkle.go index d3dc0b1fa3a2..9413b9ea3193 100644 --- a/trie/verkle.go +++ b/trie/verkle.go @@ -104,10 +104,10 @@ func (t *VerkleTrie) TryGetAccount(key []byte) (*types.StateAccount, error) { if len(values[utils.NonceLeafKey]) > 0 { acc.Nonce = binary.LittleEndian.Uint64(values[utils.NonceLeafKey]) } - balance := values[utils.BalanceLeafKey] - if len(balance) > 0 { - for i := 0; i < len(balance)/2; i++ { - balance[len(balance)-i-1], balance[i] = balance[i], balance[len(balance)-i-1] + var balance [32]byte + if len(values[utils.BalanceLeafKey]) > 0 { + for i := 0; i < len(balance); i++ { + balance[len(balance)-i-1] = values[utils.BalanceLeafKey][i] } } acc.Balance = new(big.Int).SetBytes(balance[:])