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

Allow LightClientUpdate with genesis finality #2924

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Changes from 1 commit
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
11 changes: 8 additions & 3 deletions specs/altair/sync-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class LightClientStore(object):

```python
def is_finality_update(update: LightClientUpdate) -> bool:
return update.finalized_header != BeaconBlockHeader()
return update.finality_branch != [Bytes32() for _ in range(floorlog2(FINALIZED_ROOT_INDEX))]
```

### `get_subtree_index`
Expand Down Expand Up @@ -173,10 +173,15 @@ def validate_light_client_update(store: LightClientStore,
# Verify that the `finalized_header`, if present, actually is the finalized header saved in the
# state of the `attested_header`
etan-status marked this conversation as resolved.
Show resolved Hide resolved
if not is_finality_update(update):
assert update.finality_branch == [Bytes32() for _ in range(floorlog2(FINALIZED_ROOT_INDEX))]
assert update.finalized_header == BeaconBlockHeader()
else:
if update.finalized_header.slot != GENESIS_SLOT:
finalized_root = hash_tree_root(update.finalized_header)
else:
finalized_root = Bytes32()
assert update.finalized_header == BeaconBlockHeader()
etan-status marked this conversation as resolved.
Show resolved Hide resolved
assert is_valid_merkle_branch(
leaf=hash_tree_root(update.finalized_header),
leaf=finalized_root,
branch=update.finality_branch,
depth=floorlog2(FINALIZED_ROOT_INDEX),
index=get_subtree_index(FINALIZED_ROOT_INDEX),
Expand Down