Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise participation tracking in light client #2810

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions specs/altair/sync-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ uses sync committees introduced in [this beacon chain extension](./beacon-chain.

| Name | Value | Unit | Duration |
| - | - | - | - |
| `MIN_SYNC_COMMITTEE_PARTICIPANTS` | `1` | validators |
| `MIN_SYNC_COMMITTEE_PARTICIPANTS` | `1` | validators | |
| `UPDATE_TIMEOUT` | `SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD` | slots | ~27.3 hours |

## Containers
Expand Down Expand Up @@ -141,9 +141,6 @@ A light client maintains its state in a `store` object of type `LightClientStore

```python
def process_slot_for_light_client_store(store: LightClientStore, current_slot: Slot) -> None:
if current_slot % UPDATE_TIMEOUT == 0:
store.previous_max_active_participants = store.current_max_active_participants
store.current_max_active_participants = 0
if (
current_slot > store.finalized_header.slot + UPDATE_TIMEOUT
and store.best_valid_update is not None
Expand Down Expand Up @@ -219,6 +216,8 @@ def apply_light_client_update(store: LightClientStore, update: LightClientUpdate
finalized_period = compute_sync_committee_period(compute_epoch_at_slot(store.finalized_header.slot))
update_period = compute_sync_committee_period(compute_epoch_at_slot(active_header.slot))
if update_period == finalized_period + 1:
store.previous_max_active_participants = store.current_max_active_participants
store.current_max_active_participants = 0
store.current_sync_committee = store.next_sync_committee
store.next_sync_committee = update.next_sync_committee
store.finalized_header = active_header
Expand Down Expand Up @@ -265,4 +264,7 @@ def process_light_client_update(store: LightClientStore,
# Normal update through 2/3 threshold
apply_light_client_update(store, update)
store.best_valid_update = None
else:
# Force-update to best update if the timeout elapsed
process_slot_for_light_client_store(store, current_slot)
```
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ def test_process_light_client_update_timeout(spec, state):
fork_version=state.fork.current_version,
)

pre_store = deepcopy(store)

spec.process_light_client_update(store, update, state.slot, state.genesis_validators_root)

assert store.current_max_active_participants > 0
assert store.previous_max_active_participants > 0
assert store.optimistic_header == update.attested_header
assert store.best_valid_update == update
assert store.finalized_header == pre_store.finalized_header
assert store.finalized_header == update.attested_header
assert store.best_valid_update is None


@with_altair_and_later
Expand Down