Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packages: add requests hash to genesis block #3771

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/blockchain/src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BIGINT_1,
BIGINT_8,
KECCAK256_RLP,
SHA256_EMPTY_RH,
Lock,
MapDB,
bigIntToHex,
Expand Down Expand Up @@ -1313,6 +1314,7 @@ export class Blockchain implements BlockchainInterface {
number: 0,
stateRoot,
withdrawalsRoot: common.isActivatedEIP(4895) ? KECCAK256_RLP : undefined,
requestsHash: common.isActivatedEIP(7685) ? SHA256_EMPTY_RH : undefined,
}
if (common.consensusType() === 'poa') {
if (common.genesis().extraData) {
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface GenesisBlockConfig {
extraData: PrefixedHexString
baseFeePerGas?: PrefixedHexString
excessBlobGas?: PrefixedHexString
requestsHash?: PrefixedHexString
}

export interface HardforkTransitionConfig {
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function parseGethParams(json: any) {
coinbase,
baseFeePerGas,
excessBlobGas,
requestsHash,
extraData: unparsedExtraData,
nonce: unparsedNonce,
timestamp: unparsedTimestamp,
Expand All @@ -50,6 +51,7 @@ function parseGethParams(json: any) {
coinbase: PrefixedHexString
baseFeePerGas: PrefixedHexString
excessBlobGas: PrefixedHexString
requestsHash: PrefixedHexString
extraData: string
nonce: string
timestamp: string
Expand Down Expand Up @@ -105,6 +107,7 @@ function parseGethParams(json: any) {
coinbase,
baseFeePerGas,
excessBlobGas,
requestsHash,
},
hardfork: undefined as string | undefined,
hardforks: [] as ConfigHardfork[],
Expand Down
5 changes: 5 additions & 0 deletions packages/util/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export const KECCAK256_RLP = hexToBytes(KECCAK256_RLP_S)

export const SHA256_NULL = sha256(new Uint8Array())

/**
* SHA-256 hash of the RLP of an empty requests hash
*/
export const SHA256_EMPTY_RH = sha256(new Uint8Array([0, 1, 2]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here would become part of the official API of the libraries and it would be hard "to get rid of it" if things change, so let's please not do this yet as long as specs are still changing and rather hardcode in blockchain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Holger, good point, I did somewhat notice this but note that the "empty requests hash" will be gone starting of devnet-5 (see: ethereum/EIPs#8989), where it is the empty sha256 hash and not this thing with encoded constants (so we can get rid of this constant!). But I agree it should not have been put in the util constants (note: this PR is not merged into master, it is merged in our devnet4 branch, so for now this is fine! 😄 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should nevertheless not forget to remove this constant 😄 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These things DO have some tendency to get forgotten, so I would still pledge to just give this a quick update now and we are done with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right, will do right away 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in dc93f8f


/**
* RLP encoded empty string
*/
Expand Down
Loading