From c67ad597f0c38f7eb83dea733b1bdf2490029bcb Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 8 Jul 2022 21:46:34 -0700 Subject: [PATCH] Reorder helpers to group ones operating on updates --- specs/altair/sync-protocol.md | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/specs/altair/sync-protocol.md b/specs/altair/sync-protocol.md index 7864ac6e2..6f6e728e4 100644 --- a/specs/altair/sync-protocol.md +++ b/specs/altair/sync-protocol.md @@ -18,9 +18,9 @@ - [Helper functions](#helper-functions) - [`is_sync_committee_update`](#is_sync_committee_update) - [`is_finality_update`](#is_finality_update) - - [`get_subtree_index`](#get_subtree_index) - - [`get_safety_threshold`](#get_safety_threshold) - [`is_better_update`](#is_better_update) + - [`get_safety_threshold`](#get_safety_threshold) + - [`get_subtree_index`](#get_subtree_index) - [Light client state updates](#light-client-state-updates) - [`process_slot_for_light_client_store`](#process_slot_for_light_client_store) - [`validate_light_client_update`](#validate_light_client_update) @@ -111,23 +111,6 @@ def is_finality_update(update: LightClientUpdate) -> bool: return update.finality_branch != [Bytes32() for _ in range(floorlog2(FINALIZED_ROOT_INDEX))] ``` -### `get_subtree_index` - -```python -def get_subtree_index(generalized_index: GeneralizedIndex) -> uint64: - return uint64(generalized_index % 2**(floorlog2(generalized_index))) -``` - -### `get_safety_threshold` - -```python -def get_safety_threshold(store: LightClientStore) -> uint64: - return max( - store.previous_max_active_participants, - store.current_max_active_participants, - ) // 2 -``` - ### `is_better_update` ```python @@ -172,6 +155,23 @@ def is_better_update(new_update: LightClientUpdate, old_update: LightClientUpdat return new_update.signature_slot < old_update.signature_slot ``` +### `get_safety_threshold` + +```python +def get_safety_threshold(store: LightClientStore) -> uint64: + return max( + store.previous_max_active_participants, + store.current_max_active_participants, + ) // 2 +``` + +### `get_subtree_index` + +```python +def get_subtree_index(generalized_index: GeneralizedIndex) -> uint64: + return uint64(generalized_index % 2**(floorlog2(generalized_index))) +``` + ## Light client state updates A light client maintains its state in a `store` object of type `LightClientStore` and receives `update` objects of type `LightClientUpdate`. Every `update` triggers `process_light_client_update(store, update, current_slot, genesis_validators_root)` where `current_slot` is the current slot based on a local clock. `process_slot_for_light_client_store` is triggered every time the current slot increments.