diff --git a/packages/util/examples/verkle.ts b/packages/util/examples/verkle.ts index 9fdfebab2b..da74e8b7fe 100644 --- a/packages/util/examples/verkle.ts +++ b/packages/util/examples/verkle.ts @@ -8,7 +8,7 @@ import { const state = { '0xdf67dea9181141d6255ac05c7ada5a590fb30a375023f16c31223f067319e300': - '0x0000000000000000000000000000000000000000000000000000000000000000', + '0x0100000001000000000000000000000001000000000000000000000000000000', '0xdf67dea9181141d6255ac05c7ada5a590fb30a375023f16c31223f067319e301': '0x923672e5275a0104000000000000000000000000000000000000000000000000', '0xdf67dea9181141d6255ac05c7ada5a590fb30a375023f16c31223f067319e302': @@ -24,4 +24,4 @@ const basicDataKey = getVerkleKey(stem, VerkleLeafType.BasicData) const basicDataRaw = state[bytesToHex(basicDataKey)] const basicData = decodeVerkleLeafBasicData(hexToBytes(basicDataRaw!)) -console.log(basicData) // { version: 0, nonce: 0n, codeSize: 0, balance: 0n } +console.log(basicData) // { version: 1, nonce: 1n, codeSize: 0, balance: 1n } diff --git a/packages/util/src/verkle.ts b/packages/util/src/verkle.ts index 5287f01841..b338aa1c70 100644 --- a/packages/util/src/verkle.ts +++ b/packages/util/src/verkle.ts @@ -177,7 +177,7 @@ export const getVerkleKey = (stem: Uint8Array, leaf: VerkleLeafType | Uint8Array * Calculates the position of the storage key in the Verkle tree, determining * both the tree index (the node in the tree) and the subindex (the position within the node). * @param {bigint} storageKey - The key representing a specific storage slot. - * @returns {Object} - An object containing: + * @returns {Object} - An object containing the tree index and subindex */ export function getVerkleTreeIndicesForStorageSlot(storageKey: bigint): { treeIndex: bigint @@ -200,7 +200,7 @@ export function getVerkleTreeIndicesForStorageSlot(storageKey: bigint): { * Calculates the position of the code chunks in the Verkle tree, determining * both the tree index (the node in the tree) and the subindex (the position within the node). * @param {bigint} chunkId - The ID representing a specific chunk. - * @returns {Object} - An object containing: + * @returns {Object} - An object containing the tree index and subindex */ export function getVerkleTreeIndicesForCodeChunk(chunkId: number) { const treeIndex = Math.floor((VERKLE_CODE_OFFSET + chunkId) / VERKLE_NODE_WIDTH) @@ -257,7 +257,7 @@ export const getVerkleTreeKeyForStorageSlot = async ( * from the `encodedBasicData` array based on predefined offsets and lengths, and then converted * to its appropriate type (integer or BigInt). * @param {Uint8Array} encodedBasicData - The encoded Verkle leaf basic data containing the version, nonce, - * code size, and balance in a compact binary format. + * code size, and balance in a compact Uint8Array format. * @returns {VerkleLeafBasicData} - An object containing the decoded version, nonce, code size, and balance. */ export function decodeVerkleLeafBasicData(encodedBasicData: Uint8Array): VerkleLeafBasicData { @@ -291,7 +291,7 @@ export function decodeVerkleLeafBasicData(encodedBasicData: Uint8Array): VerkleL * in EIP-6800. * @param {VerkleLeafBasicData} basicData - An object containing the version, nonce, * code size, and balance to be encoded. - * @returns {Uint8Array} - A compact, binary-encoded representation of the account header basic data. + * @returns {Uint8Array} - A compact bytes representation of the account header basic data. */ export function encodeVerkleLeafBasicData(basicData: VerkleLeafBasicData): Uint8Array { const encodedVersion = setLengthLeft(int32ToBytes(basicData.version), VERKLE_VERSION_BYTES_LENGTH)