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

get_shuffling and get_attesters_and_proposers #33

Closed
jannikluhn opened this issue Jul 2, 2018 · 1 comment
Closed

get_shuffling and get_attesters_and_proposers #33

jannikluhn opened this issue Jul 2, 2018 · 1 comment

Comments

@jannikluhn
Copy link
Collaborator

From the spec:

def get_attesters_and_proposer(crystallized_state, active_state, skip_count):
    attestation_count = min(len(crystallized_state.active_validators), ATTESTER_COUNT)
    indices = get_shuffling(active_state.randao, len(crystallized_state.active_validators))
    return indices[:attestation_count], indices[attestation_count + skip_count]

This fails if attestation_count + skip_count >= len(active_validators) which is possible either if skip_count is large or if len(active_validators) < ATTESTER_COUNT. I think one should be able to fix this by using (attestation_count + skip_count) % len(active_validators) as the proposer index (but it would mean that the proposer is also an attester, not sure if that's an issue).

The implementation in this repository is a little bit more complicated because of the sample parameter, resulting in an infinity loop in get_shuffling: At some point remaining will be zero so the inner loop breaks, but the outer loop will still continue. Proposed fix here is to just get rid of the sample complexity and just yield each o[i] as soon as it's replaced.

Finally, this check seems to be useless: https://github.com/ethereum/beacon_chain/blob/master/beacon_chain/state/state_transition.py#L59.

@jannikluhn
Copy link
Collaborator Author

Same as #18

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

No branches or pull requests

1 participant