| 375 | } |
| 376 | |
| 377 | func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, |
| 378 | params tmproto.ValidatorParams) error { |
| 379 | for _, valUpdate := range abciUpdates { |
| 380 | if valUpdate.GetPower() < 0 { |
| 381 | return fmt.Errorf("voting power can't be negative %v", valUpdate) |
| 382 | } else if valUpdate.GetPower() == 0 { |
| 383 | // continue, since this is deleting the validator, and thus there is no |
| 384 | // pubkey to check |
| 385 | continue |
| 386 | } |
| 387 | |
| 388 | // Check if validator's pubkey matches an ABCI type in the consensus params |
| 389 | pk, err := cryptoenc.PubKeyFromProto(valUpdate.PubKey) |
| 390 | if err != nil { |
| 391 | return err |
| 392 | } |
| 393 | |
| 394 | if !types.IsValidPubkeyType(params, pk.Type()) { |
| 395 | return fmt.Errorf("validator %v is using pubkey %s, which is unsupported for consensus", |
| 396 | valUpdate, pk.Type()) |
| 397 | } |
| 398 | } |
| 399 | return nil |
| 400 | } |
| 401 | |
| 402 | // updateState returns a new State updated according to the header and responses. |
| 403 | func updateState( |