2021-12-05 23:07:54 +00:00
# Optimistic Sync
2022-07-27 16:48:36 +00:00
## 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 )
- [Constants ](#constants )
- [Helpers ](#helpers )
- [Mechanisms ](#mechanisms )
- [When to optimistically import blocks ](#when-to-optimistically-import-blocks )
- [How to optimistically import blocks ](#how-to-optimistically-import-blocks )
- [How to apply `latestValidHash` when payload status is `INVALID` ](#how-to-apply-latestvalidhash-when-payload-status-is-invalid )
- [Execution Engine Errors ](#execution-engine-errors )
- [Assumptions about Execution Engine Behaviour ](#assumptions-about-execution-engine-behaviour )
- [Re-Orgs ](#re-orgs )
- [Fork Choice ](#fork-choice )
- [Fork Choice Poisoning ](#fork-choice-poisoning )
- [Checkpoint Sync (Weak Subjectivity Sync) ](#checkpoint-sync-weak-subjectivity-sync )
- [Validator assignments ](#validator-assignments )
- [Block Production ](#block-production )
- [Attesting ](#attesting )
- [Participating in Sync Committees ](#participating-in-sync-committees )
- [Ethereum Beacon APIs ](#ethereum-beacon-apis )
- [Design Decision Rationale ](#design-decision-rationale )
2022-08-09 14:00:00 +00:00
- [Why sync optimistically? ](#why-sync-optimistically )
2022-07-27 16:48:36 +00:00
- [Why `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY`? ](#why-safe_slots_to_import_optimistically )
- [Transitioning from VALID -> INVALIDATED or INVALIDATED -> VALID ](#transitioning-from-valid---invalidated-or-invalidated---valid )
- [What about Light Clients? ](#what-about-light-clients )
- [What if `TERMINAL_BLOCK_HASH` is used? ](#what-if-terminal_block_hash-is-used )
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- /TOC -->
2021-12-05 23:07:54 +00:00
## Introduction
2021-12-13 06:09:09 +00:00
In order to provide a syncing execution engine with a partial view of the head
of the chain, it may be desirable for a consensus engine to import beacon
blocks without verifying the execution payloads. This partial sync is called an
*optimistic sync*.
2021-12-05 23:07:54 +00:00
2022-01-18 00:28:08 +00:00
Optimistic sync is designed to be opt-in and backwards compatible (i.e.,
non-optimistic nodes can tolerate optimistic nodes on the network and vice
versa). Optimistic sync is not a fundamental requirement for consensus nodes.
Rather, it's a stop-gap measure to allow execution nodes to sync via
established methods until future Ethereum roadmap items are implemented (e.g.,
statelessness).
2021-12-19 03:44:21 +00:00
## Constants
|Name|Value|Unit
|---|---|---|
2021-12-21 05:49:43 +00:00
|`SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY`| `128` | slots
2021-12-19 23:15:51 +00:00
*Note: the `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` must be user-configurable. See
2021-12-19 23:32:45 +00:00
[Fork Choice Poisoning ](#fork-choice-poisoning ).*
2021-12-19 03:44:21 +00:00
## Helpers
2022-01-27 22:45:08 +00:00
For brevity, we define two aliases for values of the `status` field on
`PayloadStatusV1` :
- Alias `NOT_VALIDATED` to:
- `SYNCING`
- `ACCEPTED`
- Alias `INVALIDATED` to:
- `INVALID`
- `INVALID_BLOCK_HASH`
2022-01-12 20:17:43 +00:00
Let `head: BeaconBlock` be the result of calling of the fork choice
2022-01-12 20:23:12 +00:00
algorithm at the time of block production. Let `head_block_root: Root` be the
root of that block.
2021-12-20 06:46:42 +00:00
2022-01-12 20:23:12 +00:00
Let `blocks: Dict[Root, BeaconBlock]` and `block_states: Dict[Root,
BeaconState]` be the blocks (and accompanying states) that have been verified
either completely or optimistically.
2021-12-19 23:41:50 +00:00
2022-01-12 04:57:27 +00:00
Let `optimistic_roots: Set[Root]` be the set of `hash_tree_root(block)` for all
2022-01-27 22:45:08 +00:00
optimistically imported blocks which have only received a `NOT_VALIDATED` designation
from an execution engine (i.e., they are not known to be `INVALIDATED` or `VALID` ).
2022-01-12 04:57:27 +00:00
2022-01-18 01:26:30 +00:00
Let `current_slot: Slot` be `(time - genesis_time) // SECONDS_PER_SLOT` where
`time` is the UNIX time according to the local system clock.
2021-12-19 03:44:21 +00:00
```python
2022-01-12 04:54:11 +00:00
@dataclass
2022-01-18 00:30:28 +00:00
class OptimisticStore(object):
2022-01-12 04:54:11 +00:00
optimistic_roots: Set[Root]
head_block_root: Root
2022-08-15 17:22:19 +00:00
blocks: Dict[Root, BeaconBlock] = field(default_factory=dict)
block_states: Dict[Root, BeaconState] = field(default_factory=dict)
2021-12-19 03:44:21 +00:00
```
```python
2022-01-18 00:30:28 +00:00
def is_optimistic(opt_store: OptimisticStore, block: BeaconBlock) -> bool:
return hash_tree_root(block) in opt_store.optimistic_roots
2022-01-12 04:54:11 +00:00
```
```python
2022-01-18 00:30:28 +00:00
def latest_verified_ancestor(opt_store: OptimisticStore, block: BeaconBlock) -> BeaconBlock:
2022-01-27 22:45:08 +00:00
# It is assumed that the `block` parameter is never an INVALIDATED block.
2021-12-19 03:44:21 +00:00
while True:
2022-01-18 00:30:28 +00:00
if not is_optimistic(opt_store, block) or block.parent_root == Root():
2022-01-11 05:42:20 +00:00
return block
2022-01-18 00:30:28 +00:00
block = opt_store.blocks[block.parent_root]
2021-12-19 03:44:21 +00:00
```
```python
2022-01-20 16:25:02 +00:00
def is_execution_block(block: BeaconBlock) -> bool:
2022-01-11 05:42:20 +00:00
return block.body.execution_payload != ExecutionPayload()
2021-12-19 03:44:21 +00:00
```
2021-12-19 03:56:46 +00:00
```python
2022-01-18 01:29:20 +00:00
def is_optimistic_candidate_block(opt_store: OptimisticStore, current_slot: Slot, block: BeaconBlock) -> bool:
2022-03-01 07:46:39 +00:00
if is_execution_block(opt_store.blocks[block.parent_root]):
return True
2022-03-01 07:34:53 +00:00
2022-03-01 07:46:39 +00:00
if block.slot + SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY < = current_slot:
return True
2022-03-01 07:34:53 +00:00
2022-03-01 07:46:39 +00:00
return False
2021-12-19 03:56:46 +00:00
```
2022-08-15 14:34:51 +00:00
Let a node be an *optimistic node* if its fork choice is in one of the following states:
1. `is_optimistic(opt_store, head) is True`
2. Blocks from every viable (with respect to FFG) branch have transitioned from `NOT_VALIDATED` to `INVALIDATED`
leaving the block tree without viable branches
Let only a validator on an optimistic node be an *optimistic validator* .
2021-12-19 03:44:21 +00:00
When this specification only defines behaviour for an optimistic
node/validator, but *not* for the non-optimistic case, assume default
behaviours without regard for optimistic sync.
2021-12-05 23:07:54 +00:00
## Mechanisms
2022-01-11 05:42:20 +00:00
### When to optimistically import blocks
2021-12-19 03:44:21 +00:00
2022-01-12 20:17:57 +00:00
A block MAY be optimistically imported when
2022-03-01 07:34:53 +00:00
`is_optimistic_candidate_block(opt_store, current_slot, block)` returns `True` .
This ensures that blocks are only optimistically imported if one or more of the
following are true:
2022-01-12 20:17:57 +00:00
2022-03-01 07:34:53 +00:00
1. The parent of the block has execution enabled.
2022-11-13 07:36:34 +00:00
2. The current slot (as per the system clock) is at least
2022-01-12 20:17:57 +00:00
`SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` ahead of the slot of the block being
imported.
2021-12-19 03:44:21 +00:00
2022-03-01 07:34:53 +00:00
In effect, there are restrictions on when a *merge block* can be optimistically
imported. The merge block is the first block in any chain where
2022-03-02 08:03:06 +00:00
`is_execution_block(block) == True` . Any descendant of a merge block may be
imported optimistically at any time.
2022-03-01 07:34:53 +00:00
2021-12-19 23:32:45 +00:00
*See [Fork Choice Poisoning ](#fork-choice-poisoning ) for the motivations behind
these conditions.*
2022-01-11 05:42:20 +00:00
### How to optimistically import blocks
2021-12-19 03:44:21 +00:00
To optimistically import a block:
2021-12-05 23:07:54 +00:00
2023-05-24 03:12:03 +00:00
- The [`verify_and_notify_new_payload` ](../specs/bellatrix/beacon-chain.md#verify_and_notify_new_payload ) function MUST return `True` if the execution
2022-01-27 22:45:08 +00:00
engine returns `NOT_VALIDATED` or `VALID` . An `INVALIDATED` response MUST return `False` .
2022-01-20 16:25:02 +00:00
- The [`validate_merge_block` ](../specs/bellatrix/fork-choice.md#validate_merge_block )
function MUST NOT raise an assertion if both the
2021-12-20 06:55:10 +00:00
`pow_block` and `pow_parent` are unknown to the execution engine.
2022-01-20 16:25:02 +00:00
- All other assertions in [`validate_merge_block` ](../specs/bellatrix/fork-choice.md#validate_merge_block )
(e.g., `TERMINAL_BLOCK_HASH` ) MUST prevent an optimistic import.
2022-01-27 22:45:08 +00:00
- The parent of the block MUST NOT have an `INVALIDATED` execution payload.
2021-12-05 23:07:54 +00:00
2022-01-18 00:32:47 +00:00
In addition to this change in validation, the consensus engine MUST track which
2022-01-27 22:45:08 +00:00
blocks returned `NOT_VALIDATED` and which returned `VALID` for subsequent processing.
2021-12-05 23:07:54 +00:00
2021-12-20 00:12:11 +00:00
Optimistically imported blocks MUST pass all verifications included in
2023-05-24 03:12:03 +00:00
`process_block` (withstanding the modifications to `verify_and_notify_new_payload` ).
2021-12-14 05:21:30 +00:00
2021-12-05 23:07:54 +00:00
A consensus engine MUST be able to retrospectively (i.e., after import) modify
2022-01-27 22:45:08 +00:00
the status of `NOT_VALIDATED` blocks to be either `VALID` or `INVALIDATED` based upon responses
2021-12-05 23:07:54 +00:00
from an execution engine. I.e., perform the following transitions:
2022-01-27 22:45:08 +00:00
- `NOT_VALIDATED` -> `VALID`
- `NOT_VALIDATED` -> `INVALIDATED`
2021-12-05 23:07:54 +00:00
2022-01-27 22:45:08 +00:00
When a block transitions from `NOT_VALIDATED` -> `VALID` , all *ancestors* of the
block MUST also transition from `NOT_VALIDATED` -> `VALID` . Such a block and any previously `NOT_VALIDATED` ancestors are no longer
2021-12-20 00:12:11 +00:00
considered "optimistically imported".
2021-12-05 23:07:54 +00:00
2022-01-27 22:45:08 +00:00
When a block transitions from `NOT_VALIDATED` -> `INVALIDATED` , all *descendants* of the
block MUST also transition from `NOT_VALIDATED` -> `INVALIDATED` .
2021-12-13 06:09:09 +00:00
2022-01-27 22:45:08 +00:00
When a block transitions from the `NOT_VALIDATED` state, it is removed from the set of
2022-01-18 00:30:28 +00:00
`opt_store.optimistic_roots` .
2021-12-13 06:09:09 +00:00
2022-01-17 22:30:01 +00:00
When a "merge block" (i.e. the first block which enables execution in a chain) is declared to be
2022-01-12 05:39:43 +00:00
`VALID` by an execution engine (either directly or indirectly), the full
2022-01-20 16:25:02 +00:00
[`validate_merge_block` ](../specs/bellatrix/fork-choice.md#validate_merge_block )
MUST be run against the merge block. If the block
fails [`validate_merge_block` ](../specs/bellatrix/fork-choice.md#validate_merge_block ),
the merge block MUST be treated the same as
2022-01-27 22:45:08 +00:00
an `INVALIDATED` block (i.e., it and all its descendants are invalidated and
2022-01-12 05:39:43 +00:00
removed from the block tree).
2022-07-27 10:10:46 +00:00
### How to apply `latestValidHash` when payload status is `INVALID`
2022-08-01 15:26:18 +00:00
Processing an `INVALID` payload status depends on the `latestValidHash` parameter.
2022-07-27 10:10:46 +00:00
The general approach is as follows:
2022-08-01 15:26:18 +00:00
1. Consensus engine MUST identify `invalidBlock` as per definition in the table below.
2. `invalidBlock` and all of its descendants MUST be transitioned from `NOT_VALIDATED` to `INVALIDATED` .
2022-07-27 10:10:46 +00:00
| `latestValidHash` | `invalidBlock` |
|:- |:- |
2022-08-01 15:26:18 +00:00
| Execution block hash | The *child* of a block with `body.execution_payload.block_hash == latestValidHash` in the chain containing the block with payload in question |
2022-07-27 10:10:46 +00:00
| `0x00..00` (all zeroes) | The first block with `body.execution_payload != ExecutionPayload()` in the chain containing a block with payload in question |
| `null` | Block with payload in question |
When `latestValidHash` is a meaningful execution block hash but consensus engine
2022-08-01 15:26:18 +00:00
cannot find a block satisfying `body.execution_payload.block_hash == latestValidHash` ,
2022-07-27 10:10:46 +00:00
consensus engine SHOULD behave the same as if `latestValidHash` was `null` .
2021-12-14 04:51:15 +00:00
### Execution Engine Errors
2021-12-19 03:34:43 +00:00
2021-12-20 00:12:11 +00:00
When an execution engine returns an error or fails to respond to a payload
2021-12-20 07:32:47 +00:00
validity request for some block, a consensus engine:
2021-12-20 00:12:11 +00:00
- MUST NOT optimistically import the block.
2021-12-20 03:04:33 +00:00
- MUST NOT apply the block to the fork choice store.
2021-12-20 00:12:11 +00:00
- MAY queue the block for later processing.
2021-12-13 06:09:09 +00:00
2021-12-14 04:44:15 +00:00
### Assumptions about Execution Engine Behaviour
2022-01-27 22:45:08 +00:00
This specification assumes execution engines will only return `NOT_VALIDATED` when
there is insufficient information available to make a `VALID` or `INVALIDATED`
2021-12-14 04:44:15 +00:00
determination on the given `ExecutionPayload` (e.g., the parent payload is
2022-01-27 22:45:08 +00:00
unknown). Specifically, `NOT_VALIDATED` responses should be fork-specific, in that
the search for a block on one chain MUST NOT trigger a `NOT_VALIDATED` response for
2021-12-20 06:46:42 +00:00
another chain.
2021-12-14 04:44:15 +00:00
2021-12-14 05:42:35 +00:00
### Re-Orgs
The consensus engine MUST support any chain reorganisation which does *not*
2022-01-18 00:36:36 +00:00
affect the justified checkpoint.
2021-12-14 05:42:35 +00:00
2022-01-27 22:45:08 +00:00
If the justified checkpoint transitions from `NOT_VALIDATED` -> `INVALIDATED` , a
2021-12-14 05:42:35 +00:00
consensus engine MAY choose to alert the user and force the application to
exit.
2021-12-19 23:32:45 +00:00
## Fork Choice
2021-12-20 06:46:42 +00:00
Consensus engines MUST support removing blocks from fork choice that transition
2022-01-27 22:45:08 +00:00
from `NOT_VALIDATED` to `INVALIDATED` . Specifically, a block deemed `INVALIDATED` at any
2021-12-19 23:32:45 +00:00
point MUST NOT be included in the canonical chain and the weights from those
2022-01-27 22:45:08 +00:00
`INVALIDATED` blocks MUST NOT be applied to any `VALID` or `NOT_VALIDATED` ancestors.
2021-12-19 23:32:45 +00:00
### Fork Choice Poisoning
2021-12-19 23:15:51 +00:00
During the merge transition it is possible for an attacker to craft a
`BeaconBlock` with an execution payload that references an
2021-12-20 06:46:42 +00:00
eternally-unavailable `body.execution_payload.parent_hash` (i.e., the parent
hash is random bytes). In rare circumstances, it is possible that an attacker
can build atop such a block to trigger justification. If an optimistic node
imports this malicious chain, that node will have a "poisoned" fork choice
store, such that the node is unable to produce a block that descends from the
head (due to the invalid chain of payloads) and the node is unable to produce a
block that forks around the head (due to the justification of the malicious
2021-12-19 23:15:51 +00:00
chain).
2022-01-12 05:10:59 +00:00
If an honest chain exists which justifies a higher epoch than the malicious
2022-01-12 19:52:07 +00:00
chain, that chain will take precedence and revive any poisoned store. Such a
chain, if imported before the malicious chain, will prevent the store from
being poisoned. Therefore, the poisoning attack is temporary if >= 2/3rds of
the network is honest and non-faulty.
2021-12-19 23:15:51 +00:00
The `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` parameter assumes that the network
will justify a honest chain within some number of slots. With this assumption,
2021-12-20 00:12:11 +00:00
it is acceptable to optimistically import transition blocks during the sync
process. Since there is an assumption that an honest chain with a higher
2021-12-19 23:15:51 +00:00
justified checkpoint exists, any fork choice poisoning will be short-lived and
resolved before that node is required to produce a block.
However, the assumption that the honest, canonical chain will always justify
within `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` slots is dubious. Therefore,
clients MUST provide the following command line flag to assist with manual
disaster recovery:
2021-12-20 00:12:11 +00:00
- `--safe-slots-to-import-optimistically` : modifies the
2021-12-19 23:15:51 +00:00
`SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` .
2021-12-14 05:10:19 +00:00
## Checkpoint Sync (Weak Subjectivity Sync)
2021-12-20 06:46:42 +00:00
A consensus engine MAY assume that the `ExecutionPayload` of a block used as an
anchor for checkpoint sync is `VALID` without necessarily providing that
payload to an execution engine.
2021-12-14 05:10:19 +00:00
2021-12-13 08:02:45 +00:00
## Validator assignments
2021-12-20 07:32:54 +00:00
An optimistic node is *not* a full node. It is unable to produce blocks, since
an execution engine cannot produce a payload upon an unknown parent. It cannot
faithfully attest to the head block of the chain, since it has not fully
verified that block.
2021-12-13 08:02:45 +00:00
2021-12-13 08:15:53 +00:00
### Block Production
2021-12-05 23:07:54 +00:00
2022-01-11 05:42:20 +00:00
An optimistic validator MUST NOT produce a block (i.e., sign across the
2021-12-20 07:32:54 +00:00
`DOMAIN_BEACON_PROPOSER` domain).
2021-12-05 23:07:54 +00:00
### Attesting
An optimistic validator MUST NOT participate in attestation (i.e., sign across the
`DOMAIN_BEACON_ATTESTER` , `DOMAIN_SELECTION_PROOF` or
2021-12-13 08:03:35 +00:00
`DOMAIN_AGGREGATE_AND_PROOF` domains).
2021-12-13 06:09:09 +00:00
### Participating in Sync Committees
An optimistic validator MUST NOT participate in sync committees (i.e., sign across the
`DOMAIN_SYNC_COMMITTEE` , `DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF` or
`DOMAIN_CONTRIBUTION_AND_PROOF` domains).
2021-12-13 08:02:45 +00:00
2021-12-20 05:21:11 +00:00
## Ethereum Beacon APIs
2021-12-13 08:25:33 +00:00
2021-12-20 05:21:11 +00:00
Consensus engines which provide an implementation of the [Ethereum Beacon
2022-05-19 15:27:51 +00:00
APIs](https://github.com/ethereum/beacon-APIs) must take care to ensure the
`execution_optimistic` value is set to `True` whenever the request references
optimistic blocks (and vice-versa).
2022-01-12 08:04:43 +00:00
## Design Decision Rationale
2022-07-28 10:21:33 +00:00
### Why sync optimistically?
2022-07-29 11:31:32 +00:00
Most execution engines use state sync as a default sync mechanism on Ethereum Mainnet
2022-07-28 10:21:33 +00:00
because executing blocks from genesis takes several weeks on commodity hardware.
2022-07-29 11:31:32 +00:00
State sync requires the knowledge of the current head of the chain to converge eventually.
2022-07-28 10:21:33 +00:00
If not constantly fed with the most recent head, state sync won't be able to complete
because the recent state soon becomes unavailable due to state trie pruning.
2022-08-02 06:25:15 +00:00
Optimistic block import (i.e. import when the execution engine *cannot* currently validate the payload)
breaks a deadlock between the execution layer sync process and importing beacon blocks
while the execution engine is syncing.
2022-07-28 10:21:33 +00:00
2022-08-02 14:04:10 +00:00
Optimistic sync is also an optimal strategy for execution engines using block execution as a default
sync mechanism (e.g. Erigon). Alternatively, a consensus engine may inform the execution engine with a payload
2022-08-09 13:49:41 +00:00
obtained from a checkpoint block, then wait until the execution layer catches up with it and proceed
2022-08-02 14:04:10 +00:00
in lock step after that. This alternative approach would keep user in limbo for several hours and
would increase time of the sync process as batch sync has more opportunities for optimisation than the lock step.
Aforementioned premises make optimistic sync a *generalized* solution for interaction between consensus and
execution engines during the sync process.
2022-07-28 10:21:33 +00:00
2022-01-12 08:04:43 +00:00
### Why `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY`?
Nodes can only import an optimistic block if their justified checkpoint is
verified or the block is older than `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` .
These restraints are applied in order to mitigate an attack where a block which
enables execution (a *transition block* ) can reference a junk parent hash. This
makes it impossible for honest nodes to build atop that block. If an attacker
exploits a nuance in fork choice `filter_block_tree` , they can, in some rare
cases, produce a junk block that out-competes all locally produced blocks for
the head. This prevents a node from producing a chain of blocks, therefore
breaking liveness.
Thankfully, if 2/3rds of validators are not poisoned, they can justify an
honest chain which will un-poison all other nodes.
Notably, this attack only exists for optimistic nodes. Nodes which fully verify
2022-01-18 01:21:34 +00:00
the transition block will reject a block with a junk parent hash. Therefore,
liveness is unaffected if a vast majority of nodes have fully synced execution
and consensus clients before and during the transition.
2022-01-12 08:04:43 +00:00
Given all of this, we can say two things:
1. **BNs which are following the head during the transition shouldn't
optimistically import the transition block.** If 1/3rd of validators
optimistically import the poison block, there will be no remaining nodes to
justify an honest chain.
2. **BNs which are syncing can optimistically import transition blocks.** In
this case a justified chain already exists blocks. The poison block would be
2023-02-16 10:02:58 +00:00
quickly reverted and would have no effect on liveness.
2022-01-12 08:04:43 +00:00
Astute readers will notice that (2) contains a glaring assumption about network
liveness. This is necessary because a node cannot feasibly ascertain that the
transition block is justified without importing that block and risking
poisoning. Therefore, we use `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` to say
something along the lines of: *"if the transition block is sufficiently old
enough, then we can just assume that block is honest or there exists an honest
justified chain to out-compete it."*
Note the use of "feasibly" in the previous paragraph. One can imagine
mechanisms to check that a block is justified before importing it. For example,
just keep processing blocks without adding them to fork choice. However, there
are still edge-cases here (e.g., when to halt and declare there was no
2022-01-12 19:56:38 +00:00
justification?) and how to mitigate implementation complexity. At this point,
2022-01-12 08:04:43 +00:00
it's important to reflect on the attack and how likely it is to happen. It
2022-01-12 19:56:38 +00:00
requires some rather contrived circumstances and it seems very unlikely to
2022-01-12 08:04:43 +00:00
occur. Therefore, we need to consider if adding complexity to avoid an
unlikely attack increases or decreases our total risk. Presently, it appears
that `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` sits in a sweet spot for this
trade-off.
2022-01-27 22:45:08 +00:00
### Transitioning from VALID -> INVALIDATED or INVALIDATED -> VALID
2022-01-12 08:04:43 +00:00
These operations are purposefully omitted. It is outside of the scope of the
specification since it's only possible with a faulty EE.
Such a scenario requires manual intervention.
2022-07-27 16:48:36 +00:00
### What about Light Clients?
2022-01-12 08:04:43 +00:00
An alternative to optimistic sync is to run a light client inside/alongside
beacon nodes that mitigates the need for optimistic sync by providing
2023-02-16 10:02:58 +00:00
tip-of-chain blocks to the execution engine. However, light clients come with
2022-01-12 08:04:43 +00:00
their own set of complexities. Relying on light clients may also restrict nodes
from syncing from genesis, if they so desire.
A notable thing about optimistic sync is that it's *optional* . Should an
implementation decide to go the light-client route, then they can just ignore
2023-02-16 10:02:58 +00:00
optimistic sync altogether.
2022-01-18 03:55:10 +00:00
2022-07-27 16:48:36 +00:00
### What if `TERMINAL_BLOCK_HASH` is used?
2022-01-18 03:55:10 +00:00
If the terminal block hash override is used (i.e., `TERMINAL_BLOCK_HASH !=
2022-01-20 16:25:02 +00:00
Hash32()`), the [`validate_merge_block` ](../specs/bellatrix/fork-choice.md#validate_merge_block )
function will deterministically
2022-01-18 03:55:10 +00:00
return `True` or `False` . Whilst it's not *technically* required
2022-01-20 16:25:02 +00:00
retrospectively call [`validate_merge_block` ](../specs/bellatrix/fork-choice.md#validate_merge_block )
on a transition block that
2022-01-18 03:55:10 +00:00
matches `TERMINAL_BLOCK_HASH` after an optimistic sync, doing so will have no
effect. For simplicity, the optimistic sync specification does not define
edge-case behaviour for when `TERMINAL_BLOCK_HASH` is used.