Merge pull request #2370 from ralexstokes/simplify-sync-committee-aggregates

Simplify sync committee aggregates
This commit is contained in:
Danny Ryan 2021-05-06 12:38:49 -06:00 committed by GitHub
commit 609172d790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions

View File

@ -14,8 +14,6 @@ PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR: 2
# --------------------------------------------------------------- # ---------------------------------------------------------------
# 2**10 (= 1,024) # 2**10 (= 1,024)
SYNC_COMMITTEE_SIZE: 1024 SYNC_COMMITTEE_SIZE: 1024
# 2**6 (= 64)
SYNC_PUBKEYS_PER_AGGREGATE: 64
# 2**2 (= 4) # 2**2 (= 4)
INACTIVITY_SCORE_BIAS: 4 INACTIVITY_SCORE_BIAS: 4

View File

@ -14,8 +14,6 @@ PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR: 2
# --------------------------------------------------------------- # ---------------------------------------------------------------
# [customized] # [customized]
SYNC_COMMITTEE_SIZE: 32 SYNC_COMMITTEE_SIZE: 32
# [customized]
SYNC_PUBKEYS_PER_AGGREGATE: 16
# 2**2 (= 4) # 2**2 (= 4)
INACTIVITY_SCORE_BIAS: 4 INACTIVITY_SCORE_BIAS: 4

View File

@ -119,7 +119,6 @@ This patch updates a few configuration values to move penalty parameters closer
| Name | Value | | Name | Value |
| - | - | | - | - |
| `SYNC_COMMITTEE_SIZE` | `uint64(2**10)` (= 1,024) | | `SYNC_COMMITTEE_SIZE` | `uint64(2**10)` (= 1,024) |
| `SYNC_PUBKEYS_PER_AGGREGATE` | `uint64(2**6)` (= 64) |
| `INACTIVITY_SCORE_BIAS` | `uint64(4)` | | `INACTIVITY_SCORE_BIAS` | `uint64(4)` |
### Time parameters ### Time parameters
@ -212,7 +211,7 @@ class SyncAggregate(Container):
```python ```python
class SyncCommittee(Container): class SyncCommittee(Container):
pubkeys: Vector[BLSPubkey, SYNC_COMMITTEE_SIZE] pubkeys: Vector[BLSPubkey, SYNC_COMMITTEE_SIZE]
pubkey_aggregates: Vector[BLSPubkey, SYNC_COMMITTEE_SIZE // SYNC_PUBKEYS_PER_AGGREGATE] aggregate_pubkey: BLSPubkey
``` ```
## Helper functions ## Helper functions
@ -303,12 +302,19 @@ def get_sync_committee_indices(state: BeaconState, epoch: Epoch) -> Sequence[Val
def get_sync_committee(state: BeaconState, epoch: Epoch) -> SyncCommittee: def get_sync_committee(state: BeaconState, epoch: Epoch) -> SyncCommittee:
""" """
Return the sync committee for a given ``state`` and ``epoch``. Return the sync committee for a given ``state`` and ``epoch``.
``SyncCommittee`` contains an aggregate pubkey that enables
resource-constrained clients to save some computation when verifying
the sync committee's signature.
``SyncCommittee`` can also contain duplicate pubkeys, when ``get_sync_committee_indices``
returns duplicate indices. Implementations must take care when handling
optimizations relating to aggregation and verification in the presence of duplicates.
""" """
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]
partition = [pubkeys[i:i + SYNC_PUBKEYS_PER_AGGREGATE] for i in range(0, len(pubkeys), SYNC_PUBKEYS_PER_AGGREGATE)] aggregate_pubkey = bls.AggregatePKs(pubkeys)
pubkey_aggregates = [bls.AggregatePKs(preaggregate) for preaggregate in partition] return SyncCommittee(pubkeys=pubkeys, aggregate_pubkey=aggregate_pubkey)
return SyncCommittee(pubkeys=pubkeys, pubkey_aggregates=pubkey_aggregates)
``` ```
#### `get_base_reward_per_increment` #### `get_base_reward_per_increment`
@ -409,7 +415,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
#### Modified `slash_validator` #### Modified `slash_validator`
*Note*: The function `slash_validator` is modified to use `MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR` *Note*: The function `slash_validator` is modified to use `MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR`
and use `PROPOSER_WEIGHT` when calculating the proposer reward. and use `PROPOSER_WEIGHT` when calculating the proposer reward.
```python ```python