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

Faster Doppelganger Check #9964

Merged
merged 3 commits into from
Dec 1, 2021
Merged

Faster Doppelganger Check #9964

merged 3 commits into from
Dec 1, 2021

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Dec 1, 2021

What type of PR is this?

Feature Improvement

What does this PR do? Why is it needed?

In the event all the keys provided to the rpc method have been recently observed, we choose to exit
the method early. The reason this is done is because performing state regeneration is expensive
and doing it for 2 states can take time. This allows validators to perform quicker restarts which is
required when updating the validator client software.

Additionally this PR also modifies a test case to check for this particular situation.

Which issues(s) does this PR fix?

N.A

Other notes for review

@nisdas nisdas added the Ready For Review A pull request ready for code review label Dec 1, 2021
@nisdas nisdas requested a review from a team as a code owner December 1, 2021 08:44
Copy link
Contributor

@potuz potuz left a comment

Choose a reason for hiding this comment

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

Re reading the PR, the test is not for the condition I read originally.

I think this check misses the case of a validator that has is actually recent like this is it's first epoch, second or third. Currently we can check for the second case since we can check if the balance at the start of the current epoch is larger than the balance at the previous epoch. So a validator with v.Epoch + 2 = currentEpoch is covered. In addition to this, when we fix the doppelganger for Altair, this method will also have to go, since in Altair we can check for flags in the current epoch state. So I feel that including this would be detrimental only covering a few cases of validators deposited between the next release and the one where we fix for Altair

// validators, we can only effectively determine if a
// validator voted or not if we are able to look
// back more than 2 epochs into the past.
if v.Epoch+2 >= headEpoch {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest

if v.Epoch+2 < headEpoch {
    validatorsAreRecent = false
    break
 }
 resp.Responses....

Copy link
Member Author

Choose a reason for hiding this comment

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

This is much cleaner

return transition.ProcessSlots(ctx, retState, retState.Slot()+1)
}

func (vs *Server) checkValidatorsAreRecent(headEpoch types.Epoch, req *ethpb.DoppelGangerRequest) (bool, *ethpb.DoppelGangerResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (vs *Server) checkValidatorsAreRecent(headEpoch types.Epoch, req *ethpb.DoppelGangerRequest) (bool, *ethpb.DoppelGangerResponse) {
func checkValidatorsAreRecent(headEpoch types.Epoch, req *ethpb.DoppelGangerRequest) (bool, *ethpb.DoppelGangerResponse) {

@potuz
Copy link
Contributor

potuz commented Dec 1, 2021

Optionally we may want to leave the number of states we check as a configurable parameter. These constants v.Epoch + 2 >= headEpoch should probably be something like v.Epoch + doppelgangerCheckedStates >= headEpoch. Because when Altair comes, I claim that we get the same level of security with one less state. Or perhaps highly complicated setups may want to do checks for longer.

@nisdas
Copy link
Member Author

nisdas commented Dec 1, 2021

@potuz We can potentially add that in a new PR. But given that we would have to change the schema of our request type for it, we would need to see how that would work out. Some users don't always update the beacon node and validator in lockstep.

@potuz
Copy link
Contributor

potuz commented Dec 1, 2021

@potuz We can potentially add that in a new PR. But given that we would have to change the schema of our request type for it, we would need to see how that would work out. Some users don't always update the beacon node and validator in lockstep.

I meant to have a constant in our configuration, no need to have it configurable by API now.

// validator voted or not if we are able to look
// back more than 2 epochs into the past.
if v.Epoch+2 < headEpoch {
validatorsAreRecent = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to to also set the response to nil here? so that we make sure that we are not using it by mistake?

@prylabs-bulldozer prylabs-bulldozer bot merged commit d94bf32 into develop Dec 1, 2021
@delete-merged-branch delete-merged-branch bot deleted the fasterCheck branch December 1, 2021 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants