Skip to content

Commit ec6a754

Browse files
committedApr 12, 2024
Added prevRandao to block (#3372).
1 parent 501de23 commit ec6a754

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
 

‎src.ts/providers/format.ts

+3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ const _formatBlock = object({
129129
excessBlobGas: allowNull(getBigInt, null),
130130

131131
miner: allowNull(getAddress),
132+
prevRandao: allowNull(formatHash, null),
132133
extraData: formatData,
133134

134135
baseFeePerGas: allowNull(getBigInt)
136+
}, {
137+
prevRandao: [ "mixHash" ]
135138
});
136139

137140
export function formatBlock(value: any): BlockParams {

‎src.ts/providers/formatting.ts

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ export interface BlockParams {
8383
*/
8484
miner: string;
8585

86+
/**
87+
* The latest RANDAO mix of the post beacon state of
88+
* the previous block.
89+
*/
90+
prevRandao?: null | string;
91+
8692
/**
8793
* Additional data the miner choose to include.
8894
*/

‎src.ts/providers/provider.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ export class Block implements BlockParams, Iterable<string> {
542542
*/
543543
readonly miner!: string;
544544

545+
/**
546+
* The latest RANDAO mix of the post beacon state of
547+
* the previous block.
548+
*/
549+
readonly prevRandao!: null | string;
550+
545551
/**
546552
* Any extra data the validator wished to include.
547553
*/
@@ -592,6 +598,7 @@ export class Block implements BlockParams, Iterable<string> {
592598
blobGasUsed: block.blobGasUsed,
593599
excessBlobGas: block.excessBlobGas,
594600
miner: block.miner,
601+
prevRandao: getValue(block.prevRandao),
595602
extraData: block.extraData,
596603

597604
baseFeePerGas: getValue(block.baseFeePerGas),
@@ -640,7 +647,7 @@ export class Block implements BlockParams, Iterable<string> {
640647
toJSON(): any {
641648
const {
642649
baseFeePerGas, difficulty, extraData, gasLimit, gasUsed, hash,
643-
miner, nonce, number, parentHash, parentBeaconBlockRoot,
650+
miner, prevRandao, nonce, number, parentHash, parentBeaconBlockRoot,
644651
stateRoot, receiptsRoot, timestamp, transactions
645652
} = this;
646653

@@ -653,7 +660,7 @@ export class Block implements BlockParams, Iterable<string> {
653660
gasUsed: toJson(gasUsed),
654661
blobGasUsed: toJson(this.blobGasUsed),
655662
excessBlobGas: toJson(this.excessBlobGas),
656-
hash, miner, nonce, number, parentHash, timestamp,
663+
hash, miner, prevRandao, nonce, number, parentHash, timestamp,
657664
parentBeaconBlockRoot, stateRoot, receiptsRoot,
658665
transactions,
659666
};

0 commit comments

Comments
 (0)
Please sign in to comment.