Update sync_protocol.md

This commit is contained in:
terence tsao 2019-09-04 09:00:59 -07:00 committed by GitHub
parent d1fe8f16fd
commit dbcce17769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 18 deletions

View File

@ -13,9 +13,8 @@
- [Constants](#constants) - [Constants](#constants)
- [Containers](#containers) - [Containers](#containers)
- [`LightClientUpdate`](#lightclientupdate) - [`LightClientUpdate`](#lightclientupdate)
- [Helpers](#helpers)
- [`LightClientMemory`](#lightclientmemory) - [`LightClientMemory`](#lightclientmemory)
- [`unpack_compact_validator`](#unpack_compact_validator) - [Helpers](#helpers)
- [`get_persistent_committee_pubkeys_and_balances`](#get_persistent_committee_pubkeys_and_balances) - [`get_persistent_committee_pubkeys_and_balances`](#get_persistent_committee_pubkeys_and_balances)
- [Light client state updates](#light-client-state-updates) - [Light client state updates](#light-client-state-updates)
- [Data overhead](#data-overhead) - [Data overhead](#data-overhead)
@ -62,12 +61,9 @@ class LightClientUpdate(container):
committee_branch: Vector[Hash, PERSISTENT_COMMITTEE_ROOT_IN_BEACON_STATE_DEPTH + log_2(SHARD_COUNT)] committee_branch: Vector[Hash, PERSISTENT_COMMITTEE_ROOT_IN_BEACON_STATE_DEPTH + log_2(SHARD_COUNT)]
``` ```
## Helpers
### `LightClientMemory` ### `LightClientMemory`
```python ```python
@dataclass
class LightClientMemory(object): class LightClientMemory(object):
shard: Shard # Randomly initialized and retained forever shard: Shard # Randomly initialized and retained forever
header: BeaconBlockHeader # Beacon header which is not expected to revert header: BeaconBlockHeader # Beacon header which is not expected to revert
@ -77,19 +73,7 @@ class LightClientMemory(object):
next_committee: CompactCommittee next_committee: CompactCommittee
``` ```
### `unpack_compact_validator` ## Helpers
```python
def unpack_compact_validator(compact_validator: CompactValidator) -> Tuple[ValidatorIndex, bool, uint64]:
"""
Return the index, slashed, effective_balance // EFFECTIVE_BALANCE_INCREMENT of ``compact_validator``.
"""
return (
ValidatorIndex(compact_validator >> 16),
bool((compact_validator >> 15) % 2),
uint64(compact_validator & (2**15 - 1)),
)
```
### `get_persistent_committee_pubkeys_and_balances` ### `get_persistent_committee_pubkeys_and_balances`