Skip to content

Commit

Permalink
truncate large balances
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Ballet <[email protected]>
  • Loading branch information
gballet committed Oct 31, 2024
1 parent 8f53873 commit 7cfa21e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions trie/verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ func (t *VerkleTrie) UpdateAccount(addr common.Address, acc *types.StateAccount,

binary.BigEndian.PutUint32(basicData[utils.BasicDataCodeSizeOffset-1:], uint32(codeLen))
binary.BigEndian.PutUint64(basicData[utils.BasicDataNonceOffset:], acc.Nonce)
// Because the balance is a max of 16 bytes, truncate
// the extra values. This happens in devmode, where
// 0xff**32 is allocated to the developer account.
balanceBytes := acc.Balance.Bytes()
if len(balanceBytes) > 16 {
balanceBytes = balanceBytes[16:]
}
copy(basicData[32-len(balanceBytes):], balanceBytes[:])
values[utils.BasicDataLeafKey] = basicData[:]
values[utils.CodeHashLeafKey] = acc.CodeHash[:]
Expand Down

0 comments on commit 7cfa21e

Please sign in to comment.