Clarify names and move get_safe_block_hash to safe-block.md
This commit is contained in:
parent
c97cc6f4dc
commit
bd66114f4a
|
@ -6,7 +6,8 @@
|
||||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||||
|
|
||||||
- [Introduction](#introduction)
|
- [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)
|
||||||
|
|
||||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
<!-- /TOC -->
|
<!-- /TOC -->
|
||||||
|
@ -20,12 +21,26 @@ to expose a safe block to users.
|
||||||
|
|
||||||
This section describes an algorithm to find a safe block.
|
This section describes an algorithm to find a safe block.
|
||||||
|
|
||||||
## `get_safe_beacon_block`
|
## `get_safe_beacon_block_root`
|
||||||
|
|
||||||
```python
|
```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
|
# Use most recent justified block as a stopgap
|
||||||
return store.justified_checkpoint.root
|
return store.justified_checkpoint.root
|
||||||
```
|
```
|
||||||
*Note*: Currently safe block algorithm simply returns `store.justified_checkpoint.root`
|
*Note*: Currently safe block algorithm simply returns `store.justified_checkpoint.root`
|
||||||
and is meant to be improved in the future.
|
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()
|
||||||
|
```
|
||||||
|
|
|
@ -75,20 +75,7 @@ As per EIP-3675, before a post-transition block is finalized, `notify_forkchoice
|
||||||
|
|
||||||
##### `safe_block_hash`
|
##### `safe_block_hash`
|
||||||
|
|
||||||
The `safe_block_hash` parameter in a call to `notify_forkchoice_updated` function
|
The `safe_block_hash` parameter MUST be set to return value of `get_safe_execution_payload_hash(store: Store)` 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()
|
|
||||||
```
|
|
||||||
|
|
||||||
## Helpers
|
## Helpers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue