mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 00:05:02 -05:00
Reorder helpers to group ones operating on updates
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user