diff --git a/fork_choice/safe-block.md b/fork_choice/safe-block.md index 158a2b069..127002b15 100644 --- a/fork_choice/safe-block.md +++ b/fork_choice/safe-block.md @@ -6,7 +6,8 @@ - [Introduction](#introduction) -- [`get_safe_beacon_block`](#get_safe_beacon_block) +- [`get_safe_beacon_block_root`](#get_safe_beacon_block_root) +- [`get_safe_execution_payload_hash`](#get_safe_execution_payload_hash) @@ -20,12 +21,26 @@ to expose a safe block to users. This section describes an algorithm to find a safe block. -## `get_safe_beacon_block` +## `get_safe_beacon_block_root` ```python -def get_safe_beacon_block(store: Store) -> Root: +def get_safe_beacon_block_root(store: Store) -> Root: # Use most recent justified block as a stopgap return store.justified_checkpoint.root ``` *Note*: Currently safe block algorithm simply returns `store.justified_checkpoint.root` and is meant to be improved in the future. + +## `get_safe_execution_payload_hash` + +```python +def get_safe_execution_payload_hash(store: Store) -> Hash32: + safe_block_root = get_safe_beacon_block_root(store) + safe_block = store.blocks[safe_block_root] + + # Return Hash32() if no payload is yet justified + if compute_epoch_at_slot(safe_block.slot) >= BELLATRIX_FORK_EPOCH: + return safe_block.body.execution_payload.block_hash + else: + return Hash32() +``` diff --git a/specs/bellatrix/fork-choice.md b/specs/bellatrix/fork-choice.md index 05bde7e65..305d58a57 100644 --- a/specs/bellatrix/fork-choice.md +++ b/specs/bellatrix/fork-choice.md @@ -75,20 +75,7 @@ As per EIP-3675, before a post-transition block is finalized, `notify_forkchoice ##### `safe_block_hash` -The `safe_block_hash` parameter in a call to `notify_forkchoice_updated` function -MUST be set to the return value of the following function: - -```python -def get_safe_block_hash(store: Store) -> Hash32: - safe_block_root = get_safe_beacon_block(store) - safe_block = store.blocks[safe_block_root] - - # Return Hash32() if no payload is yet justified - if compute_epoch_at_slot(safe_block.slot) >= BELLATRIX_FORK_EPOCH: - return safe_block.body.execution_payload.block_hash - else: - return Hash32() -``` +The `safe_block_hash` parameter MUST be set to return value of `get_safe_execution_payload_hash(store: Store)` function. ## Helpers