Add notes about sync committee stability
This commit is contained in:
parent
86104ea361
commit
04a9595415
|
@ -277,6 +277,9 @@ def get_sync_committee_indices(state: BeaconState, epoch: Epoch) -> Sequence[Val
|
||||||
"""
|
"""
|
||||||
Return the sequence of sync committee indices (which may include duplicate indices)
|
Return the sequence of sync committee indices (which may include duplicate indices)
|
||||||
for a given ``state`` and ``epoch``.
|
for a given ``state`` and ``epoch``.
|
||||||
|
|
||||||
|
Note: This function is not stable during a sync committee period as
|
||||||
|
a validator's effective balance may change enough to affect the sampling.
|
||||||
"""
|
"""
|
||||||
MAX_RANDOM_BYTE = 2**8 - 1
|
MAX_RANDOM_BYTE = 2**8 - 1
|
||||||
base_epoch = Epoch((max(epoch // EPOCHS_PER_SYNC_COMMITTEE_PERIOD, 1) - 1) * EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
|
base_epoch = Epoch((max(epoch // EPOCHS_PER_SYNC_COMMITTEE_PERIOD, 1) - 1) * EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
|
||||||
|
@ -310,6 +313,9 @@ def get_sync_committee(state: BeaconState, epoch: Epoch) -> SyncCommittee:
|
||||||
``SyncCommittee`` can also contain duplicate pubkeys, when ``get_sync_committee_indices``
|
``SyncCommittee`` can also contain duplicate pubkeys, when ``get_sync_committee_indices``
|
||||||
returns duplicate indices. Implementations must take care when handling
|
returns duplicate indices. Implementations must take care when handling
|
||||||
optimizations relating to aggregation and verification in the presence of duplicates.
|
optimizations relating to aggregation and verification in the presence of duplicates.
|
||||||
|
|
||||||
|
Note: This function should only be called at sync committee period boundaries, as
|
||||||
|
``get_sync_committee_indices`` is not stable within a given period.
|
||||||
"""
|
"""
|
||||||
indices = get_sync_committee_indices(state, epoch)
|
indices = get_sync_committee_indices(state, epoch)
|
||||||
pubkeys = [state.validators[index].pubkey for index in indices]
|
pubkeys = [state.validators[index].pubkey for index in indices]
|
||||||
|
|
Loading…
Reference in New Issue