Skip to content

Commit

Permalink
exclude genesis block from consensus validations
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Nov 18, 2022
1 parent a671e21 commit 055c9fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/block/src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ export class BlockHeader {
}

// Validate consensus format after block is sealed (if applicable) so extraData checks will pass
if (skipValidateConsensusFormat === false) this._consensusFormatValidation()
// Also allow genesis to avoid consensus validations as post merge hardforks can be scheduled at
// genesis with non zero difficulty causing validation issues
if (skipValidateConsensusFormat === false && this.number !== BigInt(0))
this._consensusFormatValidation()

const freeze = options?.freeze ?? true
if (freeze) {
Expand Down
1 change: 1 addition & 0 deletions packages/evm/src/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export class EVM implements EVMInterface {
Hardfork.GrayGlacier,
Hardfork.MergeForkIdTransition,
Hardfork.Merge,
Hardfork.Shanghai,
]
if (!supportedHardforks.includes(this._common.hardfork() as Hardfork)) {
throw new Error(
Expand Down
1 change: 1 addition & 0 deletions packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ tape('EIP4895 tests', (t) => {

t.test('should build a block correctly with withdrawals', async (st) => {
const common = Common.fromGethGenesis(genesisJSON, { chain: 'custom' })
common.setHardforkByBlockNumber(0)
const genesisState = parseGethGenesisState(genesisJSON)
const blockchain = await Blockchain.create({
common,
Expand Down

0 comments on commit 055c9fb

Please sign in to comment.