Skip to content

Commit

Permalink
nyota fixes (#469)
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign authored and gballet committed Aug 23, 2024
1 parent 6626e04 commit 063552e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func VerkleKey(ctx *cli.Context) error {
}
fmt.Printf("%#x\n", utils.GetTreeKeyStorageSlotWithEvaluatedAddress(ap, slot))
} else {
fmt.Printf("%#x\n", utils.GetTreeKeyVersionWithEvaluatedAddress(ap))
fmt.Printf("%#x\n", utils.GetTreeKeyBasicDataEvaluatedAddress(ap))
}
return nil
}
Expand Down
11 changes: 7 additions & 4 deletions trie/verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ func (t *VerkleTrie) UpdateAccount(addr common.Address, acc *types.StateAccount,
stem = t.pointCache.GetTreeKeyBasicDataCached(addr[:])
)

binary.LittleEndian.PutUint64(basicData[utils.BasicDataNonceOffset:], acc.Nonce)
binary.BigEndian.PutUint64(basicData[utils.BasicDataNonceOffset:], acc.Nonce)
// get the lower 16 bytes of water and change its endianness
balanceBytes := acc.Balance.Bytes()
for i := 0; i < 16 && i < len(balanceBytes); i++ {
basicData[utils.BasicDataBalanceOffset+i] = balanceBytes[len(balanceBytes)-1-i]
basicData[utils.BasicDataBalanceOffset+i] = balanceBytes[i]
}
// var cs [8]byte
// binary.LittleEndian.PutUint64(cs[:], uint64(codeLen))
// binary.BigEndian.PutUint64(cs[:], uint64(codeLen))
// copy(basicData[utils.BasicDataCodeSizeOffset:], cs[:3])

values[utils.BasicDataLeafKey] = basicData[:]
Expand Down Expand Up @@ -457,8 +457,11 @@ func (t *VerkleTrie) UpdateContractCode(addr common.Address, codeHash common.Has

// Reuse the calculated key to also update the code size.
if i == 0 {
var basicDataKey [32]byte
copy(basicDataKey[:], key[:31])
basicDataKey[31] = utils.BasicDataLeafKey
// XXX add subfield update api
basicdata, err := t.root.Get(key, nil)
basicdata, err := t.root.Get(basicDataKey[:], nil)
if err != nil {
return fmt.Errorf("UpdateContractCode (addr=%x) error getting basic data leaf: %w", addr[:], err)
}
Expand Down

0 comments on commit 063552e

Please sign in to comment.