mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
check addrs match pubkeys in abci Validator. version bump
This commit is contained in:
parent
46fb179605
commit
fcf61b8088
16
CHANGELOG.md
16
CHANGELOG.md
@ -4,19 +4,21 @@
|
|||||||
|
|
||||||
*June 6th, 2018*
|
*June 6th, 2018*
|
||||||
|
|
||||||
BREAKING CHANGES
|
This is the first in a series of breaking releases coming to Tendermint after
|
||||||
|
soliciting developer feedback and conducting security audits.
|
||||||
|
|
||||||
- [abci] Upgrade to
|
This release does not break any blockchain data structures or
|
||||||
[v0.11.0](https://github.com/tendermint/abci/blob/master/CHANGELOG.md#0110)
|
|
||||||
- [abci] Query path for filtering peers by node ID changed from
|
|
||||||
`p2p/filter/pubkey/<id>` to `p2p/filter/id/<id>`
|
|
||||||
|
|
||||||
NOTE: this release does not break any blockchain data structures or
|
|
||||||
protocols other than the ABCI messages between Tendermint and the application.
|
protocols other than the ABCI messages between Tendermint and the application.
|
||||||
|
|
||||||
Applications that upgrade for ABCI v0.11.0 should be able to continue running Tendermint
|
Applications that upgrade for ABCI v0.11.0 should be able to continue running Tendermint
|
||||||
v0.20.0 on blockchains created with v0.19.X
|
v0.20.0 on blockchains created with v0.19.X
|
||||||
|
|
||||||
|
BREAKING CHANGES
|
||||||
|
|
||||||
|
- [abci] Upgrade to
|
||||||
|
[v0.11.0](https://github.com/tendermint/abci/blob/master/CHANGELOG.md#0110)
|
||||||
|
- [abci] Change Query path for filtering peers by node ID from
|
||||||
|
`p2p/filter/pubkey/<id>` to `p2p/filter/id/<id>`
|
||||||
|
|
||||||
## 0.19.9
|
## 0.19.9
|
||||||
|
|
||||||
|
@ -92,6 +92,19 @@ following rules:
|
|||||||
set with the given power
|
set with the given power
|
||||||
- if the validator does already exist, its power will be adjusted to the given power
|
- if the validator does already exist, its power will be adjusted to the given power
|
||||||
|
|
||||||
|
## InitChain Validator Updates
|
||||||
|
|
||||||
|
ResponseInitChain has the option to return a list of validators.
|
||||||
|
If the list is not empty, Tendermint will adopt it for the validator set.
|
||||||
|
This way the application can determine the initial validator set for the
|
||||||
|
blockchain.
|
||||||
|
|
||||||
|
Note that if addressses are included in the returned validators, they must match
|
||||||
|
the address of the public key.
|
||||||
|
|
||||||
|
ResponseInitChain also includes ConsensusParams, but these are presently
|
||||||
|
ignored.
|
||||||
|
|
||||||
## Query
|
## Query
|
||||||
|
|
||||||
Query is a generic message type with lots of flexibility to enable diverse sets
|
Query is a generic message type with lots of flexibility to enable diverse sets
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package state
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
fail "github.com/ebuchman/fail-test"
|
fail "github.com/ebuchman/fail-test"
|
||||||
@ -271,38 +270,23 @@ func getBeginBlockValidatorInfo(block *types.Block, lastValSet *types.ValidatorS
|
|||||||
// If more or equal than 1/3 of total voting power changed in one block, then
|
// If more or equal than 1/3 of total voting power changed in one block, then
|
||||||
// a light client could never prove the transition externally. See
|
// a light client could never prove the transition externally. See
|
||||||
// ./lite/doc.go for details on how a light client tracks validators.
|
// ./lite/doc.go for details on how a light client tracks validators.
|
||||||
func updateValidators(currentSet *types.ValidatorSet, updates []abci.Validator) error {
|
func updateValidators(currentSet *types.ValidatorSet, abciUpdates []abci.Validator) error {
|
||||||
for _, v := range updates {
|
updates, err := types.PB2TM.Validators(abciUpdates)
|
||||||
pubkey, err := types.PB2TM.PubKey(v.PubKey)
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
// mind the overflow from int64
|
|
||||||
if power < 0 {
|
|
||||||
return fmt.Errorf("Power (%d) overflows int64", v.Power)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// these are tendermint types now
|
||||||
|
for _, valUpdate := range updates {
|
||||||
|
address := valUpdate.Address
|
||||||
_, val := currentSet.GetByAddress(address)
|
_, val := currentSet.GetByAddress(address)
|
||||||
if val == nil {
|
if val == nil {
|
||||||
// add val
|
// add val
|
||||||
added := currentSet.Add(types.NewValidator(pubkey, power))
|
added := currentSet.Add(valUpdate)
|
||||||
if !added {
|
if !added {
|
||||||
return fmt.Errorf("Failed to add new validator %X with voting power %d", address, power)
|
return fmt.Errorf("Failed to add new validator %v", valUpdate)
|
||||||
}
|
}
|
||||||
} else if v.Power == 0 {
|
} else if valUpdate.VotingPower == 0 {
|
||||||
// remove val
|
// remove val
|
||||||
_, removed := currentSet.Remove(address)
|
_, removed := currentSet.Remove(address)
|
||||||
if !removed {
|
if !removed {
|
||||||
@ -310,10 +294,9 @@ func updateValidators(currentSet *types.ValidatorSet, updates []abci.Validator)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// update val
|
// update val
|
||||||
val.VotingPower = power
|
updated := currentSet.Update(valUpdate)
|
||||||
updated := currentSet.Update(val)
|
|
||||||
if !updated {
|
if !updated {
|
||||||
return fmt.Errorf("Failed to update validator %X with voting power %d", address, power)
|
return fmt.Errorf("Failed to update validator %X to %v", address, valUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
@ -175,8 +176,16 @@ func (pb2tm) Validators(vals []abci.Validator) ([]*Validator, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// If the app provided an address too, it must match.
|
||||||
|
// This is just a sanity check.
|
||||||
|
if len(v.Address) > 0 {
|
||||||
|
if !bytes.Equal(pub.Address(), v.Address) {
|
||||||
|
return nil, fmt.Errorf("Validator.Address (%X) does not match PubKey.Address (%X)",
|
||||||
|
v.Address, pub.Address())
|
||||||
|
}
|
||||||
|
}
|
||||||
tmVals[i] = &Validator{
|
tmVals[i] = &Validator{
|
||||||
Address: v.Address,
|
Address: pub.Address(),
|
||||||
PubKey: pub,
|
PubKey: pub,
|
||||||
VotingPower: v.Power,
|
VotingPower: v.Power,
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
// Version is the current version of Tendermint
|
// Version is the current version of Tendermint
|
||||||
// Must be a string because scripts like dist.sh read this file.
|
// Must be a string because scripts like dist.sh read this file.
|
||||||
Version = "0.20.0-dev"
|
Version = "0.20.0"
|
||||||
|
|
||||||
// GitCommit is the current HEAD set using ldflags.
|
// GitCommit is the current HEAD set using ldflags.
|
||||||
GitCommit string
|
GitCommit string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user