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

Use justified checkpoint from head state to build attestation #13703

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

terencechain
Copy link
Member

Currently, the justified checkpoint for attestation is derived from the fork choice store. To ensure maximal safety, the justified checkpoint for attestation should be derived from the head state and process slots across epoch boundaries when necessary.

@terencechain terencechain added the Ready For Review A pull request ready for code review label Mar 7, 2024
@terencechain terencechain requested a review from a team as a code owner March 7, 2024 17:00
@terencechain terencechain marked this pull request as draft March 7, 2024 18:46
@terencechain terencechain added Blocked Blocked by research or external factors and removed Blocked Blocked by research or external factors labels Mar 7, 2024
@terencechain terencechain marked this pull request as ready for review March 8, 2024 03:34
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.

LGTM

@prestonvanloon prestonvanloon added this pull request to the merge queue Mar 8, 2024
@prestonvanloon prestonvanloon removed this pull request from the merge queue due to a manual request Mar 8, 2024
@terencechain terencechain added this pull request to the merge queue Mar 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 8, 2024
@terencechain terencechain added this pull request to the merge queue Mar 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 8, 2024
nisdas
nisdas previously approved these changes Mar 8, 2024
@@ -401,7 +401,19 @@ func (s *Service) GetAttestationData(
if err != nil {
return nil, &RpcError{Reason: Internal, Err: errors.Wrap(err, "could not get target root")}
}
justifiedCheckpoint := s.FinalizedFetcher.CurrentJustifiedCheckpt()

headState, err := s.HeadFetcher.HeadState(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

you should fetch the read only version of the head state otherwise this will do a copy and blow up the memory of nodes running with many keys.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just one copy per slot because of the cache. But I'll change it to read-only because that's always better

if err != nil {
return nil, &RpcError{Reason: Internal, Err: errors.Wrap(err, "could not get head state")}
}
if coreTime.CurrentEpoch(headState) < slots.ToEpoch(req.Slot) { // Ensure justified checkpoint safety by processing head state across the boundary.
Copy link
Member

Choose a reason for hiding this comment

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

why advance though ? Previously we did not advance either

Copy link
Member Author

Choose a reason for hiding this comment

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

We did advance before. See #13300

@nisdas nisdas dismissed their stale review March 8, 2024 23:24

wrongly approved

@terencechain terencechain added this pull request to the merge queue Mar 11, 2024
Merged via the queue into develop with commit ec7949f Mar 11, 2024
16 of 17 checks passed
@terencechain terencechain deleted the head-state-jcp-att branch March 11, 2024 15:26
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.

3 participants