Skip to content

Commit

Permalink
update to latest light client sync protocol
Browse files Browse the repository at this point in the history
This implements the latest version of the light client sync protocol,
and also adds a test runner for the new accompanying tests.
See ethereum/consensus-specs#2802
  • Loading branch information
etan-status committed Jan 28, 2022
1 parent e070447 commit efe08d0
Show file tree
Hide file tree
Showing 8 changed files with 588 additions and 150 deletions.
78 changes: 43 additions & 35 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
AllTests-mainnet
===
##
```diff
+ Slashing test: duplicate_pubkey_not_slashable.json OK
+ Slashing test: multiple_interchanges_single_validator_single_message_gap.json OK
+ Slashing test: multiple_interchanges_single_validator_single_message_out_of_order.json OK
+ Slashing test: multiple_validators_multiple_blocks_and_attestations.json OK
+ Slashing test: multiple_validators_same_slot_blocks.json OK
+ Slashing test: single_validator_genesis_attestation.json OK
+ Slashing test: single_validator_import_only.json OK
+ Slashing test: single_validator_multiple_block_attempts.json OK
+ Slashing test: single_validator_multiple_blocks_and_attestations.json OK
+ Slashing test: single_validator_out_of_order_attestations.json OK
+ Slashing test: single_validator_out_of_order_blocks.json OK
+ Slashing test: single_validator_resign_attestation.json OK
+ Slashing test: single_validator_resign_block.json OK
+ Slashing test: single_validator_single_attestation.json OK
+ Slashing test: single_validator_single_block.json OK
+ Slashing test: single_validator_single_block_and_attestation.json OK
+ Slashing test: single_validator_single_block_and_attestation_signing_root.json OK
+ Slashing test: single_validator_slashable_attestations_double_vote.json OK
+ Slashing test: single_validator_slashable_attestations_surrounded_by_existing.json OK
+ Slashing test: single_validator_slashable_attestations_surrounds_existing.json OK
+ Slashing test: single_validator_slashable_blocks.json OK
+ Slashing test: single_validator_slashable_blocks_no_root.json OK
+ Slashing test: single_validator_source_greater_than_target.json OK
+ Slashing test: single_validator_two_blocks_no_signing_root.json OK
+ Slashing test: wrong_genesis_validators_root.json OK
```
OK: 25/25 Fail: 0/25 Skip: 0/25
## Attestation pool processing [Preset: mainnet]
```diff
+ Attestations may arrive in any order [Preset: mainnet] OK
Expand Down Expand Up @@ -293,17 +264,54 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ deletePeer() test OK
```
OK: 12/12 Fail: 0/12 Skip: 0/12
## Slashing Interchange tests [Preset: mainnet]
```diff
+ Slashing test: duplicate_pubkey_not_slashable.json OK
+ Slashing test: duplicate_pubkey_slashable_attestation.json OK
+ Slashing test: duplicate_pubkey_slashable_block.json OK
+ Slashing test: multiple_interchanges_multiple_validators_repeat_idem.json OK
+ Slashing test: multiple_interchanges_overlapping_validators_merge_stale.json OK
+ Slashing test: multiple_interchanges_overlapping_validators_repeat_idem.json OK
+ Slashing test: multiple_interchanges_single_validator_fail_iff_imported.json OK
+ Slashing test: multiple_interchanges_single_validator_first_surrounds_second.json OK
Slashing test: multiple_interchanges_single_validator_multiple_blocks_out_of_order.json Skip
+ Slashing test: multiple_interchanges_single_validator_second_surrounds_first.json OK
+ Slashing test: multiple_interchanges_single_validator_single_att_out_of_order.json OK
+ Slashing test: multiple_interchanges_single_validator_single_block_out_of_order.json OK
+ Slashing test: multiple_interchanges_single_validator_single_message_gap.json OK
+ Slashing test: multiple_validators_multiple_blocks_and_attestations.json OK
+ Slashing test: multiple_validators_same_slot_blocks.json OK
+ Slashing test: single_validator_genesis_attestation.json OK
+ Slashing test: single_validator_import_only.json OK
+ Slashing test: single_validator_multiple_block_attempts.json OK
+ Slashing test: single_validator_multiple_blocks_and_attestations.json OK
+ Slashing test: single_validator_out_of_order_attestations.json OK
+ Slashing test: single_validator_out_of_order_blocks.json OK
+ Slashing test: single_validator_resign_attestation.json OK
+ Slashing test: single_validator_resign_block.json OK
+ Slashing test: single_validator_single_attestation.json OK
+ Slashing test: single_validator_single_block.json OK
+ Slashing test: single_validator_single_block_and_attestation.json OK
+ Slashing test: single_validator_single_block_and_attestation_signing_root.json OK
+ Slashing test: single_validator_slashable_attestations_double_vote.json OK
+ Slashing test: single_validator_slashable_attestations_surrounded_by_existing.json OK
+ Slashing test: single_validator_slashable_attestations_surrounds_existing.json OK
+ Slashing test: single_validator_slashable_blocks.json OK
+ Slashing test: single_validator_slashable_blocks_no_root.json OK
+ Slashing test: single_validator_source_greater_than_target.json OK
+ Slashing test: single_validator_source_greater_than_target_sensible_iff_minified.json OK
+ Slashing test: single_validator_source_greater_than_target_surrounded.json OK
Slashing test: single_validator_source_greater_than_target_surrounding.json Skip
+ Slashing test: single_validator_two_blocks_no_signing_root.json OK
+ Slashing test: wrong_genesis_validators_root.json OK
```
OK: 36/38 Fail: 0/38 Skip: 2/38
## Slashing Protection DB - Interchange [Preset: mainnet]
```diff
+ Smoke test - Complete format - Invalid database is refused [Preset: mainnet] OK
+ Smoke test - Complete format [Preset: mainnet] OK
```
OK: 2/2 Fail: 0/2 Skip: 0/2
## Slashing Protection DB - v1 and v2 migration [Preset: mainnet]
```diff
+ Minimal format migration [Preset: mainnet] OK
```
OK: 1/1 Fail: 0/1 Skip: 0/1
## Slashing Protection DB [Preset: mainnet]
```diff
+ Attestation ordering #1698 OK
Expand Down Expand Up @@ -442,4 +450,4 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
OK: 1/1 Fail: 0/1 Skip: 0/1

---TOTAL---
OK: 238/240 Fail: 0/240 Skip: 2/240
OK: 248/252 Fail: 0/252 Skip: 4/252
5 changes: 3 additions & 2 deletions ConsensusSpecPreset-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,10 @@ OK: 35/35 Fail: 0/35 Skip: 0/35
```diff
+ process_light_client_update_finality_updated OK
+ process_light_client_update_timeout OK
+ test_process_light_client_update_at_period_boundary OK
+ test_process_light_client_update_not_timeout OK
```
OK: 3/3 Fail: 0/3 Skip: 0/3
OK: 4/4 Fail: 0/4 Skip: 0/4
## EF - Bellatrix - Epoch Processing - Effective balance updates [Preset: mainnet]
```diff
+ Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK
Expand Down Expand Up @@ -1191,4 +1192,4 @@ OK: 44/44 Fail: 0/44 Skip: 0/44
OK: 27/27 Fail: 0/27 Skip: 0/27

