Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo: Add missing Import File Extensions / debug Import Fixes (v8 port) #3496

Merged
merged 6 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/blockchain/src/consensus/clique.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain/src/consensus/ethash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class EthashConsensus implements Consensus {
public async genesisInit(): Promise<void> {}
public async setup({ blockchain }: ConsensusOptions): Promise<void> {
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<void> {}
}
2 changes: 1 addition & 1 deletion packages/blockchain/src/types.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
1 change: 0 additions & 1 deletion packages/blockchain/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../config/tsconfig.json",
"include": ["src/**/*.ts", "src/**/*.json", "test/**/*.ts"],
"compilerOptions": {
"types": ["node"],
"typeRoots": ["node_modules/@types"]
}
}
3 changes: 1 addition & 2 deletions packages/client/src/sync/fetcher/accountfetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -99,7 +98,7 @@ export class AccountFetcher extends Fetcher<JobTask, AccountData[], AccountData>
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,
Expand Down
5 changes: 2 additions & 3 deletions packages/client/src/sync/fetcher/bytecodefetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }

Expand Down Expand Up @@ -62,7 +61,7 @@ export class ByteCodeFetcher extends Fetcher<JobTask, Uint8Array[], Uint8Array>

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<JobTask, Uint8Array[], Uint8Array>
this.debug(
Expand Down
6 changes: 2 additions & 4 deletions packages/client/src/sync/fetcher/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debugDefault from 'debug'
import debug from 'debug'
import { Readable, Writable } from 'stream'

import { Heap } from '../../ext/qheap.js'
Expand All @@ -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
Expand Down Expand Up @@ -80,7 +78,7 @@ export abstract class Fetcher<JobTask, JobResult, StorageItem> 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
Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/sync/fetcher/storagefetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -95,7 +94,7 @@ export class StorageFetcher extends Fetcher<JobTask, StorageData[][], StorageDat
this.fetcherDoneFlags.storageFetcher.count = BigInt(this.storageRequests.length)

this.accountToHighestKnownHash = new Map<String, Uint8Array>()
this.debug = createDebugLogger('client:StorageFetcher')
this.debug = debugDefault('client:StorageFetcher')
if (this.storageRequests.length > 0) {
const fullJob = {
task: { storageRequests: this.storageRequests },
Expand Down
5 changes: 2 additions & 3 deletions packages/client/src/sync/fetcher/trienodefetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }

Expand Down Expand Up @@ -111,7 +110,7 @@ export class TrieNodeFetcher extends Fetcher<JobTask, Uint8Array[], Uint8Array>
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

Expand Down
3 changes: 1 addition & 2 deletions packages/devp2p/src/dns/dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions packages/devp2p/src/dpt/ban-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, boolean>
Expand Down
3 changes: 1 addition & 2 deletions packages/devp2p/src/dpt/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions packages/devp2p/src/dpt/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions packages/devp2p/src/protocol/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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)
}

Expand Down
3 changes: 1 addition & 2 deletions packages/devp2p/src/rlpx/ecies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions packages/devp2p/src/rlpx/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions packages/devp2p/src/rlpx/rlpx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/devp2p/src/types.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
5 changes: 2 additions & 3 deletions packages/devp2p/src/util.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
7 changes: 3 additions & 4 deletions packages/evm/src/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions packages/evm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
Log,
bn128,
} from './types.js'
export * from './logger.js'

export type {
bn128,
Expand Down
5 changes: 2 additions & 3 deletions packages/evm/src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
Expand Down
3 changes: 1 addition & 2 deletions packages/evm/src/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/src/precompiles/bls12_381/noble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/src/precompiles/bls12_381/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions packages/statemanager/src/accessWitness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions packages/statemanager/src/cache/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,7 +44,7 @@ export class AccountCache extends Cache {
}

this._diffCache.push(new Map<string, AccountCacheElement | undefined>())
this._debug = createDebugLogger('statemanager:cache:account')
this._debug = debugDefault('statemanager:cache:account')
}

_saveCachePreState(cacheKeyHex: string) {
Expand Down
3 changes: 1 addition & 2 deletions packages/statemanager/src/cache/cache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import debugDefault from 'debug'

import type { Debugger } from 'debug'
const { debug: createDebugLogger } = debugDefault

export class Cache {
_debug: Debugger
Expand Down Expand Up @@ -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')
}
}
Loading
Loading