Ethereum 2.0 Hashes – How Are Ethereum 2 Block Hashes Computed?

block-headerhashproof-of-stakerlpthe-merge

After the merge, the block hash computation has a different formula. Before that, the following data were used to compute the hash via feeding the list of hex values to an RLP encoder and hashing the encoding with Keccak.

What new headers are added to this formula?

Are the nonce and difficulty removed since they have no relevance?

block_header = [
    parent_hash, # parentHash
    uncles_hash,  # ommersHash
    coinbase_lower, #beneficiary
    state_root, # stateRoot
    transactions_root, # transactionsRoot
    receipts_root, # receiptsRoot
    bloom, #logsBloom
    difficulty_hex, # difficulty
    number_hex, # number
    gas_limit_hex, # gasLimit
    gas_used_hex, # gasUsed
    timestamp_hex, # timestamp
    extra_data, # extraData
    mix_hash, # mixHash
    nonce, # nonce
    base_fee_per_gas,
]

rlp_encoded = rlp.encode(block_header)

block_hash = web3.keccak(rlp_encoded).hex()

Best Answer

According to EIP-3675, with the transition to Proof of Stake:

Each block field listed in the table below MUST be replaced with the corresponding constant value

Field Constant value Comment
ommersHash 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 = Keccak256(RLP([]))
difficulty 0
mixHash 0x0000000000000000000000000000000000000000000000000000000000000000
nonce 0x0000000000000000

difficulty should be represented as 0x when fed into the RLP encoder.

The EIP does not specify any new block (header) fields.

Related Topic