Skip to content

Commit

Permalink
ensure consistency about sync committees vs aggregates in naming thro…
Browse files Browse the repository at this point in the history
…ughout
  • Loading branch information
djrtwo committed Jun 7, 2021
1 parent b97972c commit 09b6fb0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions specs/altair/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None:
process_randao(state, block.body)
process_eth1_data(state, block.body)
process_operations(state, block.body) # [Modified in Altair]
process_sync_committee(state, block.body.sync_aggregate) # [New in Altair]
process_sync_aggregate(state, block.body.sync_aggregate) # [New in Altair]
```

#### Modified `process_attestation`
Expand Down Expand Up @@ -532,19 +532,19 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
increase_balance(state, index, amount)
```

#### Sync committee processing
#### Sync aggregate processing

*Note*: The function `process_sync_committee` is new.
*Note*: The function `process_sync_aggregate` is new.

```python
def process_sync_committee(state: BeaconState, aggregate: SyncAggregate) -> None:
def process_sync_aggregate(state: BeaconState, sync_aggregate: SyncAggregate) -> None:
# Verify sync committee aggregate signature signing over the previous slot block root
committee_pubkeys = state.current_sync_committee.pubkeys
participant_pubkeys = [pubkey for pubkey, bit in zip(committee_pubkeys, aggregate.sync_committee_bits) if bit]
participant_pubkeys = [pubkey for pubkey, bit in zip(committee_pubkeys, sync_aggregate.sync_committee_bits) if bit]
previous_slot = max(state.slot, Slot(1)) - Slot(1)
domain = get_domain(state, DOMAIN_SYNC_COMMITTEE, compute_epoch_at_slot(previous_slot))
signing_root = compute_signing_root(get_block_root_at_slot(state, previous_slot), domain)
assert eth2_fast_aggregate_verify(participant_pubkeys, signing_root, aggregate.sync_committee_signature)
assert eth2_fast_aggregate_verify(participant_pubkeys, signing_root, sync_aggregate.sync_committee_signature)

# Compute participant and proposer rewards
total_active_increments = get_total_active_balance(state) // EFFECTIVE_BALANCE_INCREMENT
Expand All @@ -556,7 +556,7 @@ def process_sync_committee(state: BeaconState, aggregate: SyncAggregate) -> None
# Apply participant and proposer rewards
all_pubkeys = [v.pubkey for v in state.validators]
committee_indices = [ValidatorIndex(all_pubkeys.index(pubkey)) for pubkey in state.current_sync_committee.pubkeys]
for participant_index, participation_bit in zip(committee_indices, aggregate.sync_committee_bits):
for participant_index, participation_bit in zip(committee_indices, sync_aggregate.sync_committee_bits):
if participation_bit:
increase_balance(state, participant_index, participant_reward)
increase_balance(state, get_beacon_proposer_index(state), proposer_reward)
Expand Down
2 changes: 1 addition & 1 deletion tests/formats/operations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Operations:
| `deposit` | `Deposit` | `deposit` | `process_deposit(state, deposit)` |
| `proposer_slashing` | `ProposerSlashing` | `proposer_slashing` | `process_proposer_slashing(state, proposer_slashing)` |
| `voluntary_exit` | `SignedVoluntaryExit` | `voluntary_exit` | `process_voluntary_exit(state, voluntary_exit)` |
| `sync_aggregate` | `SyncAggregate` | `sync_aggregate` | `process_sync_committee(state, sync_aggregate)` (new in Altair) |
| `sync_aggregate` | `SyncAggregate` | `sync_aggregate` | `process_sync_aggregate(state, sync_aggregate)` (new in Altair) |
| `execution_payload` | `ExecutionPayload` | `execution_payload` | `process_execution_payload(state, execution_payload)` (new in Merge) |

Note that `block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here.
Expand Down
2 changes: 1 addition & 1 deletion tests/generators/operations/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]}
altair_mods = {
**{key: 'eth2spec.test.altair.block_processing.test_process_' + key for key in [
'sync_committee',
'sync_aggregate',
]},
**phase_0_mods,
} # also run the previous phase 0 tests
Expand Down

0 comments on commit 09b6fb0

Please sign in to comment.