|
| 1 | +# EIP7594 -- Honest Validator |
| 2 | + |
| 3 | +## Table of contents |
| 4 | + |
| 5 | +<!-- TOC --> |
| 6 | +<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
| 7 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 8 | + |
| 9 | +- [Introduction](#introduction) |
| 10 | +- [Prerequisites](#prerequisites) |
| 11 | +- [Block proposal](#block-proposal) |
| 12 | + - [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody) |
| 13 | + - [Execution payload](#execution-payload) |
| 14 | + |
| 15 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 16 | +<!-- /TOC --> |
| 17 | + |
| 18 | +## Introduction |
| 19 | + |
| 20 | +This document represents the changes to be made in the code of an "honest validator" to implement EIP7594. |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +This document is an extension of the [Electra -- Honest Validator](../electra/validator.md) guide. |
| 25 | +All behaviors and definitions defined in this document, and documents it extends, carry over unless explicitly noted or overridden. |
| 26 | + |
| 27 | +All terminology, constants, functions, and protocol mechanics defined in the updated Beacon Chain doc of [EIP7594](./beacon-chain.md) are requisite for this document and used throughout. |
| 28 | +Please see related Beacon Chain doc before continuing and use them as a reference throughout. |
| 29 | + |
| 30 | +## Block proposal |
| 31 | + |
| 32 | +### Constructing the `BeaconBlockBody` |
| 33 | + |
| 34 | +#### Execution payload |
| 35 | + |
| 36 | +`prepare_execution_payload` is updated from the Electra specs. |
| 37 | + |
| 38 | +*Note*: In this section, `state` is the state of the slot for the block proposal _without_ the block yet applied. |
| 39 | +That is, `state` is the `previous_state` processed through any empty slots up to the assigned slot using `process_slots(previous_state, slot)`. |
| 40 | + |
| 41 | +``python |
| 42 | +def prepare_execution_payload(state: BeaconState, |
| 43 | + safe_block_hash: Hash32, |
| 44 | + finalized_block_hash: Hash32, |
| 45 | + suggested_fee_recipient: ExecutionAddress, |
| 46 | + execution_engine: ExecutionEngine) -> Optional[PayloadId]: |
| 47 | + # Verify consistency of the parent hash with respect to the previous execution payload header |
| 48 | + parent_hash = state.latest_execution_payload_header.block_hash |
| 49 | + |
| 50 | + # Set the forkchoice head and initiate the payload build process |
| 51 | + withdrawals, _ = get_expected_withdrawals(state) |
| 52 | + |
| 53 | + payload_attributes = PayloadAttributes( |
| 54 | + timestamp=compute_timestamp_at_slot(state, state.slot), |
| 55 | + prev_randao=get_randao_mix(state, get_current_epoch(state)), |
| 56 | + suggested_fee_recipient=suggested_fee_recipient, |
| 57 | + withdrawals=withdrawals, |
| 58 | + parent_beacon_block_root=hash_tree_root(state.latest_block_header), |
| 59 | + target_blobs_per_block=TARGET_BLOBS_PER_BLOCK_EIP7594, # [Modified in EIP7594] |
| 60 | + max_blobs_per_block=MAX_BLOBS_PER_BLOCK_EIP7594, # [Modified in EIP7594] |
| 61 | + ) |
| 62 | + return execution_engine.notify_forkchoice_updated( |
| 63 | + head_block_hash=parent_hash, |
| 64 | + safe_block_hash=safe_block_hash, |
| 65 | + finalized_block_hash=finalized_block_hash, |
| 66 | + payload_attributes=payload_attributes, |
| 67 | + ) |
| 68 | +``` |
0 commit comments