From b903ad46579a4073edfbe20b8a08427a13392eef Mon Sep 17 00:00:00 2001 From: Holger Drewes Date: Sat, 17 Aug 2024 16:24:50 +0200 Subject: [PATCH] Some more solid/qualified EVM dummy blockchain + interface naming to allow for exporting --- packages/evm/src/constructors.ts | 4 ++-- packages/evm/src/types.ts | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/evm/src/constructors.ts b/packages/evm/src/constructors.ts index 381a542806..f6a3e2b24d 100644 --- a/packages/evm/src/constructors.ts +++ b/packages/evm/src/constructors.ts @@ -2,7 +2,7 @@ import { Common, Mainnet } from '@ethereumjs/common' import { SimpleStateManager } from '@ethereumjs/statemanager' import { NobleBN254 } from './precompiles/index.js' -import { DefaultBlockchain } from './types.js' +import { EVMMockBlockchain } from './types.js' import { EVM } from './index.js' @@ -25,7 +25,7 @@ export async function createEVM(createOpts?: EVMOpts) { } if (opts.blockchain === undefined) { - opts.blockchain = new DefaultBlockchain() + opts.blockchain = new EVMMockBlockchain() } if (opts.stateManager === undefined) { diff --git a/packages/evm/src/types.ts b/packages/evm/src/types.ts index b359d1c69f..6d7dfe3fc9 100644 --- a/packages/evm/src/types.ts +++ b/packages/evm/src/types.ts @@ -343,9 +343,13 @@ export interface EVMOpts { stateManager?: StateManagerInterface /** + * The EVM comes with a basic mock blockchain interface and implementation for + * non-block containing use cases. * + * For block-containing setups use the full blockchain implementation from the + * `@ethereumjs/blockchain package. */ - blockchain?: Blockchain + blockchain?: EVMMockBlockchainInterface /** * @@ -472,16 +476,16 @@ export interface TransientStorageInterface { clear(): void } -type MockBlock = { +export type EVMMockBlock = { hash(): Uint8Array } -export interface Blockchain { - getBlock(blockId: number): Promise - shallowCopy(): Blockchain +export interface EVMMockBlockchainInterface { + getBlock(blockId: number): Promise + shallowCopy(): EVMMockBlockchainInterface } -export class DefaultBlockchain implements Blockchain { +export class EVMMockBlockchain implements EVMMockBlockchainInterface { async getBlock() { return { hash() {