From 055c9fb5039a833581a4930fbf178b93155443ca Mon Sep 17 00:00:00 2001 From: harkamal Date: Fri, 18 Nov 2022 21:22:35 +0530 Subject: [PATCH] exclude genesis block from consensus validations --- packages/block/src/header.ts | 5 ++++- packages/evm/src/evm.ts | 1 + packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/block/src/header.ts b/packages/block/src/header.ts index 839c6a2f064..edd26528127 100644 --- a/packages/block/src/header.ts +++ b/packages/block/src/header.ts @@ -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) { diff --git a/packages/evm/src/evm.ts b/packages/evm/src/evm.ts index 8b6b50b01bc..45f9507c614 100644 --- a/packages/evm/src/evm.ts +++ b/packages/evm/src/evm.ts @@ -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( diff --git a/packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts b/packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts index e280324f5b2..a1555ff21d7 100644 --- a/packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts +++ b/packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts @@ -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,