Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test generator duplicate key issue #2651

Merged
merged 4 commits into from
Oct 7, 2021
Merged

Fix test generator duplicate key issue #2651

merged 4 commits into from
Oct 7, 2021

Conversation

hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Oct 6, 2021

Fix #2650

Issue

We have key conflicts in the genesis and sanity test generators.

  • phase_0_mods = {key: 'eth2spec.test.phase0.genesis.test_' + key for key in [
    'initialization',
    'validity',
    ]}
    altair_mods = phase_0_mods
    # we have new unconditional lines in `initialize_beacon_state_from_eth1` and we want to test it
    merge_mods = {
    **{key: 'eth2spec.test.merge.genesis.test_' + key for key in [
    'initialization',
    ]},
  • altair_mods = {**{key: 'eth2spec.test.altair.sanity.test_' + key for key in [
    'blocks',
    ]}, **phase_0_mods}
    merge_mods = {**{key: 'eth2spec.test.merge.sanity.test_' + key for key in [
    'blocks',
    ]}, **altair_mods}

In these test generators, the handler names were conflicting. Thus it did NOT generate the test vectors of the newer file.

How did I fix it

Add combine_mods helper to deal with the test sources.

  • p.s. usually I'd name it merge_mods, but you know, too confusing.

TODO

  • I got errors when I generated sanity tests:
➜ make detect_generator_incomplete
find ../consensus-spec-tests/tests -name "INCOMPLETE"
../consensus-spec-tests/tests/mainnet/merge/sanity/blocks/pyspec_tests/half_sync_committee_committee/INCOMPLETE
../consensus-spec-tests/tests/mainnet/merge/sanity/blocks/pyspec_tests/half_sync_committee_committee_genesis/INCOMPLETE
../consensus-spec-tests/tests/mainnet/altair/sanity/blocks/pyspec_tests/half_sync_committee_committee/INCOMPLETE
../consensus-spec-tests/tests/mainnet/altair/sanity/blocks/pyspec_tests/half_sync_committee_committee_genesis/INCOMPLETE

Update: fixed in 4ae8fb1


yield 'pre', state

block = build_empty_block_for_next_slot(spec, state)
block.body.sync_aggregate = spec.SyncAggregate(
sync_committee_bits=[index in participants for index in committee],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous sync_committee_bits would be incorrect if there are duplicate indices in committee.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously

if committee = [1, 2, 3, 1]
participants = [2, 1] <— that means the the 2nd and 4th items were selected, not 1st+2nd+4th

sync_committee_bits=[index in participants for index in committee] would be return [True, True, False, True]

The aggregate signature from compute_aggregate_sync_committee_signature would only include the 2nd sig once + 4th sig once rather than the duplicate sigs.

This fix

The new fix generates the correct sync_committee_bits first and then calculate the corresponding participants.

@hwwhww hwwhww requested review from djrtwo and ralexstokes October 6, 2021 19:48
Copy link
Member

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! great catch! left some feedback

Copy link
Member

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work! some minor feedback above

@hwwhww hwwhww merged commit 4b5d0c9 into dev Oct 7, 2021
@hwwhww hwwhww deleted the fix-testgen-key branch October 7, 2021 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No execution payload header in merge spec tests
2 participants