Ensure light client optimistic_header to be at head

When a light client updates its `finalized_header` using a forced update
because of the timeout, and the new header was not signed by enough sync
committee participants to pass `get_safety_threshold(store)`, it may
occur that `store.finalized_header.slot > store.optimistic_header.slot`.
This patch ensures that the `optimistic_header` is updated to the latest
`finalized_header` if that happens, so that it always indicates the
latest known and accepted head.
This commit is contained in:
Etan Kissling 2022-01-25 10:09:10 +01:00
parent 2232d76735
commit 0e9460b8dd
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D

View File

@ -214,6 +214,8 @@ def apply_light_client_update(store: LightClientStore, update: LightClientUpdate
store.current_sync_committee = store.next_sync_committee
store.next_sync_committee = update.next_sync_committee
store.finalized_header = active_header
if store.finalized_header.slot > store.optimistic_header.slot:
store.optimistic_header = store.finalized_header
```
#### `process_light_client_update`