From 8917fcc6e0557e23898d08ac8f346f02875060fc Mon Sep 17 00:00:00 2001 From: harkamal Date: Mon, 10 Jul 2023 22:13:49 +0530 Subject: [PATCH] add validation in from values array --- packages/block/src/header.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/block/src/header.ts b/packages/block/src/header.ts index a37ec906c7..0033aca0c5 100644 --- a/packages/block/src/header.ts +++ b/packages/block/src/header.ts @@ -109,7 +109,7 @@ export class BlockHeader { */ public static fromValuesArray(values: BlockHeaderBytes, opts: BlockOptions = {}) { const headerData = valuesArrayToHeaderData(values) - const { number, baseFeePerGas, excessDataGas, dataGasUsed } = headerData + const { number, baseFeePerGas, excessDataGas, dataGasUsed, parentBeaconBlockRoot } = headerData const header = BlockHeader.fromHeaderData(headerData, opts) // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (header.common.isActivatedEIP(1559) && baseFeePerGas === undefined) { @@ -127,6 +127,9 @@ export class BlockHeader { throw new Error('invalid header. dataGasUsed should be provided') } } + if (header.common.isActivatedEIP(4788) && parentBeaconBlockRoot === undefined) { + throw new Error('invalid header. parentBeaconBlockRoot should be provided') + } return header } /**