-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
51503b8
to
8eb6acd
Compare
for idx in range(idx_max): | ||
v = Validator(original_index=idx) | ||
# 4/5 of all validators are active | ||
if random.randint(0, 4): |
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.
I think it would be a bit cleaner to use random.random() < 0.8
, because it also allows fractions other than (n - 1) / n
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.
Also, I think this would be easier to understand without all the nesting. So I suggest to pick a random number in the beginning, and then do something like this:
if r < 0.2:
v.activation_epoch = FAR_FUTURE_EPOCH
v.exit_epoch = FAR_FUTURE_EPOCH
elif r < 0.2 + 0.25:
# validator will exit in foreseeable future
elif r < 0.45 + 0.25:
# ...
(even though adding the probabilities feels a bit messy, there's probably a better pattern for this)
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.
I really like the floating number approach, included it in my latest push.
I'm not really sold on the elif
with probability addition though. I don't think three-deep ifs are as scary.
This commit updates the validator shuffling generator and tries to make the test validator sets more life-like. constants.py: * Add FAR_FUTURE_EPOCH * Add ENTRY_EXIT_DELAY core_helpers.py: * Update the helpers needed for validator shuffling Remove enums.py: status flags are not used since 2018-12-28 tgen_shuffling.py: * Use a dynamic approach for generating diverse validator sets; pre-FAR_FUTURE_EPOCH epochs are kept small for readability * Change the YAML layout to include validator data needed for present-day shuffling yaml_objects.py: * Change ValidatorRecord name to Validator (as in spec); change fields for up-to-date shuffling * Remove ShardCommittee (not used for shuffling at all as of today) test_vector_shuffling.yml: * Regenerate
8eb6acd
to
cc3fa71
Compare
FYI this is up-to-date with v0.1 now. Applied most of the advice from @jannikluhn |
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.
LGTM
Update validator shuffling
This PR updates and improves validator shuffling generation.
This most likely needs some polishing. There's a couple things I'm not happy
with yet:
the active validators who didn't leave the set yet (no "soon-to-leaves" useful
for delay edge case testing)
Original commit message (may change as I squash new things into it):
Update test vec generation and make it dynamic
This commit updates the validator shuffling generator and tries to make
the test validator sets more life-like.
constants.py:
core_helpers.py:
Remove enums.py: status flags are not used since 2018-12-28
tgen_shuffling.py:
diverse validator sets; pre-FAR_FUTURE_EPOCH exit epochs truncated for
readability
present-day shuffling
yaml_objects.py:
for up-to-date shuffling
test_vector_shuffling.yml: