-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bellatrix: pass justified as a safe block #2858
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
199398c
Bellatrix: pass justified as a safe block
mkalinin d195e06
Fix toc
mkalinin 95a2327
Bellatrix: add get_safe_block_hash to validator.md
mkalinin 046eaf2
Bellatrix: remove a comment about safe head stub
mkalinin bc95973
Reorder params
mkalinin c97cc6f
Add separate get_safe_beacon_block function
mkalinin bd66114
Clarify names and move get_safe_block_hash to safe-block.md
mkalinin b13a9f0
Apply suggestions as per review
mkalinin c87fc48
minor typo
djrtwo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Fork Choice -- Safe Block | ||
|
||
## Table of contents | ||
<!-- TOC --> | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Introduction](#introduction) | ||
- [`get_safe_beacon_block`](#get_safe_beacon_block) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- /TOC --> | ||
|
||
## Introduction | ||
|
||
Under honest majority and certain network synchronicity assumptions | ||
there exist a block that is safe from re-orgs. Normally this block is | ||
pretty close to the head of canonical chain which makes it valuable | ||
to expose a safe block to users. | ||
|
||
This section describes an algorithm to find a safe block. | ||
|
||
## `get_safe_beacon_block` | ||
|
||
```python | ||
def get_safe_beacon_block(store: Store) -> Root: | ||
# Use most recent justified block as a stopgap | ||
return store.justified_checkpoint.root | ||
djrtwo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
*Note*: Currently safe block algorithm simply returns `store.justified_checkpoint.root` | ||
and is meant to be improved in the future. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
- [Protocols](#protocols) | ||
- [`ExecutionEngine`](#executionengine) | ||
- [`notify_forkchoice_updated`](#notify_forkchoice_updated) | ||
- [`safe_block_hash`](#safe_block_hash) | ||
- [Helpers](#helpers) | ||
- [`PayloadAttributes`](#payloadattributes) | ||
- [`PowBlock`](#powblock) | ||
|
@@ -72,7 +73,22 @@ As per EIP-3675, before a post-transition block is finalized, `notify_forkchoice | |
|
||
*Note*: Client software MUST call this function to initiate the payload build process to produce the merge transition block; the `head_block_hash` parameter MUST be set to the hash of a terminal PoW block in this case. | ||
|
||
*Note*: Until safe head function is implemented, `safe_block_hash` parameter MUST be stubbed with the `head_block_hash` value. | ||
##### `safe_block_hash` | ||
|
||
The `safe_block_hash` parameter in a call to `notify_forkchoice_updated` function | ||
djrtwo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MUST be set to the return value of the following function: | ||
|
||
```python | ||
def get_safe_block_hash(store: Store) -> Hash32: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should likely got in the safe_block helper file |
||
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() | ||
``` | ||
|
||
## Helpers | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this file is cross forks. Maybe note that it is only valid post-Bellatrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, safe block algorithm can be implemented with
Phase0
structures. I would add a note thatget_safe_execution_payload_hash
helper is based onBellatrix