Merge pull request #2469 from ethereum/sync-consistency

Sync Committee vs Aggregate naming consistencies
This commit is contained in:
Diederik Loerakker 2021-06-08 01:30:28 +02:00 committed by GitHub
commit c821e3fced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 14 deletions

View File

@ -44,7 +44,7 @@
- [Block processing](#block-processing)
- [Modified `process_attestation`](#modified-process_attestation)
- [Modified `process_deposit`](#modified-process_deposit)
- [Sync committee processing](#sync-committee-processing)
- [Sync aggregate processing](#sync-aggregate-processing)
- [Epoch processing](#epoch-processing)
- [Justification and finalization](#justification-and-finalization)
- [Inactivity scores](#inactivity-scores)
@ -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`
@ -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
@ -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)

View File

@ -243,7 +243,7 @@ def process_sync_committee_contributions(block: BeaconBlock,
block.body.sync_aggregate = sync_aggregate
```
*Note*: The resulting block must pass the validations for the `SyncAggregate` defined in `process_sync_committee` defined in the [state transition document](./beacon-chain.md#sync-committee-processing).
*Note*: The resulting block must pass the validations for the `SyncAggregate` defined in `process_sync_aggregate` defined in the [state transition document](./beacon-chain.md#sync-aggregate-processing).
In particular, this means `SyncCommitteeContribution`s received from gossip must have a `beacon_block_root` that matches the proposer's local view of the chain.
#### Packaging into a `SignedBeaconBlock`

View File

@ -32,7 +32,7 @@ def run_sync_committee_processing(spec, state, block, expect_exception=False):
produces a pre-state and post-state (None if exception) specifically for sync-committee processing changes.
"""
# process up to the sync committee work
call = run_block_processing_to(spec, state, block, 'process_sync_committee')
call = run_block_processing_to(spec, state, block, 'process_sync_aggregate')
yield 'pre', state
yield 'sync_aggregate', block.body.sync_aggregate
if expect_exception:

View File

@ -25,8 +25,8 @@ def get_process_calls(spec):
'process_voluntary_exit':
lambda state, block: for_ops(state, block.body.voluntary_exits, spec.process_voluntary_exit),
# Altair
'process_sync_committee':
lambda state, block: spec.process_sync_committee(state, block.body.sync_aggregate),
'process_sync_aggregate':
lambda state, block: spec.process_sync_aggregate(state, block.body.sync_aggregate),
# Merge
'process_application_payload':
lambda state, block: spec.process_application_payload(state, block.body),

View File

@ -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.

View File

@ -13,7 +13,7 @@ if __name__ == "__main__":
]}
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