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

Fix Head References #4852

Closed
wants to merge 7 commits into from
Closed

Fix Head References #4852

wants to merge 7 commits into from

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Feb 13, 2020

Previously we were referring to the head root and head slot via a field in the blockchain service and its corresponding root in canonical_roots. However this had a flaw, as it assumed that each slot had only 1 root. However during periods without finality and a lot of forks, each slot can have multiple blocks.

This PR instead removes head slot and replaces with a head identifier, so that we can easily glean the current head slot and root from it. This also makes sure that we return the right data when forks occur.

@nisdas nisdas added Ready For Review A pull request ready for code review Priority: High High priority item labels Feb 13, 2020
@codecov
Copy link

codecov bot commented Feb 13, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@8e8eb5c). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master    #4852   +/-   ##
=========================================
  Coverage          ?   44.21%           
=========================================
  Files             ?      203           
  Lines             ?    15078           
  Branches          ?        0           
=========================================
  Hits              ?     6666           
  Misses            ?     7339           
  Partials          ?     1073

@nisdas nisdas mentioned this pull request Feb 13, 2020
nisdas and others added 2 commits February 13, 2020 18:48
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.

I need some convincing on why make(map[uint64][]byte) wouldn't work. This tracks the canonical root of the slot. Sure there can be multiple block roots for a given slot but there can only be one head root for a slot which is the point of this map, one head root for one slot because we don't need to care rest of the orphaned block roots in that slot

@@ -5,6 +5,8 @@ import (
"context"
"time"

"github.com/prysmaticlabs/prysm/shared/bytesutil"

Copy link
Member

Choose a reason for hiding this comment

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

goimports

r := [32]byte{'A'}
service.canonicalRoots[0] = r[:]

copy(identifier[:8], bytesutil.Bytes8(0))
Copy link
Member

Choose a reason for hiding this comment

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

I think a lot of these can be refactored into its own function to reduce disparity down the line

@prestonvanloon
Copy link
Member

What is the status of this? Was this resolved in #4869 ?

@nisdas
Copy link
Member Author

nisdas commented Feb 16, 2020

Yes, that supersedes this PR. I am closing this

@nisdas nisdas closed this Feb 16, 2020
@rauljordan rauljordan deleted the fixHead branch October 13, 2020 15:17
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.

None yet

4 participants