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 Weird Pre-Genesis Timestamp #6031

Merged
merged 4 commits into from
May 29, 2020
Merged

Fix Weird Pre-Genesis Timestamp #6031

merged 4 commits into from
May 29, 2020

Conversation

rauljordan
Copy link
Contributor

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

If the beacon node is pre-genesis (as in, a genesis time has yet to be determined), the result of

curl -X GET "http://localhost:4001/eth/v1alpha1/node/genesis" -H  "accept: application/json"

will be 0001-01-01T00:00:00Z, which is not a realistic value and returns -672637623 when attempting to convert into a unix timestamp. Instead, we should do a sensible default of unix timestamp 0.

Confirmed the result works:

{"genesisTime":"1970-01-01T00:00:00Z","depositContractAddress":"vhKJVwd36/uywA1nK2aeiStTAP4=","genesisValidatorsRoot":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="}

Which issues(s) does this PR fix?

Fixes #5548

@rauljordan rauljordan requested a review from a team as a code owner May 29, 2020 00:48
@rauljordan rauljordan changed the title ensure test passes Fix Weird Pre-Genesis Timestamp May 29, 2020
@rauljordan rauljordan added Enhancement New feature or request Ready For Review A pull request ready for code review labels May 29, 2020
Comment on lines 56 to 63
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not convert genesis time to proto: %v", err)
}
} else {
gt, err = ptypes.TimestampProto(genesisTime)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not convert genesis time to proto: %v", err)
}
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
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not convert genesis time to proto: %v", err)
}
} else {
gt, err = ptypes.TimestampProto(genesisTime)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not convert genesis time to proto: %v", err)
}
} else {
gt, err = ptypes.TimestampProto(genesisTime)
}
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not convert genesis time to proto: %v", err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Messed up the suggestion lol, but can you move the error check outside of the if statements? To not duplicate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants