From ac3d8939a874fa0618a39005f4bc115bc755fcaf Mon Sep 17 00:00:00 2001 From: henridf Date: Mon, 26 Jun 2023 18:05:02 +0200 Subject: [PATCH] Add Deneb handling to state_transition.makeBeaconBlock() (#5118) * Add Deneb handling to state_transition.makeBeaconBlock() * review feedback --- beacon_chain/spec/state_transition.nim | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/beacon_chain/spec/state_transition.nim b/beacon_chain/spec/state_transition.nim index eca8ebc5c..ef4ab0fbd 100644 --- a/beacon_chain/spec/state_transition.nim +++ b/beacon_chain/spec/state_transition.nim @@ -572,8 +572,28 @@ proc makeBeaconBlock*( hash_tree_root(sync_aggregate), execution_payload_root.get, hash_tree_root(validator_changes.bls_to_execution_changes)]) - elif consensusFork > ConsensusFork.Capella: - discard denebImplementationMissing + elif consensusFork == ConsensusFork.Deneb: + when executionPayload is deneb.ExecutionPayloadForSigning: + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#beaconblockbody + forkyState.data.latest_block_header.body_root = hash_tree_root( + [hash_tree_root(randao_reveal), + hash_tree_root(eth1_data), + hash_tree_root(graffiti), + hash_tree_root(validator_changes.proposer_slashings), + hash_tree_root(validator_changes.attester_slashings), + hash_tree_root(List[Attestation, Limit MAX_ATTESTATIONS](attestations)), + hash_tree_root(List[Deposit, Limit MAX_DEPOSITS](deposits)), + hash_tree_root(validator_changes.voluntary_exits), + hash_tree_root(sync_aggregate), + execution_payload_root.get, + hash_tree_root(validator_changes.bls_to_execution_changes), + hash_tree_root(executionPayload.kzgs) + ]) + else: + raiseAssert "Attempt to use non-Deneb payload with post-Deneb state" + else: + static: raiseAssert "Unreachable" + state.`kind Data`.root = hash_tree_root(state.`kind Data`.data) blck.`kind Data`.state_root = state.`kind Data`.root