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

Correct duties calculation for old slots #11723

Merged
merged 9 commits into from
Dec 14, 2022
Merged

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Dec 6, 2022

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

All our duties' calculation are based on the head state, which means that fetching duties older than SLOTS_PER_HISTORICAL_ROOT produces wrong results. This is because the state does not contain block roots older than SLOTS_PER_HISTORICAL_ROOT and these roots are used when:

  • computing duty assignments
  • returning the dependent root

This PR also reverts some changes from #11015. Because we use dependentRootSlot = epochStartSlot.Sub(1) as the slot, the initial dependent root calculation originally worked fine for the next epoch. The update from 11015 stops working with the current changes because dependentRootSlot >= s.Slot() no longer checks for future slots (at least not always) when we don't use the head state.

Which issues(s) does this PR fix?

Fixes #11628

@rkapka rkapka requested a review from a team as a code owner December 6, 2022 14:55
@rkapka rkapka added Ready For Review API Api related tasks labels Dec 6, 2022
james-prysm
james-prysm previously approved these changes Dec 6, 2022
Copy link
Contributor

@james-prysm james-prysm left a comment

Choose a reason for hiding this comment

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

Makes sense to me but might want terence to look since it is reverting his changes.

@james-prysm james-prysm dismissed their stale review December 6, 2022 16:03

failing unit test

@rkapka
Copy link
Contributor Author

rkapka commented Dec 6, 2022

This needs more careful thought. Marking as draft for now.

@rkapka rkapka marked this pull request as draft December 6, 2022 16:24
@rkapka rkapka marked this pull request as ready for review December 7, 2022 17:58
@@ -268,21 +267,38 @@ func TestGetProposerDuties(t *testing.T) {
}
vid, _, has := vs.ProposerSlotIndexCache.GetProposerPayloadIDs(11, [32]byte{})
require.Equal(t, true, has)
require.Equal(t, types.ValidatorIndex(12289), vid)
require.Equal(t, types.ValidatorIndex(9982), vid)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changed because state's slot changed from 5 to params.BeaconConfig().SlotsPerEpoch. The implementation will always fetch a slot at an epoch boundary, which is why I modified the slot in the test.

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!

@prylabs-bulldozer prylabs-bulldozer bot merged commit 9efc89f into develop Dec 14, 2022
@delete-merged-branch delete-merged-branch bot deleted the fix-dependent-root branch December 14, 2022 00:33
roberto-bayardo pushed a commit to roberto-bayardo/prysm that referenced this pull request Dec 17, 2022
* initial code

* update proposalDependentRoot

* convert method to function

* decouple tests

Co-authored-by: terencechain <terence@prysmaticlabs.com>
PatriceVignola added a commit to PatriceVignola/prysm that referenced this pull request Dec 21, 2022
PatriceVignola added a commit to PatriceVignola/prysm that referenced this pull request Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The dependent_root value of API eth/v1/validator/duties/proposer/{epoch} is wrong.
3 participants