From ec6a754f0c8647dae59c73b2589225cb200d83dd Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 12 Apr 2024 00:08:01 -0400 Subject: [PATCH] Added prevRandao to block (#3372). --- src.ts/providers/format.ts | 3 +++ src.ts/providers/formatting.ts | 6 ++++++ src.ts/providers/provider.ts | 11 +++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src.ts/providers/format.ts b/src.ts/providers/format.ts index 36ef9828c5..c401f66e00 100644 --- a/src.ts/providers/format.ts +++ b/src.ts/providers/format.ts @@ -129,9 +129,12 @@ const _formatBlock = object({ excessBlobGas: allowNull(getBigInt, null), miner: allowNull(getAddress), + prevRandao: allowNull(formatHash, null), extraData: formatData, baseFeePerGas: allowNull(getBigInt) +}, { + prevRandao: [ "mixHash" ] }); export function formatBlock(value: any): BlockParams { diff --git a/src.ts/providers/formatting.ts b/src.ts/providers/formatting.ts index d345ff9444..ecae5937af 100644 --- a/src.ts/providers/formatting.ts +++ b/src.ts/providers/formatting.ts @@ -83,6 +83,12 @@ export interface BlockParams { */ miner: string; + /** + * The latest RANDAO mix of the post beacon state of + * the previous block. + */ + prevRandao?: null | string; + /** * Additional data the miner choose to include. */ diff --git a/src.ts/providers/provider.ts b/src.ts/providers/provider.ts index 8256505e23..10efd906f3 100644 --- a/src.ts/providers/provider.ts +++ b/src.ts/providers/provider.ts @@ -542,6 +542,12 @@ export class Block implements BlockParams, Iterable { */ readonly miner!: string; + /** + * The latest RANDAO mix of the post beacon state of + * the previous block. + */ + readonly prevRandao!: null | string; + /** * Any extra data the validator wished to include. */ @@ -592,6 +598,7 @@ export class Block implements BlockParams, Iterable { blobGasUsed: block.blobGasUsed, excessBlobGas: block.excessBlobGas, miner: block.miner, + prevRandao: getValue(block.prevRandao), extraData: block.extraData, baseFeePerGas: getValue(block.baseFeePerGas), @@ -640,7 +647,7 @@ export class Block implements BlockParams, Iterable { toJSON(): any { const { baseFeePerGas, difficulty, extraData, gasLimit, gasUsed, hash, - miner, nonce, number, parentHash, parentBeaconBlockRoot, + miner, prevRandao, nonce, number, parentHash, parentBeaconBlockRoot, stateRoot, receiptsRoot, timestamp, transactions } = this; @@ -653,7 +660,7 @@ export class Block implements BlockParams, Iterable { gasUsed: toJson(gasUsed), blobGasUsed: toJson(this.blobGasUsed), excessBlobGas: toJson(this.excessBlobGas), - hash, miner, nonce, number, parentHash, timestamp, + hash, miner, prevRandao, nonce, number, parentHash, timestamp, parentBeaconBlockRoot, stateRoot, receiptsRoot, transactions, };