From 1b6d696b8ed2dd85ec8af40c5fdc1cceeb5c7a7b Mon Sep 17 00:00:00 2001 From: Gabriel Rocheleau Date: Wed, 10 Jul 2024 20:16:10 -0400 Subject: [PATCH] verkle: address merge conflicts and refactors --- packages/evm/src/opcodes/gas.ts | 2 +- .../src/statelessVerkleStateManager.ts | 10 +-- packages/util/src/verkle.ts | 62 +++++++++++++++++++ packages/verkle/src/constants.ts | 24 ------- packages/verkle/src/index.ts | 1 - packages/verkle/src/node/util.ts | 51 +-------------- 6 files changed, 70 insertions(+), 80 deletions(-) delete mode 100644 packages/verkle/src/constants.ts diff --git a/packages/evm/src/opcodes/gas.ts b/packages/evm/src/opcodes/gas.ts index 0100d38bf0..ade64847b8 100644 --- a/packages/evm/src/opcodes/gas.ts +++ b/packages/evm/src/opcodes/gas.ts @@ -261,7 +261,7 @@ export const dynamicGasHandlers: Map { } return expandedValues } - -export function decodeLeafBasicData(encodedBasicData: Uint8Array): VerkleLeafBasicData { - const versionBytes = encodedBasicData.slice(0, VERSION_BYTES_LENGTH) - const nonceBytes = encodedBasicData.slice(NONCE_OFFSET, NONCE_OFFSET + NONCE_BYTES_LENGTH) - const codeSizeBytes = encodedBasicData.slice( - CODE_SIZE_OFFSET, - CODE_SIZE_OFFSET + CODE_SIZE_BYTES_LENGTH - ) - const balanceBytes = encodedBasicData.slice(BALANCE_OFFSET, BALANCE_OFFSET + BALANCE_BYTES_LENGTH) - - const version = bytesToInt32(versionBytes, true) - const nonce = bytesToBigInt(nonceBytes, true) - const codeSize = bytesToInt32(codeSizeBytes, true) - const balance = bytesToBigInt(balanceBytes, true) - - return { version, nonce, codeSize, balance } -} - -export function encodeLeafBasicData(basicData: VerkleLeafBasicData): Uint8Array { - const encodedVersion = setLengthRight(int32ToBytes(basicData.version, true), VERSION_BYTES_LENGTH) - const encodedNonce = setLengthRight(bigIntToBytes(basicData.nonce, true), NONCE_BYTES_LENGTH) - const encodedCodeSize = setLengthRight( - int32ToBytes(basicData.codeSize, true), - CODE_SIZE_BYTES_LENGTH - ) - const encodedBalance = setLengthRight( - bigIntToBytes(basicData.balance, true), - BALANCE_BYTES_LENGTH - ) - return concatBytes(encodedVersion, encodedNonce, encodedCodeSize, encodedBalance) -}