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

Fetch the Correct Chain Head During AttestHead #1596

Merged
merged 17 commits into from
Feb 19, 2019
Merged

Conversation

rauljordan
Copy link
Contributor

@rauljordan rauljordan commented Feb 14, 2019

This is part of #1565


Description

Write why you are making the changes in this pull request

When fetching the information necessary to attest to a beacon block, we need to fetch the chain head from the beacon node. Instead, we were fetching a block at the assigned slot for the attestation, which could be nil and is different than what the spec mentions.

Another problem is that sometimes attesters are assigned to the same slot as proposers in rare instances, and in those instances we should be prioritizing proposer assignments.

Additionally, there was a discrepancy in fetching the epoch and justified epoch boundary block roots. The reference issue in the spec is here

Write a summary of the changes you are making

This PR uses the ChainHead() function from the db to fetch the canonical head when it is time to attest. It also changes the logic of the if condition in assignments to prioritize proposers over attesters.

if v.assignment.ProposerSlot == slot {
	return pb.ValidatorRole_PROPOSER
} else if v.assignment.AttesterSlot == slot {
	return pb.ValidatorRole_ATTESTER
}

@rauljordan rauljordan self-assigned this Feb 14, 2019
@rauljordan rauljordan added Ready For Review A pull request ready for code review Priority: High High priority item labels Feb 14, 2019
@rauljordan rauljordan added this to the Sapphire milestone Feb 14, 2019
@codecov
Copy link

codecov bot commented Feb 14, 2019

Codecov Report

Merging #1596 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1596   +/-   ##
=======================================
  Coverage   70.96%   70.96%           
=======================================
  Files          94       94           
  Lines        6695     6695           
=======================================
  Hits         4751     4751           
  Misses       1527     1527           
  Partials      417      417

if v.assignment.AttesterSlot == slot {
return pb.ValidatorRole_ATTESTER
} else if v.assignment.ProposerSlot == slot {
if v.assignment.ProposerSlot == slot {
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment here since this is now an important distinction. Something like: A validator could be assigned to propose and attest in the same slot. Proposing takes priority.

Also, if a validator is selected to do both, should they do both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

LGTM

@rauljordan rauljordan merged commit 3e46381 into master Feb 19, 2019
@rauljordan rauljordan deleted the attester-fix branch February 19, 2019 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High High priority item Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants