Added prevRandao to block (#3372).

This commit is contained in:
Richard Moore 2024-04-12 00:08:01 -04:00
parent 501de23450
commit ec6a754f0c
3 changed files with 18 additions and 2 deletions

@ -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 {

@ -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.
*/

@ -542,6 +542,12 @@ export class Block implements BlockParams, Iterable<string> {
*/
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<string> {
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<string> {
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<string> {
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,
};