diff --git a/packages/evm/src/evm.ts b/packages/evm/src/evm.ts index f5ed56afe1..894466b3e3 100644 --- a/packages/evm/src/evm.ts +++ b/packages/evm/src/evm.ts @@ -40,7 +40,7 @@ import type { } from './types' import type { Account } from '@ethereumjs/util' -const debug = createDebugLogger('evm') +const debug = createDebugLogger('evm:evm') const debugGas = createDebugLogger('evm:gas') // very ugly way to detect if we are running in a browser @@ -364,13 +364,13 @@ export class EVM implements EVMInterface { if (!message.code || message.code.length === 0) { exit = true if (this.DEBUG) { - debug(`Exit early on no code`) + debug(`Exit early on no code (CALL)`) } } if (errorMessage !== undefined) { exit = true if (this.DEBUG) { - debug(`Exit early on value transfer overflowed`) + debug(`Exit early on value transfer overflowed (CALL)`) } } if (exit) { @@ -482,13 +482,13 @@ export class EVM implements EVMInterface { if (message.code === undefined || message.code.length === 0) { exit = true if (this.DEBUG) { - debug(`Exit early on no code`) + debug(`Exit early on no code (CREATE)`) } } if (errorMessage !== undefined) { exit = true if (this.DEBUG) { - debug(`Exit early on value transfer overflowed`) + debug(`Exit early on value transfer overflowed (CREATE)`) } } if (exit) { @@ -745,7 +745,7 @@ export class EVM implements EVMInterface { } await this.eei.checkpoint() - this._transientStorage.checkpoint() + if (this._common.isActivatedEIP(1153)) this._transientStorage.checkpoint() if (this.DEBUG) { debug('-'.repeat(100)) debug(`message checkpoint`) @@ -789,29 +789,19 @@ export class EVM implements EVMInterface { result.execResult.selfdestruct = {} result.execResult.gasRefund = BigInt(0) } - if (err) { - if ( - this._common.gteHardfork(Hardfork.Homestead) || - err.error !== ERROR.CODESTORE_OUT_OF_GAS - ) { - result.execResult.logs = [] - await this.eei.revert() - this._transientStorage.revert() - if (this.DEBUG) { - debug(`message checkpoint reverted`) - } - } else { - // we are in chainstart and the error was the code deposit error - // we do like nothing happened. - await this.eei.commit() - this._transientStorage.commit() - if (this.DEBUG) { - debug(`message checkpoint committed`) - } + if ( + err && + !(this._common.hardfork() === Hardfork.Chainstart && err.error === ERROR.CODESTORE_OUT_OF_GAS) + ) { + result.execResult.logs = [] + await this.eei.revert() + if (this._common.isActivatedEIP(1153)) this._transientStorage.revert() + if (this.DEBUG) { + debug(`message checkpoint reverted`) } } else { await this.eei.commit() - this._transientStorage.commit() + if (this._common.isActivatedEIP(1153)) this._transientStorage.commit() if (this.DEBUG) { debug(`message checkpoint committed`) } diff --git a/packages/evm/src/memory.ts b/packages/evm/src/memory.ts index d39bbde3b7..b3050ef432 100644 --- a/packages/evm/src/memory.ts +++ b/packages/evm/src/memory.ts @@ -70,7 +70,7 @@ export class Memory { const returnBuffer = Buffer.allocUnsafe(size) // Copy the stored "buffer" from memory into the return Buffer - const loaded = Buffer.from(this._store.slice(offset, offset + size)) + const loaded = this._store.slice(offset, offset + size) returnBuffer.fill(loaded, 0, loaded.length) if (loaded.length < size) { diff --git a/packages/vm/src/eei/vmState.ts b/packages/vm/src/eei/vmState.ts index 72880ca9c5..d397bd2d83 100644 --- a/packages/vm/src/eei/vmState.ts +++ b/packages/vm/src/eei/vmState.ts @@ -68,7 +68,7 @@ export class VmState implements EVMStateAccess { if (this.DEBUG) { this._debug('-'.repeat(100)) - this._debug(`message checkpoint`) + this._debug(`state checkpoint`) } } @@ -89,7 +89,7 @@ export class VmState implements EVMStateAccess { } if (this.DEBUG) { - this._debug(`message checkpoint committed`) + this._debug(`state checkpoint committed`) } } @@ -127,7 +127,7 @@ export class VmState implements EVMStateAccess { } if (this.DEBUG) { - this._debug(`message checkpoint reverted`) + this._debug(`state checkpoint reverted`) } }