diff --git a/config/tsconfig.json b/config/tsconfig.json index e0f4ed1545c..974902f2123 100644 --- a/config/tsconfig.json +++ b/config/tsconfig.json @@ -3,8 +3,8 @@ "sourceMap": true, "declaration": true, "declarationMap": true, - "module": "Node16", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "emitDecoratorMetadata": true, "experimentalDecorators": true, "esModuleInterop": false, diff --git a/config/tsconfig.prod.cjs.json b/config/tsconfig.prod.cjs.json index fc8520e7376..fe0aa2cc496 100644 --- a/config/tsconfig.prod.cjs.json +++ b/config/tsconfig.prod.cjs.json @@ -1,3 +1,7 @@ { - "extends": "./tsconfig.json" + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "Node16", + "moduleResolution": "node" + } } diff --git a/config/tsconfig.prod.esm.json b/config/tsconfig.prod.esm.json index fec8b26791a..fc8520e7376 100644 --- a/config/tsconfig.prod.esm.json +++ b/config/tsconfig.prod.esm.json @@ -1,6 +1,3 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "esnext" - } + "extends": "./tsconfig.json" } diff --git a/packages/block/package.json b/packages/block/package.json index f883e4259dd..a6453bd62d8 100644 --- a/packages/block/package.json +++ b/packages/block/package.json @@ -16,7 +16,7 @@ }, "license": "MPL-2.0", "author": "mjbecze (mb@ethdev.com)", - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/blockchain/package.json b/packages/blockchain/package.json index 180df21cc44..8f8ad12d1f8 100644 --- a/packages/blockchain/package.json +++ b/packages/blockchain/package.json @@ -16,7 +16,7 @@ }, "license": "MPL-2.0", "author": "mjbecze ", - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/blockchain/src/consensus/clique.ts b/packages/blockchain/src/consensus/clique.ts index 2a24955411c..9f59a7a95b6 100644 --- a/packages/blockchain/src/consensus/clique.ts +++ b/packages/blockchain/src/consensus/clique.ts @@ -18,9 +18,8 @@ import type { Blockchain } from '../index.js' import type { Consensus, ConsensusOptions } from '../types.js' import type { Block, BlockHeader } from '@ethereumjs/block' import type { CliqueConfig } from '@ethereumjs/common' -const { debug: createDebugLogger } = debugDefault -const debug = createDebugLogger('blockchain:clique') +const debug = debugDefault('blockchain:clique') // Magic nonce number to vote on adding a new signer export const CLIQUE_NONCE_AUTH = hexToBytes('0xffffffffffffffff') diff --git a/packages/blockchain/src/consensus/ethash.ts b/packages/blockchain/src/consensus/ethash.ts index a5f118dcec2..b02f4229c80 100644 --- a/packages/blockchain/src/consensus/ethash.ts +++ b/packages/blockchain/src/consensus/ethash.ts @@ -44,7 +44,7 @@ export class EthashConsensus implements Consensus { public async genesisInit(): Promise {} public async setup({ blockchain }: ConsensusOptions): Promise { this.blockchain = blockchain - this._ethash = new Ethash(this.blockchain.db as any) + this._ethash = new Ethash(this.blockchain!.db as any) } public async newBlock(): Promise {} } diff --git a/packages/blockchain/src/types.ts b/packages/blockchain/src/types.ts index fd810759a12..7ae0b755391 100644 --- a/packages/blockchain/src/types.ts +++ b/packages/blockchain/src/types.ts @@ -1,4 +1,4 @@ -import type { Blockchain } from '.' +import type { Blockchain } from './index.js' import type { Block, BlockHeader } from '@ethereumjs/block' import type { Common, ConsensusAlgorithm } from '@ethereumjs/common' import type { AsyncEventEmitter, DB, DBObject, GenesisState } from '@ethereumjs/util' diff --git a/packages/blockchain/tsconfig.json b/packages/blockchain/tsconfig.json index ad9065826ec..109ec6fb263 100644 --- a/packages/blockchain/tsconfig.json +++ b/packages/blockchain/tsconfig.json @@ -2,7 +2,6 @@ "extends": "../../config/tsconfig.json", "include": ["src/**/*.ts", "src/**/*.json", "test/**/*.ts"], "compilerOptions": { - "types": ["node"], "typeRoots": ["node_modules/@types"] } } diff --git a/packages/client/package.json b/packages/client/package.json index 112e177c25b..648725f084e 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -20,9 +20,9 @@ }, "license": "MPL-2.0", "author": "Vinay Pulim (v@pulim.com)", + "type": "module", "main": "dist/esm/bin/cli.js", "types": "dist/esm/src/index.d.ts", - "type": "module", "bin": { "ethereumjs": "dist/esm/bin/cli.js" }, diff --git a/packages/client/src/sync/fetcher/accountfetcher.ts b/packages/client/src/sync/fetcher/accountfetcher.ts index 64bc633ca05..7a5e8884435 100644 --- a/packages/client/src/sync/fetcher/accountfetcher.ts +++ b/packages/client/src/sync/fetcher/accountfetcher.ts @@ -34,7 +34,6 @@ import type { FetcherOptions } from './fetcher.js' import type { StorageRequest } from './storagefetcher.js' import type { Job, SnapFetcherDoneFlags } from './types.js' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault type AccountDataResponse = AccountData[] & { completed?: boolean } @@ -99,7 +98,7 @@ export class AccountFetcher extends Fetcher this.stateManager = options.stateManager ?? new DefaultStateManager() this.accountTrie = this.stateManager['_getAccountTrie']() - this.debug = createDebugLogger('client:AccountFetcher') + this.debug = debugDefault('client:AccountFetcher') this.storageFetcher = new StorageFetcher({ config: this.config, diff --git a/packages/client/src/sync/fetcher/bytecodefetcher.ts b/packages/client/src/sync/fetcher/bytecodefetcher.ts index 816ae7aa1c9..e0fdb957bca 100644 --- a/packages/client/src/sync/fetcher/bytecodefetcher.ts +++ b/packages/client/src/sync/fetcher/bytecodefetcher.ts @@ -6,7 +6,7 @@ import { concatBytes, equalsBytes, } from '@ethereumjs/util' -import debugDefault from 'debug' +import debug from 'debug' import { keccak256 } from 'ethereum-cryptography/keccak' import { Fetcher } from './fetcher.js' @@ -17,7 +17,6 @@ import type { FetcherOptions } from './fetcher.js' import type { Job, SnapFetcherDoneFlags } from './types.js' import type { BatchDBOp, DB } from '@ethereumjs/util' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault type ByteCodeDataResponse = Uint8Array[] & { completed?: boolean } @@ -62,7 +61,7 @@ export class ByteCodeFetcher extends Fetcher this.keccakFunction = this.config.chainCommon.customCrypto.keccak256 ?? keccak256 - this.debug = createDebugLogger('client:ByteCodeFetcher') + this.debug = debug('client:ByteCodeFetcher') if (this.hashes.length > 0) { const fullJob = { task: { hashes: this.hashes } } as Job this.debug( diff --git a/packages/client/src/sync/fetcher/fetcher.ts b/packages/client/src/sync/fetcher/fetcher.ts index c2750bf917e..6bc1e92d906 100644 --- a/packages/client/src/sync/fetcher/fetcher.ts +++ b/packages/client/src/sync/fetcher/fetcher.ts @@ -1,4 +1,4 @@ -import debugDefault from 'debug' +import debug from 'debug' import { Readable, Writable } from 'stream' import { Heap } from '../../ext/qheap.js' @@ -12,8 +12,6 @@ import type { JobTask as BlockFetcherJobTask } from './blockfetcherbase.js' import type { Job } from './types.js' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault - export interface FetcherOptions { /* Common chain config*/ config: Config @@ -80,7 +78,7 @@ export abstract class Fetcher extends Readable super({ ...options, objectMode: true }) this.config = options.config - this.debug = createDebugLogger('client:fetcher') + this.debug = debug('client:fetcher') this.pool = options.pool this.timeout = options.timeout ?? 8000 diff --git a/packages/client/src/sync/fetcher/storagefetcher.ts b/packages/client/src/sync/fetcher/storagefetcher.ts index 6ffae1fed48..6602785af80 100644 --- a/packages/client/src/sync/fetcher/storagefetcher.ts +++ b/packages/client/src/sync/fetcher/storagefetcher.ts @@ -24,7 +24,6 @@ import type { StorageData } from '../../net/protocol/snapprotocol.js' import type { FetcherOptions } from './fetcher.js' import type { Job, SnapFetcherDoneFlags } from './types.js' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault const TOTAL_RANGE_END = BIGINT_2 ** BIGINT_256 - BIGINT_1 @@ -95,7 +94,7 @@ export class StorageFetcher extends Fetcher() - this.debug = createDebugLogger('client:StorageFetcher') + this.debug = debugDefault('client:StorageFetcher') if (this.storageRequests.length > 0) { const fullJob = { task: { storageRequests: this.storageRequests }, diff --git a/packages/client/src/sync/fetcher/trienodefetcher.ts b/packages/client/src/sync/fetcher/trienodefetcher.ts index 300e8dbb895..54b8ab96ad3 100644 --- a/packages/client/src/sync/fetcher/trienodefetcher.ts +++ b/packages/client/src/sync/fetcher/trienodefetcher.ts @@ -15,7 +15,7 @@ import { KECCAK256_RLP, unprefixedHexToBytes, } from '@ethereumjs/util' -import debugPkg from 'debug' +import debug from 'debug' import { keccak256 } from 'ethereum-cryptography/keccak.js' import { bytesToHex, equalsBytes, hexToBytes } from 'ethereum-cryptography/utils' import { OrderedMap } from 'js-sdsl' @@ -28,7 +28,6 @@ import type { FetcherOptions } from './fetcher.js' import type { Job, SnapFetcherDoneFlags } from './types.js' import type { BatchDBOp, DB } from '@ethereumjs/util' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugPkg type TrieNodesResponse = Uint8Array[] & { completed?: boolean } @@ -111,7 +110,7 @@ export class TrieNodeFetcher extends Fetcher this.codeDB = this.stateManager['_getCodeDB']() this.nodeCount = 0 - this.debug = createDebugLogger('client:TrieNodeFetcher') + this.debug = debug('client:TrieNodeFetcher') this.keccakFunction = this.config.chainCommon.customCrypto.keccak256 ?? keccak256 diff --git a/packages/client/tsconfig.json b/packages/client/tsconfig.json index 3c51a814810..ce0d04ef29e 100644 --- a/packages/client/tsconfig.json +++ b/packages/client/tsconfig.json @@ -3,6 +3,6 @@ "include": ["bin", "src", "test", "package.json"], "compilerOptions": { "typeRoots": ["node_modules/@types", "src/@types"], - "moduleResolution": "Node16" + "allowSyntheticDefaultImports": true } } diff --git a/packages/client/tsconfig.prod.esm.json b/packages/client/tsconfig.prod.esm.json index a855a8ff28f..baf85d72afe 100644 --- a/packages/client/tsconfig.prod.esm.json +++ b/packages/client/tsconfig.prod.esm.json @@ -4,17 +4,18 @@ "compilerOptions": { "outDir": "dist/esm", "typeRoots": ["node_modules/@types", "src/@types"], - "composite": true + "composite": true, + "allowSyntheticDefaultImports": true }, "references": [ - { "path": "../block/tsconfig.prod.cjs.json" }, - { "path": "../blockchain/tsconfig.prod.cjs.json" }, - { "path": "../common/tsconfig.prod.cjs.json" }, - { "path": "../devp2p/tsconfig.prod.cjs.json" }, - { "path": "../rlp/tsconfig.prod.cjs.json" }, - { "path": "../trie/tsconfig.prod.cjs.json" }, - { "path": "../tx/tsconfig.prod.cjs.json" }, - { "path": "../util/tsconfig.prod.cjs.json" }, - { "path": "../vm/tsconfig.prod.cjs.json" } + { "path": "../block/tsconfig.prod.esm.json" }, + { "path": "../blockchain/tsconfig.prod.esm.json" }, + { "path": "../common/tsconfig.prod.esm.json" }, + { "path": "../devp2p/tsconfig.prod.esm.json" }, + { "path": "../rlp/tsconfig.prod.esm.json" }, + { "path": "../trie/tsconfig.prod.esm.json" }, + { "path": "../tx/tsconfig.prod.esm.json" }, + { "path": "../util/tsconfig.prod.esm.json" }, + { "path": "../vm/tsconfig.prod.esm.json" } ] } diff --git a/packages/common/package.json b/packages/common/package.json index 422276764e1..41083bf4012 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -26,7 +26,7 @@ "email": "Holger.Drewes@gmail.com" } ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/devp2p/package.json b/packages/devp2p/package.json index d14c3ccb8f5..b8379fd045e 100644 --- a/packages/devp2p/package.json +++ b/packages/devp2p/package.json @@ -29,8 +29,8 @@ "Martin Becze ", "Holger Drewes " ], - "main": "dist/cjs/index.js", "type": "module", + "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { ".": { diff --git a/packages/devp2p/src/dns/dns.ts b/packages/devp2p/src/dns/dns.ts index 9af414d118c..d2d056994e9 100644 --- a/packages/devp2p/src/dns/dns.ts +++ b/packages/devp2p/src/dns/dns.ts @@ -5,9 +5,8 @@ import { ENR } from './enr.js' import type { DNSOptions, PeerInfo } from '../types.js' import type { Common } from '@ethereumjs/common' -const { debug: createDebugLogger } = debugDefault -const debug = createDebugLogger('devp2p:dns:dns') +const debug = debugDefault('devp2p:dns:dns') type SearchContext = { domain: string diff --git a/packages/devp2p/src/dpt/ban-list.ts b/packages/devp2p/src/dpt/ban-list.ts index 678e5a161f3..639a700e962 100644 --- a/packages/devp2p/src/dpt/ban-list.ts +++ b/packages/devp2p/src/dpt/ban-list.ts @@ -6,10 +6,9 @@ import { formatLogId } from '../util.js' import { KBucket } from './kbucket.js' import type { PeerInfo } from '../types.js' -const { debug: createDebugLogger } = debugDefault -const debug = createDebugLogger('devp2p:dpt:ban-list') -const verbose = createDebugLogger('verbose').enabled +const debug = debugDefault('devp2p:dpt:ban-list') +const verbose = debugDefault('verbose').enabled export class BanList { private _lru: LRUCache diff --git a/packages/devp2p/src/dpt/message.ts b/packages/devp2p/src/dpt/message.ts index 55bfaf60dd2..f0d09ccfcd6 100644 --- a/packages/devp2p/src/dpt/message.ts +++ b/packages/devp2p/src/dpt/message.ts @@ -8,9 +8,8 @@ import { assertEq, ipToBytes, ipToString, isV4Format, isV6Format, unstrictDecode import type { PeerInfo } from '../types.js' import type { Common } from '@ethereumjs/common' -const { debug: createDebugLogger } = debugDefault -const debug = createDebugLogger('devp2p:dpt:server') +const debug = debugDefault('devp2p:dpt:server') function getTimestamp() { return (Date.now() / 1000) | 0 diff --git a/packages/devp2p/src/dpt/server.ts b/packages/devp2p/src/dpt/server.ts index 7c0fd5147da..dfb982e3f03 100644 --- a/packages/devp2p/src/dpt/server.ts +++ b/packages/devp2p/src/dpt/server.ts @@ -13,10 +13,9 @@ import type { DPT } from './dpt.js' import type { Common } from '@ethereumjs/common' import type { Debugger } from 'debug' import type { Socket as DgramSocket, RemoteInfo } from 'dgram' -const { debug: createDebugLogger } = debugDefault const DEBUG_BASE_NAME = 'dpt:server' -const verbose = createDebugLogger('verbose').enabled +const verbose = debugDefault('verbose').enabled const VERSION = 0x04 diff --git a/packages/devp2p/src/protocol/protocol.ts b/packages/devp2p/src/protocol/protocol.ts index bc8dcc28a97..01ccd3e22e3 100644 --- a/packages/devp2p/src/protocol/protocol.ts +++ b/packages/devp2p/src/protocol/protocol.ts @@ -7,7 +7,6 @@ import { devp2pDebug } from '../util.js' import type { Peer } from '../rlpx/peer.js' import type { SendMethod } from '../types.js' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault type MessageCodes = { [key: number | string]: number | string } @@ -50,7 +49,7 @@ export abstract class Protocol { : undefined this._debug = devp2pDebug.extend(protocol) - this._verbose = createDebugLogger('verbose').enabled + this._verbose = debugDefault('verbose').enabled this.initMsgDebuggers(protocol) } diff --git a/packages/devp2p/src/rlpx/ecies.ts b/packages/devp2p/src/rlpx/ecies.ts index 21535fded58..d13fa10886b 100644 --- a/packages/devp2p/src/rlpx/ecies.ts +++ b/packages/devp2p/src/rlpx/ecies.ts @@ -12,10 +12,9 @@ import { assertEq, genPrivateKey, id2pk, pk2id, unstrictDecode, xor, zfill } fro import { MAC } from './mac.js' import type { Common } from '@ethereumjs/common' -const { debug: createDebugLogger } = debugDefault type Decipher = crypto.Decipher -const debug = createDebugLogger('devp2p:rlpx:peer') +const debug = debugDefault('devp2p:rlpx:peer') function ecdhX(publicKey: Uint8Array, privateKey: Uint8Array) { // return (publicKey * privateKey).x diff --git a/packages/devp2p/src/rlpx/peer.ts b/packages/devp2p/src/rlpx/peer.ts index 88ff611c5dc..e980c896882 100644 --- a/packages/devp2p/src/rlpx/peer.ts +++ b/packages/devp2p/src/rlpx/peer.ts @@ -23,10 +23,9 @@ import type { Capabilities, PeerOptions } from '../types.js' import type { Common } from '@ethereumjs/common' import type { Debugger } from 'debug' import type { Socket } from 'net' -const { debug: createDebugLogger } = debugDefault const DEBUG_BASE_NAME = 'rlpx:peer' -const verbose = createDebugLogger('verbose').enabled +const verbose = debugDefault('verbose').enabled const BASE_PROTOCOL_VERSION = 5 const BASE_PROTOCOL_LENGTH = 16 diff --git a/packages/devp2p/src/rlpx/rlpx.ts b/packages/devp2p/src/rlpx/rlpx.ts index 7790d1c9e0b..45232dcf4cd 100644 --- a/packages/devp2p/src/rlpx/rlpx.ts +++ b/packages/devp2p/src/rlpx/rlpx.ts @@ -22,12 +22,11 @@ import type { DPT } from '../dpt/index.js' import type { Capabilities, PeerInfo, RLPxOptions } from '../types.js' import type { Common } from '@ethereumjs/common' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault // note: relative path only valid in .js file in dist const DEBUG_BASE_NAME = 'rlpx' -const verbose = createDebugLogger('verbose').enabled +const verbose = debugDefault('verbose').enabled export class RLPx { public events: EventEmitter diff --git a/packages/devp2p/src/types.ts b/packages/devp2p/src/types.ts index 9c1ba4dd843..a7f12d382cb 100644 --- a/packages/devp2p/src/types.ts +++ b/packages/devp2p/src/types.ts @@ -1,5 +1,5 @@ -import type { DPT } from './dpt' -import type { Protocol } from './protocol/protocol' +import type { DPT } from './dpt/index.js' +import type { Protocol } from './protocol/protocol.js' import type { Common } from '@ethereumjs/common' import type { Socket } from 'net' diff --git a/packages/devp2p/src/util.ts b/packages/devp2p/src/util.ts index 52634713831..746cece35ef 100644 --- a/packages/devp2p/src/util.ts +++ b/packages/devp2p/src/util.ts @@ -1,14 +1,13 @@ import { RLP } from '@ethereumjs/rlp' import { bytesToHex, bytesToUnprefixedHex, concatBytes, equalsBytes } from '@ethereumjs/util' -import debugDefault from 'debug' +import debug from 'debug' import { publicKeyConvert } from 'ethereum-cryptography/secp256k1-compat.js' import { secp256k1 } from 'ethereum-cryptography/secp256k1.js' import type { ETH } from './protocol/eth.js' import type { LES } from './protocol/les.js' -const { debug: createDebugLogger } = debugDefault -export const devp2pDebug = createDebugLogger('devp2p') +export const devp2pDebug = debug('devp2p') export function genPrivateKey(): Uint8Array { const privateKey = secp256k1.utils.randomPrivateKey() diff --git a/packages/evm/package.json b/packages/evm/package.json index d080ceccf2b..bd132656d44 100644 --- a/packages/evm/package.json +++ b/packages/evm/package.json @@ -21,6 +21,7 @@ "contributors": [ "Alex Beregszaszi " ], + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/evm/src/evm.ts b/packages/evm/src/evm.ts index 2a04fe429f6..a9266197e96 100644 --- a/packages/evm/src/evm.ts +++ b/packages/evm/src/evm.ts @@ -52,11 +52,10 @@ import type { bn128, } from './types.js' import type { EVMStateManagerInterface } from '@ethereumjs/common' -const { debug: createDebugLogger } = debugDefault -const debug = createDebugLogger('evm:evm') -const debugGas = createDebugLogger('evm:gas') -const debugPrecompiles = createDebugLogger('evm:precompiles') +const debug = debugDefault('evm:evm') +const debugGas = debugDefault('evm:gas') +const debugPrecompiles = debugDefault('evm:precompiles') let initializedRustBN: bn128 | undefined = undefined diff --git a/packages/evm/src/index.ts b/packages/evm/src/index.ts index c441fefe977..3c2303d301f 100644 --- a/packages/evm/src/index.ts +++ b/packages/evm/src/index.ts @@ -21,6 +21,7 @@ import type { Log, bn128, } from './types.js' +export * from './logger.js' export type { bn128, diff --git a/packages/evm/src/interpreter.ts b/packages/evm/src/interpreter.ts index bba5c9ce90c..ec46ecb3e12 100644 --- a/packages/evm/src/interpreter.ts +++ b/packages/evm/src/interpreter.ts @@ -25,9 +25,8 @@ import type { AsyncOpHandler, Opcode, OpcodeMapEntry } from './opcodes/index.js' import type { Block, Blockchain, EVMProfilerOpts, EVMResult, Log } from './types.js' import type { AccessWitnessInterface, Common, EVMStateManagerInterface } from '@ethereumjs/common' import type { Address, PrefixedHexString } from '@ethereumjs/util' -const { debug: createDebugLogger } = debugDefault -const debugGas = createDebugLogger('evm:gas') +const debugGas = debugDefault('evm:gas') export interface InterpreterOpts { pc?: number @@ -435,7 +434,7 @@ export class Interpreter { } if (!(name in this.opDebuggers)) { - this.opDebuggers[name] = createDebugLogger(`evm:ops:${name}`) + this.opDebuggers[name] = debugDefault(`evm:ops:${name}`) } this.opDebuggers[name](JSON.stringify(opTrace)) } diff --git a/packages/evm/src/journal.ts b/packages/evm/src/journal.ts index 1a84e51ac5f..60dad80bd37 100644 --- a/packages/evm/src/journal.ts +++ b/packages/evm/src/journal.ts @@ -13,7 +13,6 @@ import { hexToBytes } from 'ethereum-cryptography/utils' import type { Common, EVMStateManagerInterface } from '@ethereumjs/common' import type { Account, PrefixedHexString } from '@ethereumjs/util' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault type AddressString = string type SlotString = string @@ -54,7 +53,7 @@ export class Journal { this.DEBUG = typeof window === 'undefined' ? process?.env?.DEBUG?.includes('ethjs') ?? false : false - this._debug = createDebugLogger('statemanager:statemanager') + this._debug = debugDefault('statemanager:statemanager') // TODO maybe call into this.clearJournal this.cleanJournal() diff --git a/packages/evm/src/precompiles/bls12_381/noble.ts b/packages/evm/src/precompiles/bls12_381/noble.ts index 577c7c33fa7..1d2ad640bee 100644 --- a/packages/evm/src/precompiles/bls12_381/noble.ts +++ b/packages/evm/src/precompiles/bls12_381/noble.ts @@ -21,7 +21,7 @@ import { } from './constants.js' import type { EVMBLSInterface } from '../../types.js' -import type { AffinePoint, ProjPointType } from '@noble/curves/abstract/weierstrass.js' +import type { AffinePoint, ProjPointType } from '@noble/curves/abstract/weierstrass' // Copied from @noble/curves/bls12-381 (only local declaration) type Fp2 = { diff --git a/packages/evm/src/precompiles/bls12_381/util.ts b/packages/evm/src/precompiles/bls12_381/util.ts index 446de8788e9..ca09ef12710 100644 --- a/packages/evm/src/precompiles/bls12_381/util.ts +++ b/packages/evm/src/precompiles/bls12_381/util.ts @@ -2,7 +2,7 @@ import { equalsBytes, short } from '@ethereumjs/util' import { BLS_GAS_DISCOUNT_PAIRS } from './constants.js' -import type { PrecompileInput } from '../types' +import type { PrecompileInput } from '../types.js' const ZERO_BYTES_16 = new Uint8Array(16) diff --git a/packages/genesis/package.json b/packages/genesis/package.json index 85bbda42ed8..bcfb77a1119 100644 --- a/packages/genesis/package.json +++ b/packages/genesis/package.json @@ -16,9 +16,9 @@ }, "license": "MIT", "author": "g11tech ", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", - "type": "commonjs", "exports": { ".": { "import": "./dist/esm/index.js", diff --git a/packages/statemanager/package.json b/packages/statemanager/package.json index 821879a00ee..b34d670fe42 100644 --- a/packages/statemanager/package.json +++ b/packages/statemanager/package.json @@ -19,7 +19,7 @@ "contributors": [ "g11tech " ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/statemanager/src/accessWitness.ts b/packages/statemanager/src/accessWitness.ts index 6ab4f87d4d3..2563c915373 100644 --- a/packages/statemanager/src/accessWitness.ts +++ b/packages/statemanager/src/accessWitness.ts @@ -22,8 +22,7 @@ import debugDefault from 'debug' import type { AccessEventFlags, AccessWitnessInterface } from '@ethereumjs/common' import type { Address, PrefixedHexString, VerkleCrypto } from '@ethereumjs/util' -const { debug: createDebugLogger } = debugDefault -const debug = createDebugLogger('statemanager:verkle:aw') +const debug = debugDefault('statemanager:verkle:aw') /** * Tree key constants. diff --git a/packages/statemanager/src/cache/account.ts b/packages/statemanager/src/cache/account.ts index 0619ee12fe3..c78ca1b41f3 100644 --- a/packages/statemanager/src/cache/account.ts +++ b/packages/statemanager/src/cache/account.ts @@ -8,7 +8,6 @@ import { CacheType } from './types.js' import type { CacheOpts } from './types.js' import type { Account, Address } from '@ethereumjs/util' -const { debug: createDebugLogger } = debugDefault /** * account: undefined @@ -45,7 +44,7 @@ export class AccountCache extends Cache { } this._diffCache.push(new Map()) - this._debug = createDebugLogger('statemanager:cache:account') + this._debug = debugDefault('statemanager:cache:account') } _saveCachePreState(cacheKeyHex: string) { diff --git a/packages/statemanager/src/cache/cache.ts b/packages/statemanager/src/cache/cache.ts index 878c2172d7f..3be3a712155 100644 --- a/packages/statemanager/src/cache/cache.ts +++ b/packages/statemanager/src/cache/cache.ts @@ -1,7 +1,6 @@ import debugDefault from 'debug' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault export class Cache { _debug: Debugger @@ -32,6 +31,6 @@ export class Cache { this.DEBUG = typeof window === 'undefined' ? process?.env?.DEBUG?.includes('ethjs') ?? false : false - this._debug = createDebugLogger('statemanager:cache') + this._debug = debugDefault('statemanager:cache') } } diff --git a/packages/statemanager/src/cache/code.ts b/packages/statemanager/src/cache/code.ts index f28f607ce0a..5579da224d4 100644 --- a/packages/statemanager/src/cache/code.ts +++ b/packages/statemanager/src/cache/code.ts @@ -9,8 +9,6 @@ import { CacheType } from './types.js' import type { CacheOpts } from './types.js' import type { Address } from '@ethereumjs/util' -const { debug: createDebugLogger } = debugDefault - /** * Represents a cached code element. */ @@ -45,7 +43,7 @@ export class CodeCache extends Cache { } this._diffCache.push(new Map()) - this._debug = createDebugLogger('statemanager:cache:code') + this._debug = debugDefault('statemanager:cache:code') } /** diff --git a/packages/statemanager/src/cache/storage.ts b/packages/statemanager/src/cache/storage.ts index 52ae969bc73..eb8d52bdd93 100644 --- a/packages/statemanager/src/cache/storage.ts +++ b/packages/statemanager/src/cache/storage.ts @@ -8,7 +8,6 @@ import { CacheType } from './types.js' import type { CacheOpts } from './types.js' import type { Address } from '@ethereumjs/util' -const { debug: createDebugLogger } = debugDefault /** * key -> storage mapping @@ -47,7 +46,7 @@ export class StorageCache extends Cache { this._diffCache.push(new Map()) if (this.DEBUG) { - this._debug = createDebugLogger('statemanager:cache:storage') + this._debug = debugDefault('statemanager:cache:storage') } } diff --git a/packages/statemanager/src/rpcStateManager.ts b/packages/statemanager/src/rpcStateManager.ts index 500b92a4710..2935088cedd 100644 --- a/packages/statemanager/src/rpcStateManager.ts +++ b/packages/statemanager/src/rpcStateManager.ts @@ -25,7 +25,6 @@ import type { } from '@ethereumjs/common' import type { Address, PrefixedHexString } from '@ethereumjs/util' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault export interface RPCStateManagerOpts { provider: string @@ -57,7 +56,7 @@ export class RPCStateManager implements EVMStateManagerInterface { this.DEBUG = typeof window === 'undefined' ? process?.env?.DEBUG?.includes('ethjs') ?? false : false - this._debug = createDebugLogger('statemanager:rpcStateManager') + this._debug = debugDefault('statemanager:rpcStateManager') if (typeof opts.provider === 'string' && opts.provider.startsWith('http')) { this._provider = opts.provider } else { diff --git a/packages/statemanager/src/stateManager.ts b/packages/statemanager/src/stateManager.ts index 0f4292521fa..9c08670e2e3 100644 --- a/packages/statemanager/src/stateManager.ts +++ b/packages/statemanager/src/stateManager.ts @@ -28,11 +28,14 @@ import { keccak256 } from 'ethereum-cryptography/keccak.js' import { AccountCache, CacheType, CodeCache, StorageCache } from './cache/index.js' import { OriginalStorageCache } from './cache/originalStorageCache.js' -import type { AccountFields, EVMStateManagerInterface, StorageDump } from '@ethereumjs/common' -import type { StorageRange } from '@ethereumjs/common/src' +import type { + AccountFields, + EVMStateManagerInterface, + StorageDump, + StorageRange, +} from '@ethereumjs/common' import type { DB, PrefixedHexString } from '@ethereumjs/util' import type { Debugger } from 'debug' -const { debug: createDebugLogger } = debugDefault export type StorageProof = { key: PrefixedHexString @@ -195,7 +198,7 @@ export class DefaultStateManager implements EVMStateManagerInterface { this.DEBUG = typeof window === 'undefined' ? process?.env?.DEBUG?.includes('ethjs') ?? false : false - this._debug = createDebugLogger('statemanager:statemanager') + this._debug = debugDefault('statemanager:statemanager') this.common = opts.common ?? new Common({ chain: Chain.Mainnet }) diff --git a/packages/statemanager/src/statelessVerkleStateManager.ts b/packages/statemanager/src/statelessVerkleStateManager.ts index b696af12f96..fb27cf144ab 100644 --- a/packages/statemanager/src/statelessVerkleStateManager.ts +++ b/packages/statemanager/src/statelessVerkleStateManager.ts @@ -44,9 +44,7 @@ import type { VerkleProof, } from '@ethereumjs/util' -const { debug: createDebugLogger } = debugDefault - -const debug = createDebugLogger('statemanager:verkle') +const debug = debugDefault('statemanager:verkle') export interface VerkleState { [key: PrefixedHexString]: PrefixedHexString | null diff --git a/packages/trie/examples/createFromProof.ts b/packages/trie/examples/createFromProof.ts index 90a56cf4f31..7b41410c425 100644 --- a/packages/trie/examples/createFromProof.ts +++ b/packages/trie/examples/createFromProof.ts @@ -1,6 +1,6 @@ import { Trie } from '@ethereumjs/trie' import { bytesToUtf8 } from '@ethereumjs/util' -import { utf8ToBytes } from 'ethereum-cryptography/utils' +import { utf8ToBytes } from '@ethereumjs/util' async function main() { const k1 = utf8ToBytes('keyOne') diff --git a/packages/trie/examples/logDemo.ts b/packages/trie/examples/logDemo.ts index d6638490dc5..f3b77fe7a5c 100644 --- a/packages/trie/examples/logDemo.ts +++ b/packages/trie/examples/logDemo.ts @@ -1,8 +1,8 @@ -import { utf8ToBytes } from 'ethereum-cryptography/utils' -import { Trie } from '../dist/cjs/index.js' -import { debug } from 'debug' - -debug.enable('*') +/** + * Run with DEBUG=ethjs,trie:* to see debug log ouput + */ +import { utf8ToBytes } from '@ethereumjs/util' +import { Trie } from '@ethereumjs/trie' const trie_entries: [string, string | null][] = [ ['do', 'verb'], @@ -16,7 +16,6 @@ const trie_entries: [string, string | null][] = [ ] const main = async () => { - process.env.DEBUG = 'ethjs,*trie*' const trie = new Trie({ useRootPersistence: true, }) diff --git a/packages/trie/examples/trieWalking.ts b/packages/trie/examples/trieWalking.ts index a2dc2d1afb8..e99eb935438 100644 --- a/packages/trie/examples/trieWalking.ts +++ b/packages/trie/examples/trieWalking.ts @@ -1,5 +1,5 @@ import { Trie } from '@ethereumjs/trie' -import { utf8ToBytes } from 'ethereum-cryptography/utils' +import { utf8ToBytes } from '@ethereumjs/util' async function main() { const trie = await Trie.create() diff --git a/packages/trie/package.json b/packages/trie/package.json index 14d5fd38f30..d9f7c58cea8 100644 --- a/packages/trie/package.json +++ b/packages/trie/package.json @@ -21,8 +21,8 @@ "contributors": [ "Aaron Kumavis (https://github.com/kumavis)" ], + "type": "module", "main": "dist/cjs/index.js", - "type": "commonjs", "module": "dist/esm/index.js", "exports": { ".": { diff --git a/packages/trie/src/util/view.ts b/packages/trie/scripts/view.ts similarity index 99% rename from packages/trie/src/util/view.ts rename to packages/trie/scripts/view.ts index fef2086f611..5d2f6000279 100644 --- a/packages/trie/src/util/view.ts +++ b/packages/trie/scripts/view.ts @@ -1,5 +1,5 @@ import { debug as _debug } from 'debug' -import { bytesToHex, equalsBytes, hexToBytes, utf8ToBytes } from 'ethereum-cryptography/utils' +import { bytesToHex, equalsBytes, hexToBytes, utf8ToBytes } from '@ethereumjs/util' import { BranchNode, ExtensionNode, LeafNode } from '../node/index.js' import { Trie } from '../trie.js' diff --git a/packages/trie/examples/walkDemo.ts b/packages/trie/scripts/walkDemo.ts similarity index 100% rename from packages/trie/examples/walkDemo.ts rename to packages/trie/scripts/walkDemo.ts diff --git a/packages/trie/src/util/asyncWalk.ts b/packages/trie/src/util/asyncWalk.ts index f23cc33fc05..20743021939 100644 --- a/packages/trie/src/util/asyncWalk.ts +++ b/packages/trie/src/util/asyncWalk.ts @@ -1,5 +1,7 @@ import { RLP } from '@ethereumjs/rlp' -import { equalsBytes, toHex } from 'ethereum-cryptography/utils' +import { equalsBytes } from '@ethereumjs/util' +// TODO: replace with bytesToHex from @ethereumjs/util +import { toHex } from 'ethereum-cryptography/utils.js' // eslint-disable-line import { BranchNode } from '../node/branch.js' import { ExtensionNode } from '../node/extension.js' diff --git a/packages/trie/test/util/log.spec.ts b/packages/trie/test/util/log.spec.ts index a5c4b801f09..bb58340d2b6 100644 --- a/packages/trie/test/util/log.spec.ts +++ b/packages/trie/test/util/log.spec.ts @@ -1,4 +1,4 @@ -import { utf8ToBytes } from 'ethereum-cryptography/utils' +import { utf8ToBytes } from '@ethereumjs/util' import { assert, describe, it } from 'vitest' import { Trie } from '../../src/trie.js' diff --git a/packages/tx/package.json b/packages/tx/package.json index d1ec3b52390..014e7019ea6 100644 --- a/packages/tx/package.json +++ b/packages/tx/package.json @@ -27,7 +27,7 @@ "hireable": true } ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/util/package.json b/packages/util/package.json index 3d0906d6215..2be8921aaa0 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -61,7 +61,7 @@ "url": "https://github.com/asinyagin" } ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/verkle/package.json b/packages/verkle/package.json index 84a04bc501f..1cc3b7ab1f4 100644 --- a/packages/verkle/package.json +++ b/packages/verkle/package.json @@ -24,8 +24,8 @@ "url": "https://github.com/gabrocheleau" } ], + "type": "module", "main": "dist/cjs/index.js", - "type": "commonjs", "module": "dist/esm/index.js", "exports": { ".": { diff --git a/packages/vm/benchmarks/mainnetBlocks.ts b/packages/vm/benchmarks/mainnetBlocks.ts index 64f19b464d0..6bb4e335a96 100644 --- a/packages/vm/benchmarks/mainnetBlocks.ts +++ b/packages/vm/benchmarks/mainnetBlocks.ts @@ -2,8 +2,8 @@ import { readFileSync } from 'fs' import Benchmark from 'benchmark' import { Chain, Common, Hardfork } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' -import { VM } from '../dist/cjs' -import { getPreState, getBlockchain, verifyResult } from './util' +import { VM } from '@ethereumjs/vm' +import { getPreState, getBlockchain, verifyResult } from './util.js' const BLOCK_FIXTURE = 'benchmarks/fixture/blocks-prestate.json' diff --git a/packages/vm/benchmarks/run.ts b/packages/vm/benchmarks/run.ts index 84590b3918f..3ed25d1a8ae 100644 --- a/packages/vm/benchmarks/run.ts +++ b/packages/vm/benchmarks/run.ts @@ -1,6 +1,6 @@ import Benchmark from 'benchmark' -import { BenchmarksType } from './util' -import { mainnetBlocks } from './mainnetBlocks' +import { BenchmarksType } from './util.js' +import { mainnetBlocks } from './mainnetBlocks.js' // Add an import and a BENCHMARKS entry to list a new benchmark const BENCHMARKS: BenchmarksType = { diff --git a/packages/vm/benchmarks/util.ts b/packages/vm/benchmarks/util.ts index 4eb20c7bce9..460f29ce30e 100644 --- a/packages/vm/benchmarks/util.ts +++ b/packages/vm/benchmarks/util.ts @@ -11,8 +11,8 @@ import { import { Common } from '@ethereumjs/common' import { Block } from '@ethereumjs/block' import { DefaultStateManager } from '@ethereumjs/statemanager' -import { RunBlockResult } from '../dist/cjs/types' -import { Mockchain } from './mockchain' +import { RunBlockResult } from '@ethereumjs/vm' +import { Mockchain } from './mockchain.js' export interface BenchmarkType { [key: string]: Function diff --git a/packages/vm/examples/buildBlock.ts b/packages/vm/examples/buildBlock.ts index 3be0f55ed96..170a5cde9f0 100644 --- a/packages/vm/examples/buildBlock.ts +++ b/packages/vm/examples/buildBlock.ts @@ -1,7 +1,7 @@ import { Block } from '@ethereumjs/block' -import { Chain, Common, Hardfork } from '@ethereumjs/common' +import { Chain, Common } from '@ethereumjs/common' import { LegacyTransaction } from '@ethereumjs/tx' -import { Account, Address, bytesToHex, hexToBytes, randomBytes } from '@ethereumjs/util' +import { Account, Address, bytesToHex, hexToBytes } from '@ethereumjs/util' import { VM } from '@ethereumjs/vm' const main = async () => { diff --git a/packages/vm/examples/helpers/account-utils.cts b/packages/vm/examples/helpers/account-utils.ts similarity index 95% rename from packages/vm/examples/helpers/account-utils.cts rename to packages/vm/examples/helpers/account-utils.ts index 1957a42d747..c5db9a3c3e8 100644 --- a/packages/vm/examples/helpers/account-utils.cts +++ b/packages/vm/examples/helpers/account-utils.ts @@ -1,4 +1,4 @@ -import { VM } from '../../dist/cjs/vm' +import { VM } from '@ethereumjs/vm' import { Account, Address } from '@ethereumjs/util' export const keyPair = { diff --git a/packages/vm/examples/helpers/tx-builder.cts b/packages/vm/examples/helpers/tx-builder.ts similarity index 76% rename from packages/vm/examples/helpers/tx-builder.cts rename to packages/vm/examples/helpers/tx-builder.ts index 27748af4e2c..b00be99f7b7 100644 --- a/packages/vm/examples/helpers/tx-builder.cts +++ b/packages/vm/examples/helpers/tx-builder.ts @@ -1,7 +1,5 @@ import { Interface, defaultAbiCoder as AbiCoder } from '@ethersproject/abi' -import { AccessListEIP2930TxData, FeeMarketEIP1559TxData, TxData } from '@ethereumjs/tx' - -type TransactionsData = TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData +import { LegacyTxData } from '@ethereumjs/tx' export const encodeFunction = ( method: string, @@ -33,8 +31,8 @@ export const encodeDeployment = ( return deploymentData } -export const buildTransaction = (data: Partial): TransactionsData => { - const defaultData: Partial = { +export const buildTransaction = (data: Partial): LegacyTxData => { + const defaultData: Partial = { nonce: BigInt(0), gasLimit: 2_000_000, // We assume that 2M is enough, gasPrice: 1, diff --git a/packages/vm/examples/run-blockchain.ts b/packages/vm/examples/run-blockchain.ts index 0ed588ba9a7..c708773746d 100644 --- a/packages/vm/examples/run-blockchain.ts +++ b/packages/vm/examples/run-blockchain.ts @@ -11,9 +11,9 @@ import { Block } from '@ethereumjs/block' import { Blockchain } from '@ethereumjs/blockchain' import { Common, ConsensusType } from '@ethereumjs/common' import { VM } from '@ethereumjs/vm' -//import testData from './helpers/blockchain-mock-data.json' -const testData = require('./helpers/blockchain-mock-data.json') +import testData from './helpers/blockchain-mock-data.json' + async function main() { const common = new Common({ chain: 1, hardfork: testData.network.toLowerCase() }) const validatePow = common.consensusType() === ConsensusType.ProofOfWork diff --git a/packages/vm/examples/run-solidity-contract.ts b/packages/vm/examples/run-solidity-contract.ts index 89d7acb5293..8579eb51773 100644 --- a/packages/vm/examples/run-solidity-contract.ts +++ b/packages/vm/examples/run-solidity-contract.ts @@ -1,14 +1,15 @@ -import { join } from 'path' +import path from 'path' +import { fileURLToPath } from 'url' import { readFileSync } from 'fs' import { defaultAbiCoder as AbiCoder, Interface } from '@ethersproject/abi' import { Address, bytesToHex, hexToBytes } from '@ethereumjs/util' import { Chain, Common, Hardfork } from '@ethereumjs/common' import { LegacyTransaction } from '@ethereumjs/tx' import { VM } from '@ethereumjs/vm' -import { buildTransaction, encodeDeployment, encodeFunction } from './helpers/tx-builder.cjs' -import { getAccountNonce, insertAccount } from './helpers/account-utils.cjs' +import { buildTransaction, encodeDeployment, encodeFunction } from './helpers/tx-builder.js' +import { getAccountNonce, insertAccount } from './helpers/account-utils.js' import { Block } from '@ethereumjs/block' -const solc = require('solc') +import solc from 'solc' const INITIAL_GREETING = 'Hello, World!' const SECOND_GREETING = 'Hola, Mundo!' @@ -16,6 +17,9 @@ const SECOND_GREETING = 'Hola, Mundo!' const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Istanbul }) const block = Block.fromBlockData({ header: { extraData: new Uint8Array(97) } }, { common }) +const __filename = fileURLToPath(import.meta.url) // get the resolved path to the file +const __dirname = path.dirname(__filename) // get the name of the directory + /** * This function creates the input for the Solidity compiler. * @@ -30,7 +34,7 @@ function getSolcInput() { language: 'Solidity', sources: { 'helpers/Greeter.sol': { - content: readFileSync(join(__dirname, 'helpers', 'Greeter.sol'), 'utf8'), + content: readFileSync(path.join(__dirname, 'helpers', 'Greeter.sol'), 'utf8'), }, // If more contracts were to be compiled, they should have their own entries here }, @@ -101,7 +105,7 @@ async function deployContract( nonce: await getAccountNonce(vm, senderPrivateKey), } - const tx = LegacyTransaction.fromTxData(buildTransaction(txData), { common }).sign( + const tx = LegacyTransaction.fromTxData(buildTransaction(txData as any), { common }).sign( senderPrivateKey ) @@ -128,10 +132,10 @@ async function setGreeting( const txData = { to: contractAddress, data, - nonce: await getAccountNonce(vm, senderPrivateKey), + nonce: await getAccountNonce(vm as any, senderPrivateKey), } - const tx = LegacyTransaction.fromTxData(buildTransaction(txData), { common }).sign( + const tx = LegacyTransaction.fromTxData(buildTransaction(txData as any), { common }).sign( senderPrivateKey ) diff --git a/packages/vm/package.json b/packages/vm/package.json index 111df4c2427..94f2e3a3c95 100644 --- a/packages/vm/package.json +++ b/packages/vm/package.json @@ -19,7 +19,7 @@ "contributors": [ "Alex Beregszaszi " ], - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": { diff --git a/packages/vm/src/requests.ts b/packages/vm/src/requests.ts index 7141fa8c972..def8143248f 100644 --- a/packages/vm/src/requests.ts +++ b/packages/vm/src/requests.ts @@ -13,7 +13,7 @@ import { unpadBytes, } from '@ethereumjs/util' -import type { RunTxResult } from './types' +import type { RunTxResult } from './types.js' import type { VM } from './vm.js' import type { CLRequest, CLRequestType } from '@ethereumjs/util' diff --git a/packages/vm/src/runBlock.ts b/packages/vm/src/runBlock.ts index b2a43677884..8d316147876 100644 --- a/packages/vm/src/runBlock.ts +++ b/packages/vm/src/runBlock.ts @@ -44,9 +44,7 @@ import type { Common } from '@ethereumjs/common' import type { EVM, EVMInterface } from '@ethereumjs/evm' import type { CLRequest, CLRequestType, PrefixedHexString } from '@ethereumjs/util' -const { debug: createDebugLogger } = debugDefault - -const debug = createDebugLogger('vm:block') +const debug = debugDefault('vm:block') const parentBeaconBlockRootAddress = Address.fromString( '0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02' diff --git a/packages/vm/src/runTx.ts b/packages/vm/src/runTx.ts index 11c9ccc1f7b..a0306a8f138 100644 --- a/packages/vm/src/runTx.ts +++ b/packages/vm/src/runTx.ts @@ -43,10 +43,9 @@ import type { LegacyTransaction, TypedTransaction, } from '@ethereumjs/tx' -const { debug: createDebugLogger } = debugDefault -const debug = createDebugLogger('vm:tx') -const debugGas = createDebugLogger('vm:tx:gas') +const debug = debugDefault('vm:tx') +const debugGas = debugDefault('vm:tx:gas') let enableProfiler = false const initLabel = 'EVM journal init, address/slot warming, fee validation' diff --git a/packages/vm/src/vm.ts b/packages/vm/src/vm.ts index 39fc643f26f..e775d0c0ed3 100644 --- a/packages/vm/src/vm.ts +++ b/packages/vm/src/vm.ts @@ -20,8 +20,7 @@ import type { } from './types.js' import type { BlockchainInterface } from '@ethereumjs/blockchain' import type { EVMStateManagerInterface } from '@ethereumjs/common' -import type { EVMInterface } from '@ethereumjs/evm' -import type { EVMPerformanceLogOutput } from '@ethereumjs/evm/dist/cjs/logger.js' +import type { EVMInterface, EVMPerformanceLogOutput } from '@ethereumjs/evm' import type { BigIntLike } from '@ethereumjs/util' /** diff --git a/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts b/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts index 647cf5d9a19..5570e84d4a5 100644 --- a/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts +++ b/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts @@ -5,8 +5,8 @@ import { DefaultStateManager } from '@ethereumjs/statemanager' import { Trie } from '@ethereumjs/trie' import { Account, Address, bytesToHex, equalsBytes, toBytes } from '@ethereumjs/util' -import { VM } from '../../../src/vm' -import { makeBlockFromEnv, makeTx, setupPreConditions } from '../../util' +import { VM } from '../../../src/index.js' +import { makeBlockFromEnv, makeTx, setupPreConditions } from '../../util.js' import type * as tape from 'tape' diff --git a/packages/vm/tsconfig.benchmarks.json b/packages/vm/tsconfig.benchmarks.json index ae8a7db8e29..e05b9c483fc 100644 --- a/packages/vm/tsconfig.benchmarks.json +++ b/packages/vm/tsconfig.benchmarks.json @@ -1,5 +1,5 @@ { - "extends": "../../config/tsconfig.json", + "extends": "../../config/tsconfig.prod.esm.json", "compilerOptions": { "lib": ["dom"], "sourceMap": false, diff --git a/packages/wallet/package.json b/packages/wallet/package.json index 505e23e9a66..536ed2e27b1 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -17,7 +17,7 @@ }, "license": "MIT", "author": "Alex Beregszaszi ", - "type": "commonjs", + "type": "module", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "exports": {