Skip to content

Commit 7e1c382

Browse files
packages: add requests hash to genesis block (#3771)
* packages: add requests hash to genesis block. * Update packages/util/src/constants.ts Co-authored-by: Jochem Brouwer <[email protected]> * Update packages/util/src/constants.ts Co-authored-by: Jochem Brouwer <[email protected]> * packages: integrate suggestions. * Update packages/util/src/constants.ts --------- Co-authored-by: Jochem Brouwer <[email protected]>
1 parent ea935e7 commit 7e1c382

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

packages/blockchain/src/blockchain.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
BIGINT_1,
66
BIGINT_8,
77
KECCAK256_RLP,
8+
SHA256_EMPTY_RH,
89
Lock,
910
MapDB,
1011
bigIntToHex,
@@ -1313,6 +1314,7 @@ export class Blockchain implements BlockchainInterface {
13131314
number: 0,
13141315
stateRoot,
13151316
withdrawalsRoot: common.isActivatedEIP(4895) ? KECCAK256_RLP : undefined,
1317+
requestsHash: common.isActivatedEIP(7685) ? SHA256_EMPTY_RH : undefined,
13161318
}
13171319
if (common.consensusType() === 'poa') {
13181320
if (common.genesis().extraData) {

packages/common/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface GenesisBlockConfig {
5252
extraData: PrefixedHexString
5353
baseFeePerGas?: PrefixedHexString
5454
excessBlobGas?: PrefixedHexString
55+
requestsHash?: PrefixedHexString
5556
}
5657

5758
export interface HardforkTransitionConfig {

packages/common/src/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function parseGethParams(json: any) {
3838
coinbase,
3939
baseFeePerGas,
4040
excessBlobGas,
41+
requestsHash,
4142
extraData: unparsedExtraData,
4243
nonce: unparsedNonce,
4344
timestamp: unparsedTimestamp,
@@ -50,6 +51,7 @@ function parseGethParams(json: any) {
5051
coinbase: PrefixedHexString
5152
baseFeePerGas: PrefixedHexString
5253
excessBlobGas: PrefixedHexString
54+
requestsHash: PrefixedHexString
5355
extraData: string
5456
nonce: string
5557
timestamp: string
@@ -105,6 +107,7 @@ function parseGethParams(json: any) {
105107
coinbase,
106108
baseFeePerGas,
107109
excessBlobGas,
110+
requestsHash,
108111
},
109112
hardfork: undefined as string | undefined,
110113
hardforks: [] as ConfigHardfork[],

packages/util/src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export const KECCAK256_RLP = hexToBytes(KECCAK256_RLP_S)
6767

6868
export const SHA256_NULL = sha256(new Uint8Array())
6969

70+
/**
71+
* SHA-256 hash of the RLP of an empty requests hash
72+
*/
73+
export const SHA256_EMPTY_RH = sha256(new Uint8Array([0, 1, 2]))
74+
7075
/**
7176
* RLP encoded empty string
7277
*/

0 commit comments

Comments
 (0)