-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use headstate for recent checkpoints #13746
Conversation
slot, err := slots.EpochStart(c.Epoch) | ||
if err != nil { | ||
return nil | ||
} | ||
st, err := s.HeadState(ctx) | ||
if err != nil { | ||
return nil | ||
} | ||
st, err = transition.ProcessSlotsUsingNextSlotCache(ctx, st, c.Root, slot) | ||
if err != nil { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wouldn't we want to cache the result of this in the check point attestation cache? Seems to me if there are N attestations trigger this condition then we will need to do this N times which could become a dos vector. Are state copy and process slots here that cheap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the NSC cache is a hit wouldn't this be already in the checkpoint cache? hmm probably better to follow on Slack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, we're getting these messages on attestations up to slot 5, so they are not in the NSC, I updated the checkpoint cache here.
e6196f0
to
0ddbdfe
Compare
if err != nil { | ||
return nil | ||
} | ||
st, err = transition.ProcessSlotsUsingNextSlotCache(ctx, st, c.Root, slot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried about advancing slots this way, this becomes expensive. why can't we just return the read only head state here ? If slot 0 is missed, the head state should still be able to verify an attestation from slot 31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the attestation is not from slot 31, it's from slot 0, you need to check that the attester is in the right committee
8dbad79
to
b96a52b
Compare
return nil | ||
} | ||
// Try if we have already set the checkpoint cache | ||
epochKey := strconv.FormatUint(uint64(c.Epoch), 10 /* base 10 */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have to move it up before you fetch the head state.
b96a52b
to
7d1d045
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The conditions make sense. We should clean up getAttPreState
with getRecentPreState
to remove the overlapping code later on
In the event a peer hasn't imported slot 0 and attests for slot 31 as target during slot 0. All prysm nodes that have seen the block in slot 0 and are receiving these attestations, go through the following in
gettAttPrestate
This code path is missed since
c.Epoch > headEpoch
.Later in the code we hit:
Forkchoice does not take
c
as viable for checkpoint because the only child (slot 0) does not satisfy the condition in it:Thus we are flooded with the message
This should result in poor attestation performance in slot 0 and inclusion in slot 1.
This PR implements that if the incoming checkpoint has epoch higher than the current head root and the block is canonical (this can only happen if the checkpoint is the actual headroot) then we return as state the head state advanced to the current slot.
Reviewer be advised: check about possible performance problems because of the slot processing.