Skip to content

Commit

Permalink
Log grpc error chain (#7307)
Browse files Browse the repository at this point in the history
* Log error chain
* Merge refs/heads/master into error-msgs
* Merge refs/heads/master into error-msgs
  • Loading branch information
terencechain authored Sep 22, 2020
1 parent 568cd3c commit bbdd20e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions beacon-chain/rpc/beacon/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,8 @@ func (bs *Server) ListValidators(
} else {
reqState, err = bs.HeadFetcher.HeadState(ctx)
}

if err != nil {
return nil, status.Error(codes.Internal, "Could not get requested state")
return nil, status.Errorf(codes.Internal, "Could not get requested state: %v", err)
}

s, err := helpers.StartSlot(requestedEpoch)
Expand All @@ -228,7 +227,7 @@ func (bs *Server) ListValidators(
for _, index := range req.Indices {
val, err := reqState.ValidatorAtIndex(index)
if err != nil {
return nil, status.Error(codes.Internal, "Could not get validator")
return nil, status.Errorf(codes.Internal, "Could not get validator: %v", err)
}
validatorList = append(validatorList, &ethpb.Validators_ValidatorContainer{
Index: index,
Expand All @@ -248,7 +247,7 @@ func (bs *Server) ListValidators(
}
val, err := reqState.ValidatorAtIndex(index)
if err != nil {
return nil, status.Error(codes.Internal, "Could not get validator")
return nil, status.Errorf(codes.Internal, "Could not get validator: %v", err)
}
validatorList = append(validatorList, &ethpb.Validators_ValidatorContainer{
Index: index,
Expand All @@ -264,7 +263,7 @@ func (bs *Server) ListValidators(
for i := 0; i < reqState.NumValidators(); i++ {
val, err := reqState.ValidatorAtIndex(uint64(i))
if err != nil {
return nil, status.Error(codes.Internal, "Could not get validator")
return nil, status.Errorf(codes.Internal, "Could not get validator: %v", err)
}
validatorList = append(validatorList, &ethpb.Validators_ValidatorContainer{
Index: uint64(i),
Expand Down Expand Up @@ -346,7 +345,7 @@ func (bs *Server) GetValidator(
}
headState, err := bs.HeadFetcher.HeadState(ctx)
if err != nil {
return nil, status.Error(codes.Internal, "Could not get head state")
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err)
}
if requestingIndex {
if index >= uint64(headState.NumValidators()) {
Expand Down Expand Up @@ -498,20 +497,20 @@ func (bs *Server) GetValidatorParticipation(
nextEpochEndSlot--
requestedState, err := bs.StateGen.StateBySlot(ctx, nextEpochEndSlot)
if err != nil {
return nil, status.Error(codes.Internal, "Could not get state")
return nil, status.Errorf(codes.Internal, "Could not get state: %v", err)
}

v, b, err := precompute.New(ctx, requestedState)
if err != nil {
return nil, status.Error(codes.Internal, "Could not set up pre compute instance")
return nil, status.Errorf(codes.Internal, "Could not set up pre compute instance: %v", err)
}
_, b, err = precompute.ProcessAttestations(ctx, requestedState, v, b)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not pre compute attestations: %v", err)
}
headState, err := bs.HeadFetcher.HeadState(ctx)
if err != nil {
return nil, status.Error(codes.Internal, "Could not get head state")
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err)
}

return &ethpb.ValidatorParticipationResponse{
Expand Down Expand Up @@ -539,7 +538,7 @@ func (bs *Server) GetValidatorQueue(
) (*ethpb.ValidatorQueue, error) {
headState, err := bs.HeadFetcher.HeadState(ctx)
if err != nil {
return nil, status.Error(codes.Internal, "Could not get head state")
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err)
}
// Queue the validators whose eligible to activate and sort them by activation eligibility epoch number.
// Additionally, determine those validators queued to exit
Expand Down Expand Up @@ -806,7 +805,7 @@ func (bs *Server) GetIndividualVotes(
}
v, b, err = precompute.ProcessAttestations(ctx, requestedState, v, b)
if err != nil {
return nil, status.Error(codes.Internal, "Could not pre compute attestations")
return nil, status.Errorf(codes.Internal, "Could not pre compute attestations: %v", err)
}
vals := requestedState.ValidatorsReadOnly()
for _, index := range filteredIndices {
Expand Down

0 comments on commit bbdd20e

Please sign in to comment.