diff --git a/packages/statemanager/src/statefulVerkleStateManager.ts b/packages/statemanager/src/statefulVerkleStateManager.ts index 42b610326d..30aec348f5 100644 --- a/packages/statemanager/src/statefulVerkleStateManager.ts +++ b/packages/statemanager/src/statefulVerkleStateManager.ts @@ -385,9 +385,9 @@ export class StatefulVerkleStateManager implements StateManagerInterface { // Determine code ending byte (if we're on the last chunk) let sliceEnd = 32 if (x === chunks.length - 1) { - sliceEnd = (codeSize % VERKLE_CODE_CHUNK_SIZE) + 1 + // On the last chunk, the end of the slice is either codeSize (if only one chunk) or codeSize % chunkSize + sliceEnd = (x === 0 ? codeSize : codeSize % VERKLE_CODE_CHUNK_SIZE) + 1 } - code.set(chunks[x]!.slice(1, sliceEnd), code.byteOffset + x * VERKLE_CODE_CHUNK_SIZE) } this._caches?.code?.put(address, code) @@ -538,7 +538,6 @@ export class StatefulVerkleStateManager implements StateManagerInterface { return bytesToHex(basicDataBytes) } else { const encodedAccount = this._caches?.account?.get(address)?.accountRLP - this._debug(`we have encoded account ${encodedAccount}`) if (encodedAccount === undefined) { return null } diff --git a/packages/vm/src/runBlock.ts b/packages/vm/src/runBlock.ts index 0ec31d43d4..520960df2f 100644 --- a/packages/vm/src/runBlock.ts +++ b/packages/vm/src/runBlock.ts @@ -47,6 +47,7 @@ import type { import type { VM } from './vm.js' import type { Block } from '@ethereumjs/block' import type { Common } from '@ethereumjs/common' +import type { StatefulVerkleStateManager } from '@ethereumjs/statemanager' import type { CLRequest, CLRequestType, PrefixedHexString } from '@ethereumjs/util' const debug = debugDefault('vm:block') @@ -134,40 +135,37 @@ export async function runBlock(vm: VM, opts: RunBlockOpts): Promise