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

Strict ValidatorIndex definition #1714

Merged
merged 2 commits into from
Apr 14, 2020
Merged

Strict ValidatorIndex definition #1714

merged 2 commits into from
Apr 14, 2020

Conversation

hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Apr 9, 2020

Issue

We defined that ValidatorIndex is the index number for state.validators.
By that definition, the input parameter index in compute_shuffled_index is the position of the index_count-size Sequence[ValidatorIndex], not ValidatorIndex.

I found it by looking at the line assert index < index_count since IMO it's wrong if the given index is really a ValidatorIndex.

How did I fix it

This PR only removes the wrong type casting, no substantive change for PySpec, but I'm not sure about how other client implementations deal with casting.

@@ -722,24 +722,24 @@ def is_valid_merkle_branch(leaf: Bytes32, branch: Sequence[Bytes32], depth: uint
#### `compute_shuffled_index`

```python
def compute_shuffled_index(index: ValidatorIndex, index_count: uint64, seed: Bytes32) -> ValidatorIndex:
def compute_shuffled_index(index: uint64, index_count: uint64, seed: Bytes32) -> uint64:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the input param should be renamed offset as further differentiation?

@hwwhww hwwhww changed the base branch from dev to v012x April 10, 2020 06:35
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.

This looks good to me.
Should be a no-op to update for clients. Will release with IETF in v012x

@djrtwo djrtwo merged commit 1e9df66 into v012x Apr 14, 2020
@djrtwo djrtwo deleted the hwwhww/validator_index branch April 14, 2020 17:52
@hwwhww hwwhww added this to the v0.12.0 milestone May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants