-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Extract and test count_no_shows method for approval voting #3264
Conversation
0cf9c7a
to
dace0bf
Compare
}, | ||
]; | ||
|
||
for test in tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: I'd prefer each test to get its own #[test]
function which uses a helper function as the body of this loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know, will take note of that going forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rphmeier force pushed the change to create each test case individually. Should be good to go.
Yes, I think this is correct. The reasoning is that the I do think that a comment explaining logic in the API would be useful. cc @burdges to confirm |
This commit extracts no_show computation into a pure function so that it can be extensively unit tested.
dace0bf
to
20172c0
Compare
Yes, we want being no-show to indicate that you'll likely not show within any sane time period, like your power when off or you got DoS. If your assignment was late then your approval vote will likely be late too, so we measure no shows in wall time since we learned about your assignment. |
clock_drift: 10, | ||
no_show_duration: 10, | ||
drifted_tick_now: 20, | ||
exp_no_shows: 1, // TODO(ladi): should this be counted or ignored? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should validator indexes past the length of the approvals vector be ignored or handled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ignored; Garbage-in-Garbage-out
Please add a commit adding a comment to the |
Previously indexes that were past the length of the approvals bitvector would contribute to the no_show count or the next_no_show value. This commit changes the behavior to ignore garbage values.
@rphmeier Added comment and modified logic such that we ignore indexes past the length of the approval vector. Should be ready to go. |
bot merge |
Trying merge. |
This commit extracts no_show computation into a pure function so that it can be
extensively unit tested.
This commit extracts no_show computation into a pure function so that it can be extensively unit tested. So far the tests behave mostly as I would expect, though I plan on further expanding them to better test the interactions of the
Tick
parameters.The main thing that currently sticks out is the
next_no_show
calculation, which I suspect is adding an extraclock_drift
factor. For example, in the current test harness, a validator assigned at tick 20 is counted as a no_show when drifted_tick_now is also 20. However, a validator assigned at tick 21 (which would be counted as a no_show at a drifted_tick_now of 21) is reported as a next_no_show of 31 (21 + clock_drift). If this is the correct behavior I can continue to add unit tests on this interaction, but wanted to clarify before proceeding.