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

Can't save attestation target when head is nil #2530

Merged
merged 7 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions beacon-chain/rpc/attester_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ func (as *AttesterServer) AttestHead(ctx context.Context, att *pbp2p.Attestation

// Update attestation target for RPC server to run necessary fork choice.
// We need to retrieve the head block to get its parent root.
blk, err := as.beaconDB.Block(bytesutil.ToBytes32(att.Data.BeaconBlockRootHash32))
head, err := as.beaconDB.Block(bytesutil.ToBytes32(att.Data.BeaconBlockRootHash32))
if err != nil {
return nil, err
}
// If the head block is nil, we can't save the attestation target.
if head == nil {
return nil, fmt.Errorf("could not find head %#x in db", bytesutil.Trunc(att.Data.BeaconBlockRootHash32))
}
attTarget := &pbp2p.AttestationTarget{
Slot: att.Data.Slot,
BlockRoot: att.Data.BeaconBlockRootHash32,
ParentRoot: blk.ParentRootHash32,
ParentRoot: head.ParentRootHash32,
}
if err := as.beaconDB.SaveAttestationTarget(ctx, attTarget); err != nil {
return nil, fmt.Errorf("could not save attestation target")
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/proposer_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (ps *ProposerServer) PendingAttestations(ctx context.Context, req *pb.Pendi

log.WithError(err).WithFields(logrus.Fields{
"slot": att.Data.Slot - params.BeaconConfig().GenesisSlot,
"headRoot": bytesutil.Trunc(att.Data.BeaconBlockRootHash32)}).Warn(
"headRoot": fmt.Sprintf("%#x", bytesutil.Trunc(att.Data.BeaconBlockRootHash32))}).Info(
"Deleting failed pending attestation from DB")
if err := ps.beaconDB.DeleteAttestation(att); err != nil {
return nil, fmt.Errorf("could not delete failed attestation: %v", err)
Expand Down