Skip to content

Commit 37e31ab

Browse files
authored
common: GethGenesis interface (#3973)
* common: GethGenesis interface * monorepo: apply gethGenesis interface throughout monorepo * common: add pragueTime to gethGenesis * common: fix poa adjusted test case * common: minor improvements * chore: remove non null assertion * common: add typecasting note
1 parent d1c6ea7 commit 37e31ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+347
-1211
lines changed

packages/blockchain/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ For many custom chains we might come across a genesis configuration, which can b
127127
// ./examples/gethGenesis.ts
128128

129129
import { createBlockchain } from '@ethereumjs/blockchain'
130-
import { createCommonFromGethGenesis } from '@ethereumjs/common'
131-
import { bytesToHex, parseGethGenesisState } from '@ethereumjs/util'
130+
import { createCommonFromGethGenesis, parseGethGenesisState } from '@ethereumjs/common'
131+
import { bytesToHex} from '@ethereumjs/util'
132132

133133
import { postMergeGethGenesis } from './genesisData/post-merge.ts'
134134

packages/blockchain/examples/gethGenesis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createBlockchain } from '@ethereumjs/blockchain'
2-
import { createCommonFromGethGenesis } from '@ethereumjs/common'
2+
import { createCommonFromGethGenesis, parseGethGenesisState } from '@ethereumjs/common'
33
import { postMergeGethGenesis } from '@ethereumjs/testdata'
4-
import { bytesToHex, parseGethGenesisState } from '@ethereumjs/util'
4+
import { bytesToHex } from '@ethereumjs/util'
55

66
const main = async () => {
77
// Load geth genesis file

packages/blockchain/src/blockchain.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,8 @@ import { DBManager } from './db/manager.ts'
3030
import { DBTarget } from './db/operation.ts'
3131

3232
import type { HeaderData } from '@ethereumjs/block'
33-
import type { CliqueConfig } from '@ethereumjs/common'
34-
import type {
35-
BigIntLike,
36-
DB,
37-
DBObject,
38-
GenesisState,
39-
VerkleExecutionWitness,
40-
} from '@ethereumjs/util'
33+
import type { CliqueConfig, GenesisState } from '@ethereumjs/common'
34+
import type { BigIntLike, DB, DBObject, VerkleExecutionWitness } from '@ethereumjs/util'
4135
import type { Debugger } from 'debug'
4236
import type {
4337
BlockchainEvent,

packages/blockchain/src/helpers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { ChainGenesis } from '@ethereumjs/common'
22
import { genesisMPTStateRoot } from '@ethereumjs/mpt'
3-
import { type GenesisState } from '@ethereumjs/util'
43

5-
import type { Chain, Common } from '@ethereumjs/common'
4+
import type { Chain, Common, GenesisState } from '@ethereumjs/common'
65

76
/**
87
* Safe creation of a new Blockchain object awaiting the initialization function,

packages/blockchain/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Block, BlockHeader } from '@ethereumjs/block'
2-
import type { Common, ConsensusAlgorithm } from '@ethereumjs/common'
3-
import type { DB, DBObject, GenesisState } from '@ethereumjs/util'
2+
import type { Common, ConsensusAlgorithm, GenesisState } from '@ethereumjs/common'
3+
import type { DB, DBObject } from '@ethereumjs/util'
44
import type { EventEmitter } from 'eventemitter3'
55
import type { Blockchain } from './index.ts'
66

packages/blockchain/test/utils.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import { createCommonFromGethGenesis } from '@ethereumjs/common'
1+
import {
2+
type GethGenesis,
3+
createCommonFromGethGenesis,
4+
parseGethGenesisState,
5+
} from '@ethereumjs/common'
26
import { genesisMPTStateRoot } from '@ethereumjs/mpt'
37
import { postMergeGethGenesis } from '@ethereumjs/testdata'
4-
import { bytesToHex, parseGethGenesisState } from '@ethereumjs/util'
8+
import { bytesToHex } from '@ethereumjs/util'
59
import { assert, describe, it } from 'vitest'
610

711
import { createBlockchain } from '../src/index.ts'
812

913
import type { Blockchain } from '../src/blockchain.ts'
1014

11-
async function getBlockchain(gethGenesis: any): Promise<Blockchain> {
15+
async function getBlockchain(gethGenesis: GethGenesis): Promise<Blockchain> {
1216
const common = createCommonFromGethGenesis(gethGenesis, { chain: 'kiln' })
1317
const genesisState = parseGethGenesisState(gethGenesis)
1418
const blockchain = await createBlockchain({

packages/client/bin/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { generateClientConfig, getArgs } from './utils.ts'
1919
import type * as http from 'http'
2020
import type { Block, BlockBytes } from '@ethereumjs/block'
2121
import type { ConsensusDict } from '@ethereumjs/blockchain'
22-
import type { GenesisState } from '@ethereumjs/util'
22+
import type { GenesisState } from '@ethereumjs/common'
2323
import type { AbstractLevel } from 'abstract-level'
2424
import type { Server as RPCServer } from 'jayson/promise/index.js'
2525
import type { Config } from '../src/config.ts'

packages/client/bin/repl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { createInlineClient } from '../src/util/index.ts'
66
import { startRPCServers } from './startRPC.ts'
77
import { generateClientConfig, getArgs } from './utils.ts'
88

9-
import type { Common } from '@ethereumjs/common'
10-
import type { GenesisState } from '@ethereumjs/util'
9+
import type { Common, GenesisState } from '@ethereumjs/common'
1110
import type { Config } from '../src/config.ts'
1211
import type { EthereumClient } from '../src/index.ts'
1312
import type { ClientOpts } from '../src/types.ts'

packages/client/bin/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
createCommonFromGethGenesis,
1414
createCustomCommon,
1515
getPresetChainConfig,
16+
parseGethGenesisState,
1617
} from '@ethereumjs/common'
1718
import {
1819
EthereumJSErrorWithoutCode,
@@ -24,7 +25,6 @@ import {
2425
createAddressFromString,
2526
ecrecover,
2627
hexToBytes,
27-
parseGethGenesisState,
2828
randomBytes,
2929
setLengthLeft,
3030
} from '@ethereumjs/util'
@@ -52,8 +52,8 @@ import { Event } from '../src/types.ts'
5252
import { parseMultiaddrs } from '../src/util/index.ts'
5353
import { setupMetrics } from '../src/util/metrics.ts'
5454

55-
import type { CustomCrypto } from '@ethereumjs/common'
56-
import type { Address, GenesisState, PrefixedHexString } from '@ethereumjs/util'
55+
import type { CustomCrypto, GenesisState } from '@ethereumjs/common'
56+
import type { Address, PrefixedHexString } from '@ethereumjs/util'
5757
import type { Logger } from '../src/logging.ts'
5858
import type { ClientOpts } from '../src/types.ts'
5959

packages/client/src/blockchain/chain.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { Event } from '../types.ts'
88

99
import type { Block, BlockHeader } from '@ethereumjs/block'
1010
import type { Blockchain, ConsensusDict } from '@ethereumjs/blockchain'
11-
import type { DB, DBObject, GenesisState } from '@ethereumjs/util'
11+
import type { GenesisState } from '@ethereumjs/common'
12+
import type { DB, DBObject } from '@ethereumjs/util'
1213
import type { AbstractLevel } from 'abstract-level'
1314
import type { Config } from '../config.ts'
1415

0 commit comments

Comments
 (0)