Skip to content

Commit

Permalink
fix(types): throw error on invalid pubkey in ValidatorSetFromProtoUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed May 15, 2024
1 parent 4bc98b0 commit 0f0adc2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions types/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,18 @@ func (pb2tm) ValidatorSetFromProtoUpdate(
valSetUpdate *abci.ValidatorSetUpdate,
) (*ValidatorSet, error) {
hasPublicKeys := true
for _, v := range valSetUpdate.ValidatorUpdates {
for i, v := range valSetUpdate.ValidatorUpdates {
if v.PubKey == nil {
hasPublicKeys = false
break
}

pubkey, err := cryptoenc.PubKeyFromProto(*v.PubKey)
if err != nil || len(pubkey.Bytes()) == 0 {
hasPublicKeys = false
break
if err != nil {
return nil, fmt.Errorf("invalid pubkey of validator %d (%x) in valset update: %w", i, v.ProTxHash, err)
}
if len(pubkey.Bytes()) == 0 {
return nil, fmt.Errorf("pubkey of validator %d (%x) in valset update has zero length", i, v.ProTxHash)
}
}

Expand Down

0 comments on commit 0f0adc2

Please sign in to comment.