From 09b6fb0e644a1f781cc2c5220b784319a086b2ee Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 7 Jun 2021 16:15:53 -0600 Subject: [PATCH 1/3] ensure consistency about sync committees vs aggregates in naming throughout --- specs/altair/beacon-chain.md | 14 +++++++------- ...committee.py => test_process_sync_aggregate.py} | 0 tests/formats/operations/README.md | 2 +- tests/generators/operations/main.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename tests/core/pyspec/eth2spec/test/altair/block_processing/{test_process_sync_committee.py => test_process_sync_aggregate.py} (100%) diff --git a/specs/altair/beacon-chain.md b/specs/altair/beacon-chain.md index 3877f17d2..5e5d9abf8 100644 --- a/specs/altair/beacon-chain.md +++ b/specs/altair/beacon-chain.md @@ -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) diff --git a/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_committee.py b/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_aggregate.py similarity index 100% rename from tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_committee.py rename to tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_aggregate.py diff --git a/tests/formats/operations/README.md b/tests/formats/operations/README.md index f562a6f2a..c69d798d7 100644 --- a/tests/formats/operations/README.md +++ b/tests/formats/operations/README.md @@ -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. diff --git a/tests/generators/operations/main.py b/tests/generators/operations/main.py index 554d0b30a..57fc6dd96 100644 --- a/tests/generators/operations/main.py +++ b/tests/generators/operations/main.py @@ -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 From cfc66a3794c4f102af9661fa417f4dd2b04893a5 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 7 Jun 2021 16:36:18 -0600 Subject: [PATCH 2/3] patch tests --- specs/altair/beacon-chain.md | 2 +- .../altair/block_processing/test_process_sync_aggregate.py | 2 +- tests/core/pyspec/eth2spec/test/helpers/block_processing.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/specs/altair/beacon-chain.md b/specs/altair/beacon-chain.md index 5e5d9abf8..3bd82aec8 100644 --- a/specs/altair/beacon-chain.md +++ b/specs/altair/beacon-chain.md @@ -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) diff --git a/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_aggregate.py b/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_aggregate.py index b0a294c85..fa7f89fdc 100644 --- a/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_aggregate.py +++ b/tests/core/pyspec/eth2spec/test/altair/block_processing/test_process_sync_aggregate.py @@ -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: diff --git a/tests/core/pyspec/eth2spec/test/helpers/block_processing.py b/tests/core/pyspec/eth2spec/test/helpers/block_processing.py index 676d8cb6d..d2ec4a111 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/block_processing.py +++ b/tests/core/pyspec/eth2spec/test/helpers/block_processing.py @@ -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), From 64f217d3e19091ce342c6982d79f995b7a7fbd57 Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 8 Jun 2021 01:05:50 +0200 Subject: [PATCH 3/3] update sync aggregate processing reference in validator doc --- specs/altair/validator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/altair/validator.md b/specs/altair/validator.md index 844c7021b..f193e3591 100644 --- a/specs/altair/validator.md +++ b/specs/altair/validator.md @@ -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`