Skip to content

Commit 5b86cc1

Browse files
acolytec3ryanio
andauthored
client: add dev param to start devnet with miner (#1492)
* client: add dev param to start ephemeral devnet with miner Co-authored-by: Ryan Ghods <[email protected]>
1 parent cf95e04 commit 5b86cc1

File tree

6 files changed

+217
-84
lines changed

6 files changed

+217
-84
lines changed

package-lock.json

Lines changed: 77 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/block/src/header.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Common, { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from '@ethereumjs/common'
1+
import Common, { Chain, ConsensusAlgorithm, ConsensusType } from '@ethereumjs/common'
22
import {
33
Address,
44
BN,
@@ -210,12 +210,11 @@ export class BlockHeader {
210210
if (options.common) {
211211
this._common = options.common.copy()
212212
} else {
213-
const chain = Chain.Mainnet // default
213+
this._common = new Common({
214+
chain: Chain.Mainnet, // default
215+
})
214216
if (options.initWithGenesisHeader) {
215-
this._common = new Common({ chain, hardfork: Hardfork.Chainstart })
216-
} else {
217-
// This initializes on the Common default hardfork
218-
this._common = new Common({ chain })
217+
this._common.setHardforkByBlockNumber(0)
219218
}
220219
}
221220

@@ -227,7 +226,7 @@ export class BlockHeader {
227226

228227
const hardforkByBlockNumber = options.hardforkByBlockNumber ?? false
229228
if (hardforkByBlockNumber || options.hardforkByTD) {
230-
this._common.setHardforkByBlockNumber(number.toNumber(), options.hardforkByTD)
229+
this._common.setHardforkByBlockNumber(number, options.hardforkByTD)
231230
}
232231

233232
if (this._common.isActivatedEIP(1559)) {

packages/blockchain/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export default class Blockchain implements BlockchainInterface {
335335

336336
if (!genesisBlock) {
337337
const common = this._common.copy()
338-
common.setHardfork(Hardfork.Chainstart)
338+
common.setHardforkByBlockNumber(0)
339339
genesisBlock = Block.genesis({}, { common })
340340
}
341341

@@ -1470,14 +1470,14 @@ export default class Blockchain implements BlockchainInterface {
14701470
const blockHash = header.hash()
14711471
const blockNumber = header.number
14721472

1473-
DBSaveLookups(blockHash, blockNumber).map((op) => {
1474-
ops.push(op)
1475-
})
1476-
14771473
if (blockNumber.isZero()) {
14781474
break
14791475
}
14801476

1477+
DBSaveLookups(blockHash, blockNumber).map((op) => {
1478+
ops.push(op)
1479+
})
1480+
14811481
// mark each key `_heads` which is currently set to the hash in the DB as
14821482
// stale to overwrite this later.
14831483
Object.keys(this._heads).forEach((name) => {

0 commit comments

Comments
 (0)