Skip to content
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
7 changes: 2 additions & 5 deletions packages/client/lib/util/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,12 @@ async function createGethGenesisBlockHeader(json: any) {
* @returns genesis parameters in a `CommonOpts` compliant object
*/
async function parseGethParams(json: any) {
const { name, config, difficulty, nonce, mixHash, coinbase } = json
const { name, config, difficulty, nonce, mixHash, coinbase, baseFeePerGas } = json

let { gasLimit, extraData, baseFeePerGas, timestamp } = json
let { gasLimit, extraData, timestamp } = json

// geth stores gasLimit as a hex string while our gasLimit is a `number`
json['gasLimit'] = gasLimit = parseInt(gasLimit)
// geth assumes an initial base fee value on londonBlock=0
json['baseFeePerGas'] = baseFeePerGas =
baseFeePerGas === undefined && config.londonBlock === 0 ? 1000000000 : undefined
// geth is not strictly putting in empty fields with a 0x prefix
json['extraData'] = extraData = extraData === '' ? '0x' : extraData
// geth may use number for timestamp
Expand Down
35 changes: 35 additions & 0 deletions packages/client/test/testdata/post-merge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"config": {
"chainId":1,
"homesteadBlock":0,
"eip150Block":0,
"eip155Block":0,
"eip158Block":0,
"byzantiumBlock":0,
"constantinopleBlock":0,
"petersburgBlock":0,
"istanbulBlock":0,
"muirGlacierBlock":0,
"berlinBlock":0,
"londonBlock":0,
"clique": {
"period": 5,
"epoch": 30000
},
"terminalTotalDifficulty":0
},
"nonce":"0x42",
"timestamp":"0x0",
"extraData":"0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit":"0x1C9C380",
"difficulty":"0x400000000",
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase":"0x0000000000000000000000000000000000000000",
"alloc":{
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"balance":"0x6d6172697573766477000000"}
},
"number":"0x0",
"gasUsed":"0x0",
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas":"0x7"
}
14 changes: 14 additions & 0 deletions packages/client/test/util/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,18 @@ tape('[Util/Parse]', (t) => {
'consensus config matches'
)
})

t.test(
'should generate expected hash with london block zero and base fee per gas defined',
async (t) => {
t.plan(2)
const json = require('../testdata/post-merge.json')
const params = await parseCustomParams(json, 'post-merge')
t.equals(
params.genesis.hash,
'0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a'
)
t.equals(params.genesis.baseFeePerGas, json.baseFeePerGas)
Copy link
Member

Choose a reason for hiding this comment

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

👍

}
)
})