Skip to content

Commit

Permalink
Refactor to set empty within the error
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Jan 13, 2023
1 parent 142cf8d commit 575e523
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions beacon-chain/rpc/prysm/v1alpha1/validator/proposer_altair.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@ func (vs *Server) setSyncAggregate(ctx context.Context, blk interfaces.BeaconBlo
return
}

// Set empty sync aggregate in case subsequent calls fail. Empty sync aggregate is better than failing.
emptySig := [96]byte{0xC0}
syncAggregate := &ethpb.SyncAggregate{
SyncCommitteeBits: make([]byte, params.BeaconConfig().SyncCommitteeSize),
SyncCommitteeSignature: emptySig[:],
}

var err error
syncAggregate, err = vs.getSyncAggregate(ctx, blk.Slot()-1, blk.ParentRoot())
syncAggregate, err := vs.getSyncAggregate(ctx, blk.Slot()-1, blk.ParentRoot())
if err != nil {
log.WithError(err).Error("Could not get sync aggregate")
emptySig := [96]byte{0xC0}
emptyAggregate := &ethpb.SyncAggregate{
SyncCommitteeBits: make([]byte, params.BeaconConfig().SyncCommitteeSize),
SyncCommitteeSignature: emptySig[:],
}
if err := blk.Body().SetSyncAggregate(emptyAggregate); err != nil {
log.WithError(err).Error("Could not set sync aggregate")
}
return
}

// Can not error. We already filter block versioning at the top. Phase 0 is impossible.
if err := blk.Body().SetSyncAggregate(syncAggregate); err != nil {
log.WithError(err).Error("Could not set sync aggregate")
}
Expand Down

0 comments on commit 575e523

Please sign in to comment.