diff --git a/fork_choice/.pages b/fork_choice/.pages deleted file mode 100644 index a5e6ccc9046..00000000000 --- a/fork_choice/.pages +++ /dev/null @@ -1,7 +0,0 @@ -nav: - - ... - - Fork Choice -- Core: - - phase0: specs/phase0/fork-choice - - bellatrix: specs/bellatrix/fork-choice - - capella: specs/capella/fork-choice - - deneb: specs/deneb/fork-choice diff --git a/fork_choice/safe-block.md b/fork_choice/safe-block.md deleted file mode 100644 index 00f75e92ce4..00000000000 --- a/fork_choice/safe-block.md +++ /dev/null @@ -1,41 +0,0 @@ -# Fork Choice -- Safe Block - - - -- [Introduction](#introduction) -- [`get_safe_execution_block_hash`](#get_safe_execution_block_hash) - - - -## Introduction - -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. - -This section describes an algorithm to find a safe block. - -## `get_safe_execution_block_hash` - -*Note*: `retrieve_fast_confirmed_root()` is an implementation dependent function -that retrieves the most recent `confirmed_root` determined by the -[Fast Confirmation](../specs/phase0/fast-confirmation.md) algorithm. - -```python -def get_safe_execution_block_hash(store: Store) -> Hash32: - safe_block_root = retrieve_fast_confirmed_root() - safe_block = store.blocks[safe_block_root] - - 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 - 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) and -[Gloas](../specs/gloas/beacon-chain.md). diff --git a/specs/bellatrix/fast-confirmation.md b/specs/bellatrix/fast-confirmation.md new file mode 100644 index 00000000000..4bfcb939e0c --- /dev/null +++ b/specs/bellatrix/fast-confirmation.md @@ -0,0 +1,29 @@ +# Bellatrix -- Fast Confirmation + + + +- [Introduction](#introduction) +- [Safe execution block](#safe-execution-block) + - [New `get_safe_execution_block_hash`](#new-get_safe_execution_block_hash) + + + +## Introduction + +This is the modification of the fast confirmation rule specification +accompanying Bellatrix. + +## Safe execution block + +With Bellatrix introducing execution payload, `get_safe_execution_block_hash` +function is introduced. This function returns the block hash of the payload +included into the most recent confirmed block. This block hash is communicated +to ExecutionEngine as a hash of a safe block. + +### New `get_safe_execution_block_hash` + +```python +def get_safe_execution_block_hash(fcr_store: FastConfirmationStore) -> Hash32: + safe_block = fcr_store.store.blocks[fcr_store.confirmed_root] + return safe_block.body.execution_payload.block_hash +``` diff --git a/specs/bellatrix/fork-choice.md b/specs/bellatrix/fork-choice.md index ac7e1a55127..d2b884cdd54 100644 --- a/specs/bellatrix/fork-choice.md +++ b/specs/bellatrix/fork-choice.md @@ -92,7 +92,7 @@ MUST be set to the hash of a terminal PoW block in this case. ##### `safe_block_hash` The `safe_block_hash` parameter MUST be set to return value of -[`get_safe_execution_block_hash(store: Store)`](../../fork_choice/safe-block.md#get_safe_execution_block_hash) +[`get_safe_execution_block_hash(fcr_store)`](./fast-confirmation.md#get_safe_execution_block_hash) function. ##### `should_override_forkchoice_update` diff --git a/specs/gloas/fast-confirmation.md b/specs/gloas/fast-confirmation.md new file mode 100644 index 00000000000..2c50b232b7d --- /dev/null +++ b/specs/gloas/fast-confirmation.md @@ -0,0 +1,27 @@ +# Gloas -- Fast Confirmation + + + +- [Introduction](#introduction) +- [Safe execution block](#safe-execution-block) + - [Modified `get_safe_execution_block_hash`](#modified-get_safe_execution_block_hash) + + + +## Introduction + +This is the modification of the fast confirmation rule specification +accompanying Gloas. + +## Safe execution block + +### Modified `get_safe_execution_block_hash` + +*Note*: In Gloas, only the parent payload of a confirmed beacon block is safe. + +```python +def get_safe_execution_block_hash(fcr_store: FastConfirmationStore) -> Hash32: + safe_block = fcr_store.store.blocks[fcr_store.confirmed_root] + # [Modified in Gloas:EIP7732] + return safe_block.body.signed_execution_payload_bid.message.parent_block_hash +``` diff --git a/specs/gloas/fork-choice.md b/specs/gloas/fork-choice.md index c419abfc69b..11e1b540b6a 100644 --- a/specs/gloas/fork-choice.md +++ b/specs/gloas/fork-choice.md @@ -91,13 +91,16 @@ computed as the following. All other semantics of `notify_forkchoice_updated` and its invocation are inherited from prior forks. - `finalized_block_hash = finalized_block_bid.parent_block_hash`, -- `safe_block_hash = get_safe_execution_block_hash(store)`. +- `safe_block_hash = get_safe_execution_block_hash(fcr_store)`. Where: - `finalized_block = store.blocks[store.finalized_checkpoint.root]`, - `finalized_block_bid = finalized_block.body.signed_execution_payload_bid.message`. +*Note*: `get_safe_execution_block_hash` is modified in Gloas, see +[Fast Confirmation](./fast-confirmation.md#get_safe_execution_block_hash). + ## Helpers ### New `ForkChoiceNode`