Skip to content

Add tests to test sync aggregate's order of balance operation#3157

Merged
djrtwo merged 2 commits intodevfrom
balance-op
Dec 14, 2022
Merged

Add tests to test sync aggregate's order of balance operation#3157
djrtwo merged 2 commits intodevfrom
balance-op

Conversation

@hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Dec 13, 2022

Thank the Prysm team for proposing this test case.

  • sync_committee_rewards_duplicate_committee_only_participate_first_one and sync_committee_rewards_duplicate_committee_only_participate_second_one both:
    • validator_index validator gets selected twice in the sync committee (duplicate).
    • validator_index validator's balance is 0.
  • sync_committee_rewards_duplicate_committee_only_participate_first_one:
    • only participate in the first sync committee responsibility
    • balance changes:
      • [first responsibility] 0 + reward x = x
      • [second responsibility] x - penalty x = 0
  • sync_committee_rewards_duplicate_committee_only_participate_second_one:
    • only participate in the second sync committee responsibility
    • balance changes:
      • [first responsibility] 0 - penalty x = 0 (due to underflow protection)
      • [second responsibility] 0 + reward x = x

@hwwhww hwwhww added the testing CI, actions, tests, testing infra label Dec 13, 2022
Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

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

Looks good. a few nits on code duplication but otherwise good to go

Comment on lines 227 to 228
assert active_validator_count < spec.SYNC_COMMITTEE_SIZE
assert committee_size > len(set(committee_indices))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move this up higher so it's more of a "blocking condition" at the top of the test rather than midway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ralexstokes iiuc the preconditions were about duplicate or nonduplicate?

I changed it to be checked with is_duplicate_sync_committee helper in c7e102a. IMO it's more explicit and more precise than checking with committee size.

spec, state, committee_indices, committee_bits,
skip_reward_validation=skip_reward_validation)

return validator_index
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@djrtwo I remember you hated that I returned variables from a yielding function 😅 but it is so tempting here...
otherwise, I have to break _run_sync_committee_selected_twice into two functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I won't stop you

@hwwhww hwwhww requested a review from djrtwo December 14, 2022 14:21
Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

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

nice cleanups!

@djrtwo djrtwo merged commit 991f817 into dev Dec 14, 2022
@djrtwo djrtwo deleted the balance-op branch December 14, 2022 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing CI, actions, tests, testing infra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants