Browse Source

ResponseEndBlock: ensure Address matches PubKey if provided

pull/1701/head
Ethan Buchman 7 years ago
parent
commit
6b8613b3e7
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      state/execution.go

+ 11
- 0
state/execution.go View File

@ -1,6 +1,7 @@
package state package state
import ( import (
"bytes"
"fmt" "fmt"
fail "github.com/ebuchman/fail-test" fail "github.com/ebuchman/fail-test"
@ -278,6 +279,16 @@ func updateValidators(currentSet *types.ValidatorSet, updates []abci.Validator)
} }
address := pubkey.Address() address := pubkey.Address()
// If the app provided an address too, it must match.
// This is just a sanity check.
if len(v.Address) > 0 {
if !bytes.Equal(address, v.Address) {
return fmt.Errorf("Validator.Address (%X) does not match PubKey.Address (%X)",
v.Address, address)
}
}
power := int64(v.Power) power := int64(v.Power)
// mind the overflow from int64 // mind the overflow from int64
if power < 0 { if power < 0 {


Loading…
Cancel
Save