From e49685eed5cc2c4f95b83798a6e90650f60d837b Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 19 Dec 2021 14:56:46 +1100 Subject: [PATCH] Add section for enabling opt sync --- sync/optimistic.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sync/optimistic.md b/sync/optimistic.md index d633f25ac..ff249dcbf 100644 --- a/sync/optimistic.md +++ b/sync/optimistic.md @@ -37,6 +37,11 @@ def is_execution_block(block: BeaconBlock) -> BeaconBlock: block.execution_payload != ExecutionPayload() ``` +```python +def should_optimistically_import_block(current_slot: Slot, block: BeaconBlock) -> bool: + block.slot + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY <= current_slot +``` + Let only a node which returns `is_optimistic(head) == True` be an *optimistic node*. Let only a validator on an optimistic node be an *optimistic validator*. @@ -48,7 +53,13 @@ behaviours without regard for optimistic sync. ## When to optimistically import blocks -TODO +A block MUST NOT be optimistically imported, unless either of the following +conditions are met: + +1. The justified checkpoint has execution enabled. I.e., + `is_execution_block(get_block(get_state(head_block).finalized_checkpoint.root))` +1. The current slot (as per the system clock) is at least `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` ahead of + the slot of the block being imported. I.e., `should_optimistically_import_block(current_slot) == True`. ## How to optimistically import blocks