Add aliases
This commit is contained in:
parent
020d72c756
commit
cbbe6e744a
|
@ -25,6 +25,17 @@ statelessness).
|
||||||
|
|
||||||
## Helpers
|
## Helpers
|
||||||
|
|
||||||
|
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`
|
||||||
|
- `INVALID_TERMINAL_BLOCK`
|
||||||
|
|
||||||
Let `head: BeaconBlock` be the result of calling of the fork choice
|
Let `head: BeaconBlock` be the result of calling of the fork choice
|
||||||
algorithm at the time of block production. Let `head_block_root: Root` be the
|
algorithm at the time of block production. Let `head_block_root: Root` be the
|
||||||
root of that block.
|
root of that block.
|
||||||
|
@ -34,8 +45,8 @@ BeaconState]` be the blocks (and accompanying states) that have been verified
|
||||||
either completely or optimistically.
|
either completely or optimistically.
|
||||||
|
|
||||||
Let `optimistic_roots: Set[Root]` be the set of `hash_tree_root(block)` for all
|
Let `optimistic_roots: Set[Root]` be the set of `hash_tree_root(block)` for all
|
||||||
optimistically imported blocks which have only received a `SYNCING` designation
|
optimistically imported blocks which have only received a `NOT_VALIDATED` designation
|
||||||
from an execution engine (i.e., they are not known to be `INVALID` or `VALID`).
|
from an execution engine (i.e., they are not known to be `INVALIDATED` or `VALID`).
|
||||||
|
|
||||||
Let `current_slot: Slot` be `(time - genesis_time) // SECONDS_PER_SLOT` where
|
Let `current_slot: Slot` be `(time - genesis_time) // SECONDS_PER_SLOT` where
|
||||||
`time` is the UNIX time according to the local system clock.
|
`time` is the UNIX time according to the local system clock.
|
||||||
|
@ -56,7 +67,7 @@ def is_optimistic(opt_store: OptimisticStore, block: BeaconBlock) -> bool:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def latest_verified_ancestor(opt_store: OptimisticStore, block: BeaconBlock) -> BeaconBlock:
|
def latest_verified_ancestor(opt_store: OptimisticStore, block: BeaconBlock) -> BeaconBlock:
|
||||||
# It is assumed that the `block` parameter is never an INVALID block.
|
# It is assumed that the `block` parameter is never an INVALIDATED block.
|
||||||
while True:
|
while True:
|
||||||
if not is_optimistic(opt_store, block) or block.parent_root == Root():
|
if not is_optimistic(opt_store, block) or block.parent_root == Root():
|
||||||
return block
|
return block
|
||||||
|
@ -104,35 +115,35 @@ these conditions.*
|
||||||
To optimistically import a block:
|
To optimistically import a block:
|
||||||
|
|
||||||
- The [`notify_new_payload`](../specs/bellatrix/beacon-chain.md#notify_new_payload) function MUST return `True` if the execution
|
- The [`notify_new_payload`](../specs/bellatrix/beacon-chain.md#notify_new_payload) function MUST return `True` if the execution
|
||||||
engine returns `SYNCING`, `VALID`, or `ACCEPTED`. An `INVALID` or `INVALID_BLOCK_HASH` response MUST return `False`.
|
engine returns `NOT_VALIDATED` or `VALID`. An `INVALIDATED` response MUST return `False`.
|
||||||
- The [`validate_merge_block`](../specs/bellatrix/fork-choice.md#validate_merge_block)
|
- The [`validate_merge_block`](../specs/bellatrix/fork-choice.md#validate_merge_block)
|
||||||
function MUST NOT raise an assertion if both the
|
function MUST NOT raise an assertion if both the
|
||||||
`pow_block` and `pow_parent` are unknown to the execution engine.
|
`pow_block` and `pow_parent` are unknown to the execution engine.
|
||||||
- All other assertions in [`validate_merge_block`](../specs/bellatrix/fork-choice.md#validate_merge_block)
|
- 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.
|
(e.g., `TERMINAL_BLOCK_HASH`) MUST prevent an optimistic import.
|
||||||
- The parent of the block MUST NOT have an INVALID execution payload.
|
- The parent of the block MUST NOT have an `INVALIDATED` execution payload.
|
||||||
|
|
||||||
In addition to this change in validation, the consensus engine MUST track which
|
In addition to this change in validation, the consensus engine MUST track which
|
||||||
blocks returned `SYNCING` and which returned `VALID` for subsequent processing.
|
blocks returned `NOT_VALIDATED` and which returned `VALID` for subsequent processing.
|
||||||
|
|
||||||
Optimistically imported blocks MUST pass all verifications included in
|
Optimistically imported blocks MUST pass all verifications included in
|
||||||
`process_block` (withstanding the modifications to `notify_new_payload`).
|
`process_block` (withstanding the modifications to `notify_new_payload`).
|
||||||
|
|
||||||
A consensus engine MUST be able to retrospectively (i.e., after import) modify
|
A consensus engine MUST be able to retrospectively (i.e., after import) modify
|
||||||
the status of `SYNCING` blocks to be either `VALID` or `INVALID` based upon responses
|
the status of `NOT_VALIDATED` blocks to be either `VALID` or `INVALIDATED` based upon responses
|
||||||
from an execution engine. I.e., perform the following transitions:
|
from an execution engine. I.e., perform the following transitions:
|
||||||
|
|
||||||
- `SYNCING` -> `VALID`
|
- `NOT_VALIDATED` -> `VALID`
|
||||||
- `SYNCING` -> `INVALID`
|
- `NOT_VALIDATED` -> `INVALIDATED`
|
||||||
|
|
||||||
When a block transitions from `SYNCING` -> `VALID`, all *ancestors* of the
|
When a block transitions from `NOT_VALIDATED` -> `VALID`, all *ancestors* of the
|
||||||
block MUST also transition from `SYNCING` -> `VALID`. Such a block and any previously `SYNCING` ancestors are no longer
|
block MUST also transition from `NOT_VALIDATED` -> `VALID`. Such a block and any previously `NOT_VALIDATED` ancestors are no longer
|
||||||
considered "optimistically imported".
|
considered "optimistically imported".
|
||||||
|
|
||||||
When a block transitions from `SYNCING` -> `INVALID`, all *descendants* of the
|
When a block transitions from `NOT_VALIDATED` -> `INVALIDATED`, all *descendants* of the
|
||||||
block MUST also transition from `SYNCING` -> `INVALID`.
|
block MUST also transition from `NOT_VALIDATED` -> `INVALIDATED`.
|
||||||
|
|
||||||
When a block transitions from the `SYNCING` state, it is removed from the set of
|
When a block transitions from the `NOT_VALIDATED` state, it is removed from the set of
|
||||||
`opt_store.optimistic_roots`.
|
`opt_store.optimistic_roots`.
|
||||||
|
|
||||||
When a "merge block" (i.e. the first block which enables execution in a chain) is declared to be
|
When a "merge block" (i.e. the first block which enables execution in a chain) is declared to be
|
||||||
|
@ -141,7 +152,7 @@ When a "merge block" (i.e. the first block which enables execution in a chain) i
|
||||||
MUST be run against the merge block. If the block
|
MUST be run against the merge block. If the block
|
||||||
fails [`validate_merge_block`](../specs/bellatrix/fork-choice.md#validate_merge_block),
|
fails [`validate_merge_block`](../specs/bellatrix/fork-choice.md#validate_merge_block),
|
||||||
the merge block MUST be treated the same as
|
the merge block MUST be treated the same as
|
||||||
an `INVALID` block (i.e., it and all its descendants are invalidated and
|
an `INVALIDATED` block (i.e., it and all its descendants are invalidated and
|
||||||
removed from the block tree).
|
removed from the block tree).
|
||||||
|
|
||||||
### Execution Engine Errors
|
### Execution Engine Errors
|
||||||
|
@ -155,11 +166,11 @@ validity request for some block, a consensus engine:
|
||||||
|
|
||||||
### Assumptions about Execution Engine Behaviour
|
### Assumptions about Execution Engine Behaviour
|
||||||
|
|
||||||
This specification assumes execution engines will only return `SYNCING` when
|
This specification assumes execution engines will only return `NOT_VALIDATED` when
|
||||||
there is insufficient information available to make a `VALID` or `INVALID`
|
there is insufficient information available to make a `VALID` or `INVALIDATED`
|
||||||
determination on the given `ExecutionPayload` (e.g., the parent payload is
|
determination on the given `ExecutionPayload` (e.g., the parent payload is
|
||||||
unknown). Specifically, `SYNCING` responses should be fork-specific, in that
|
unknown). Specifically, `NOT_VALIDATED` responses should be fork-specific, in that
|
||||||
the search for a block on one chain MUST NOT trigger a `SYNCING` response for
|
the search for a block on one chain MUST NOT trigger a `NOT_VALIDATED` response for
|
||||||
another chain.
|
another chain.
|
||||||
|
|
||||||
### Re-Orgs
|
### Re-Orgs
|
||||||
|
@ -167,16 +178,16 @@ another chain.
|
||||||
The consensus engine MUST support any chain reorganisation which does *not*
|
The consensus engine MUST support any chain reorganisation which does *not*
|
||||||
affect the justified checkpoint.
|
affect the justified checkpoint.
|
||||||
|
|
||||||
If the justified checkpoint transitions from `SYNCING` -> `INVALID`, a
|
If the justified checkpoint transitions from `NOT_VALIDATED` -> `INVALIDATED`, a
|
||||||
consensus engine MAY choose to alert the user and force the application to
|
consensus engine MAY choose to alert the user and force the application to
|
||||||
exit.
|
exit.
|
||||||
|
|
||||||
## Fork Choice
|
## Fork Choice
|
||||||
|
|
||||||
Consensus engines MUST support removing blocks from fork choice that transition
|
Consensus engines MUST support removing blocks from fork choice that transition
|
||||||
from `SYNCING` to `INVALID`. Specifically, a block deemed `INVALID` at any
|
from `NOT_VALIDATED` to `INVALIDATED`. Specifically, a block deemed `INVALIDATED` at any
|
||||||
point MUST NOT be included in the canonical chain and the weights from those
|
point MUST NOT be included in the canonical chain and the weights from those
|
||||||
`INVALID` blocks MUST NOT be applied to any `VALID` or `SYNCING` ancestors.
|
`INVALIDATED` blocks MUST NOT be applied to any `VALID` or `NOT_VALIDATED` ancestors.
|
||||||
|
|
||||||
### Fork Choice Poisoning
|
### Fork Choice Poisoning
|
||||||
|
|
||||||
|
@ -333,7 +344,7 @@ unlikely attack increases or decreases our total risk. Presently, it appears
|
||||||
that `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` sits in a sweet spot for this
|
that `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` sits in a sweet spot for this
|
||||||
trade-off.
|
trade-off.
|
||||||
|
|
||||||
### Transitioning from VALID -> INVALID or INVALID -> VALID
|
### Transitioning from VALID -> INVALIDATED or INVALIDATED -> VALID
|
||||||
|
|
||||||
These operations are purposefully omitted. It is outside of the scope of the
|
These operations are purposefully omitted. It is outside of the scope of the
|
||||||
specification since it's only possible with a faulty EE.
|
specification since it's only possible with a faulty EE.
|
||||||
|
|
Loading…
Reference in New Issue