---TOTAL---
OK: 1015/1017 Fail: 0/1017 Skip: 2/1017
OK: 1016/1018 Fail: 0/1018 Skip: 2/1018
8 changes: 5 additions & 3 deletions ConsensusSpecPreset-minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,10 @@ ConsensusSpecPreset-minimal
+ fork_random_large_validator_set OK
+ fork_random_low_balances OK
+ fork_random_misc_balances OK
+ light_client_sync OK
+ next_sync_committee_merkle_proof OK
```
OK: 386/386 Fail: 0/386 Skip: 0/386
OK: 387/387 Fail: 0/387 Skip: 0/387
## Attestation
```diff
+ [Invalid] EF - Altair - Operations - Attestation - after_epoch_slots OK
Expand Down Expand Up @@ -828,9 +829,10 @@ OK: 35/35 Fail: 0/35 Skip: 0/35
```diff
+ process_light_client_update_finality_updated OK
+ process_light_client_update_timeout OK
+ test_process_light_client_update_at_period_boundary OK
+ test_process_light_client_update_not_timeout OK
```
OK: 3/3 Fail: 0/3 Skip: 0/3
OK: 4/4 Fail: 0/4 Skip: 0/4
## EF - Bellatrix - Epoch Processing - Effective balance updates [Preset: minimal]
```diff
+ Effective balance updates - effective_balance_hysteresis [Preset: minimal] OK
Expand Down Expand Up @@ -1268,4 +1270,4 @@ OK: 48/48 Fail: 0/48 Skip: 0/48
OK: 30/30 Fail: 0/30 Skip: 0/30

---TOTAL---
OK: 1066/1086 Fail: 0/1086 Skip: 20/1086
OK: 1068/1088 Fail: 0/1088 Skip: 20/1088
30 changes: 28 additions & 2 deletions beacon_chain/spec/datatypes/altair.nim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const

# https://github.com/ethereum/consensus-specs/blob/v1.1.8/setup.py#L478-L479
FINALIZED_ROOT_INDEX* = 105.GeneralizedIndex
CURRENT_SYNC_COMMITTEE_INDEX* = 54.GeneralizedIndex
NEXT_SYNC_COMMITTEE_INDEX* = 55.GeneralizedIndex

# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#participation-flag-indices
Expand Down Expand Up @@ -152,12 +153,23 @@ type

### Modified/overloaded

# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/sync-protocol.md#lightclientbootstrap
LightClientBootstrap* = object
header*: BeaconBlockHeader ##\
## The requested beacon block header

# Current sync committee corresponding to the requested header
current_sync_committee*: SyncCommittee
current_sync_committee_branch*:
array[log2trunc(CURRENT_SYNC_COMMITTEE_INDEX), Eth2Digest]

# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/sync-protocol.md#lightclientupdate
LightClientUpdate* = object
attested_header*: BeaconBlockHeader ##\
## The beacon block header that is attested to by the sync committee

# Next sync committee corresponding to the active header
# Next sync committee corresponding to the active header,
# if signature is from current sync committee
next_sync_committee*: SyncCommittee
next_sync_committee_branch*:
array[log2trunc(NEXT_SYNC_COMMITTEE_INDEX), Eth2Digest]
Expand All @@ -167,11 +179,25 @@ type
finality_branch*: array[log2trunc(FINALIZED_ROOT_INDEX), Eth2Digest]

# Sync committee aggregate signature
sync_committee_aggregate*: SyncAggregate
sync_aggregate*: SyncAggregate

fork_version*: Version ##\
## Fork version for the aggregate signature

# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/sync-protocol.md#optimisticlightclientupdate
OptimisticLightClientUpdate* = object
attested_header*: BeaconBlockHeader ##\
## The beacon block header that is attested to by the sync committee

sync_aggregate*: SyncAggregate ##\
## Sync committee aggregate signature

fork_version*: Version ##\
## Fork version for the aggregate signature

is_signed_by_next_sync_committee*: bool ##\
## Whether the signature was produced by `attested_header`'s next sync committee

# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/sync-protocol.md#lightclientstore
LightClientStore* = object
finalized_header*: BeaconBlockHeader ##\
Expand Down
Loading

0 comments on commit efe08d0

Please sign in to comment.