Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions fork_choice/safe-block.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ def get_safe_execution_block_hash(store: Store) -> Hash32:
safe_block_root = retrieve_fast_confirmed_root()
safe_block = store.blocks[safe_block_root]

# Return Hash32() if no payload is yet justified
if compute_epoch_at_slot(safe_block.slot) >= GLOAS_FORK_EPOCH:
safe_block_bid = safe_block.body.signed_execution_payload_bid.message
return safe_block_bid.parent_block_hash

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just curious, why not safe_block_bid.block_hash?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because we yet don’t know if this payload is going to be canonical, do we?

if compute_epoch_at_slot(safe_block.slot) >= BELLATRIX_FORK_EPOCH:
return safe_block.body.execution_payload.block_hash
else:
# Return Hash32() if no safe block is yet available
return Hash32()
```

*Note*: This helper uses beacon block container extended in
[Bellatrix](../specs/bellatrix/beacon-chain.md).
[Bellatrix](../specs/bellatrix/beacon-chain.md) and
[Gloas](../specs/gloas/beacon-chain.md).
39 changes: 39 additions & 0 deletions specs/gloas/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- [Introduction](#introduction)
- [Types](#types)
- [Constants](#constants)
- [Protocols](#protocols)
- [`ExecutionEngine`](#executionengine)
- [Modified `notify_forkchoice_updated`](#modified-notify_forkchoice_updated)
- [Helpers](#helpers)
- [New `ForkChoiceNode`](#new-forkchoicenode)
- [Modified `PayloadAttributes`](#modified-payloadattributes)
Expand Down Expand Up @@ -75,6 +78,42 @@ This is the modification of the fork-choice accompanying the Gloas upgrade.
| `PTC_TIMELINESS_INDEX` | `1` |
| `NUM_BLOCK_TIMELINESS_DEADLINES` | `2` |

## Protocols

### `ExecutionEngine`

*Note*: The `notify_forkchoice_updated` function is modified in the
`ExecutionEngine` protocol at the Gloas upgrade.

#### Modified `notify_forkchoice_updated`

The only modification is the computation of the `finalized_block_hash` and
`safe_block_hash` that Consensus layer client passes to the call of this
Comment thread
jtraglia marked this conversation as resolved.
Resolved
function.
Comment thread
jtraglia marked this conversation as resolved.
Resolved

Starting with Gloas `finalized_block_hash` value **MUST** be computed as the
following. Let:

- `finalized_block = store.blocks[store.finalized_checkpoint.root]`
- `finalized_block_bid = finalized_block.body.signed_execution_payload_bid.message`

Then `finalized_block_hash = finalized_block_bid.parent_block_hash`.

*Note:* The post-Gloas `safe_block_hash` computation is handled by extending
[`get_safe_execution_block_hash(store: Store)`](../../fork_choice/safe-block.md#get_safe_execution_block_hash).

```python
def notify_forkchoice_updated(
self: ExecutionEngine,
head_block_hash: Hash32,
# [Modified in Gloas:EIP7732]
safe_block_hash: Hash32,
# [Modified in Gloas:EIP7732]
finalized_block_hash: Hash32,
payload_attributes: Optional[PayloadAttributes],
) -> Optional[PayloadId]: ...
```
Comment thread
jtraglia marked this conversation as resolved.
Resolved

## Helpers

### New `ForkChoiceNode`
Expand Down
Loading