Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dist/

.pytest_cache
.mypy_cache
.ruff_cache

# Dynamically built from Markdown spec
tests/core/pyspec/eth_consensus_specs/phase0/
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,15 @@ test: _pyspec
###############################################################################

DOCS_DIR = ./docs
FORK_CHOICE_DIR = ./fork_choice
SPEC_DIR = ./specs
SSZ_DIR = ./ssz
SYNC_DIR = ./sync

# Copy files to the docs directory.
_copy_docs:
@cp -r $(SPEC_DIR) $(DOCS_DIR)
@rm -rf $(DOCS_DIR)/specs/_deprecated
@cp -r $(SYNC_DIR) $(DOCS_DIR)
@cp -r $(SSZ_DIR) $(DOCS_DIR)
@cp -r $(FORK_CHOICE_DIR) $(DOCS_DIR)
@cp $(CURDIR)/README.md $(DOCS_DIR)/README.md

# Start a local documentation server.
Expand Down
7 changes: 0 additions & 7 deletions fork_choice/.pages

This file was deleted.

41 changes: 0 additions & 41 deletions fork_choice/safe-block.md

This file was deleted.

32 changes: 32 additions & 0 deletions specs/bellatrix/safe-block.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Bellatrix -- Safe Block

<!-- mdformat-toc start --slug=github --no-anchors --maxlevel=6 --minlevel=2 -->

- [Introduction](#introduction)
- [Helpers](#helpers)
- [New `get_safe_execution_block_hash`](#new-get_safe_execution_block_hash)

<!-- mdformat-toc end -->

## Introduction

This document describes an algorithm to find a safe block. Under honest majority
and certain network synchronicity assumptions there exists 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.

## Helpers

### New `get_safe_execution_block_hash`

```python
def get_safe_execution_block_hash(fcr_store: FastConfirmationStore) -> Hash32:
safe_block_root = fcr_store.confirmed_root
safe_block = fcr_store.store.blocks[safe_block_root]

if compute_epoch_at_slot(safe_block.slot) >= BELLATRIX_FORK_EPOCH:
return safe_block.body.execution_payload.block_hash
else:
# No safe block is available yet
return Hash32()
```
41 changes: 41 additions & 0 deletions specs/gloas/safe-block.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Gloas -- Safe Block

<!-- mdformat-toc start --slug=github --no-anchors --maxlevel=6 --minlevel=2 -->

- [Introduction](#introduction)
- [Helpers](#helpers)
- [Modified `get_safe_execution_block_hash`](#modified-get_safe_execution_block_hash)

<!-- mdformat-toc end -->

## Introduction

This document is an extension of
[Bellatrix -- Safe Block](../bellatrix/safe-block.md). All behaviors and
definitions defined in this document, and documents it extends, carry over
unless explicitly noted or overridden.

This document describes an algorithm to find a safe block. Under honest majority
and certain network synchronicity assumptions there exists 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.

## Helpers

### Modified `get_safe_execution_block_hash`

```python
def get_safe_execution_block_hash(fcr_store: FastConfirmationStore) -> Hash32:
safe_block_root = fcr_store.confirmed_root
safe_block = fcr_store.store.blocks[safe_block_root]

# [Modified in Gloas]
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
elif compute_epoch_at_slot(safe_block.slot) >= BELLATRIX_FORK_EPOCH:
return safe_block.body.execution_payload.block_hash
else:
# No safe block is available yet
return Hash32()
```