Fix apply_light_client_update calls

This commit is contained in:
Hsiao-Wei Wang 2021-03-11 14:27:23 +08:00
parent 36b6f8c3bf
commit 86fe6bc094
No known key found for this signature in database
GPG Key ID: 1111A8A81778319E
1 changed files with 9 additions and 8 deletions

View File

@ -61,7 +61,7 @@ uses sync committees introduced in [this beacon chain extension](./beacon-chain.
## Containers ## Containers
#### `LightClientSnapshot` ### `LightClientSnapshot`
```python ```python
class LightClientSnapshot(Container): class LightClientSnapshot(Container):
@ -72,7 +72,7 @@ class LightClientSnapshot(Container):
next_sync_committee: SyncCommittee next_sync_committee: SyncCommittee
``` ```
#### `LightClientUpdate` ### `LightClientUpdate`
```python ```python
class LightClientUpdate(Container): class LightClientUpdate(Container):
@ -91,7 +91,7 @@ class LightClientUpdate(Container):
fork_version: Version fork_version: Version
``` ```
#### `LightClientStore` ### `LightClientStore`
```python ```python
class LightClientStore(Container): class LightClientStore(Container):
@ -188,10 +188,11 @@ def process_light_client_update(store: LightClientStore, update: LightClientUpda
# Apply update if (1) 2/3 quorum is reached and (2) we have a finality proof. # Apply update if (1) 2/3 quorum is reached and (2) we have a finality proof.
# Note that (2) means that the current light client design needs finality. # Note that (2) means that the current light client design needs finality.
# It may be changed to re-organizable light client design. See the on-going issue eth2.0-specs#2182. # It may be changed to re-organizable light client design. See the on-going issue eth2.0-specs#2182.
apply_light_client_update(store, update) apply_light_client_update(store.snapshot, update)
store.valid_updates = [] store.valid_updates = []
elif current_slot > store.snapshot.header.slot + LIGHT_CLIENT_UPDATE_TIMEOUT: elif current_slot > store.snapshot.header.slot + LIGHT_CLIENT_UPDATE_TIMEOUT:
# Forced best update when the update timeout has elapsed # Forced best update when the update timeout has elapsed
apply_light_client_update(store, max(store.valid_updates, key=lambda update: sum(update.sync_committee_bits))) apply_light_client_update(store.snapshot,
max(store.valid_updates, key=lambda update: sum(update.sync_committee_bits)))
store.valid_updates = [] store.valid_updates = []
``` ```