mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-04 22:34:57 -05:00
Remove fork_version from LightClientUpdate
The `fork_version` field in `LightClientUpdate` can be derived from the `update.signature_slot` value by consulting the locally configured fork schedule. The light client already needs access to the fork schedule to determine the `GeneralizedIndex` values used for merkle proofs, and the memory layouts of the structures (including `LightClientUpdate`). The `fork_version` itself is network dependent and doesn't reveal that info.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
- [Helper functions](#helper-functions)
|
||||
- [Crypto](#crypto)
|
||||
- [Misc](#misc-1)
|
||||
- [`compute_fork_version`](#compute_fork_version)
|
||||
- [`add_flag`](#add_flag)
|
||||
- [`has_flag`](#has_flag)
|
||||
- [Beacon state accessors](#beacon-state-accessors)
|
||||
@@ -226,6 +227,18 @@ the functionality described in those documents.
|
||||
|
||||
### Misc
|
||||
|
||||
#### `compute_fork_version`
|
||||
|
||||
```python
|
||||
def compute_fork_version(epoch: Epoch) -> Version:
|
||||
"""
|
||||
Return the fork version at the given ``epoch``.
|
||||
"""
|
||||
if epoch >= ALTAIR_FORK_EPOCH:
|
||||
return ALTAIR_FORK_VERSION
|
||||
return GENESIS_FORK_VERSION
|
||||
```
|
||||
|
||||
#### `add_flag`
|
||||
|
||||
```python
|
||||
|
||||
@@ -71,8 +71,6 @@ class LightClientUpdate(Container):
|
||||
finality_branch: Vector[Bytes32, floorlog2(FINALIZED_ROOT_INDEX)]
|
||||
# Sync committee aggregate signature
|
||||
sync_aggregate: SyncAggregate
|
||||
# Fork version for the aggregate signature
|
||||
fork_version: Version
|
||||
# Slot at which the aggregate signature was created (untrusted)
|
||||
signature_slot: Slot
|
||||
```
|
||||
@@ -211,7 +209,8 @@ def validate_light_client_update(store: LightClientStore,
|
||||
pubkey for (bit, pubkey) in zip(sync_aggregate.sync_committee_bits, sync_committee.pubkeys)
|
||||
if bit
|
||||
]
|
||||
domain = compute_domain(DOMAIN_SYNC_COMMITTEE, update.fork_version, genesis_validators_root)
|
||||
fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot))
|
||||
domain = compute_domain(DOMAIN_SYNC_COMMITTEE, fork_version, genesis_validators_root)
|
||||
signing_root = compute_signing_root(update.attested_header, domain)
|
||||
assert bls.FastAggregateVerify(participant_pubkeys, signing_root, sync_aggregate.sync_committee_signature)
|
||||
```
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
- [`is_execution_enabled`](#is_execution_enabled)
|
||||
- [Misc](#misc)
|
||||
- [`compute_timestamp_at_slot`](#compute_timestamp_at_slot)
|
||||
- [Modified `compute_fork_version`](#modified-compute_fork_version)
|
||||
- [Beacon state accessors](#beacon-state-accessors)
|
||||
- [Modified `get_inactivity_penalty_deltas`](#modified-get_inactivity_penalty_deltas)
|
||||
- [Beacon state mutators](#beacon-state-mutators)
|
||||
@@ -242,6 +243,20 @@ def compute_timestamp_at_slot(state: BeaconState, slot: Slot) -> uint64:
|
||||
return uint64(state.genesis_time + slots_since_genesis * SECONDS_PER_SLOT)
|
||||
```
|
||||
|
||||
#### Modified `compute_fork_version`
|
||||
|
||||
```python
|
||||
def compute_fork_version(epoch: Epoch) -> Version:
|
||||
"""
|
||||
Return the fork version at the given ``epoch``.
|
||||
"""
|
||||
if epoch >= BELLATRIX_FORK_EPOCH:
|
||||
return BELLATRIX_FORK_VERSION
|
||||
if epoch >= ALTAIR_FORK_EPOCH:
|
||||
return ALTAIR_FORK_VERSION
|
||||
return GENESIS_FORK_VERSION
|
||||
```
|
||||
|
||||
### Beacon state accessors
|
||||
|
||||
#### Modified `get_inactivity_penalty_deltas`
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
- [`has_eth1_withdrawal_credential`](#has_eth1_withdrawal_credential)
|
||||
- [`is_fully_withdrawable_validator`](#is_fully_withdrawable_validator)
|
||||
- [`is_partially_withdrawable_validator`](#is_partially_withdrawable_validator)
|
||||
- [Misc](#misc-1)
|
||||
- [Modified `compute_fork_version`](#modified-compute_fork_version)
|
||||
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
|
||||
- [Epoch processing](#epoch-processing)
|
||||
- [Full withdrawals](#full-withdrawals)
|
||||
@@ -318,6 +320,24 @@ def is_partially_withdrawable_validator(validator: Validator, balance: Gwei) ->
|
||||
return has_eth1_withdrawal_credential(validator) and has_max_effective_balance and has_excess_balance
|
||||
```
|
||||
|
||||
### Misc
|
||||
|
||||
#### Modified `compute_fork_version`
|
||||
|
||||
```python
|
||||
def compute_fork_version(epoch: Epoch) -> Version:
|
||||
"""
|
||||
Return the fork version at the given ``epoch``.
|
||||
"""
|
||||
if epoch >= CAPELLA_FORK_EPOCH:
|
||||
return CAPELLA_FORK_VERSION
|
||||
if epoch >= BELLATRIX_FORK_EPOCH:
|
||||
return BELLATRIX_FORK_VERSION
|
||||
if epoch >= ALTAIR_FORK_EPOCH:
|
||||
return ALTAIR_FORK_VERSION
|
||||
return GENESIS_FORK_VERSION
|
||||
```
|
||||
|
||||
## Beacon chain state transition function
|
||||
|
||||
### Epoch processing
|
||||
|
||||
Reference in New Issue
Block a user