mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
[types] dont hash validator.Accum
This commit is contained in:
parent
cc2b430e68
commit
6d83c60c40
@ -25,6 +25,7 @@ BREAKING CHANGES:
|
|||||||
- Introduce EventDataInner for serializing events
|
- Introduce EventDataInner for serializing events
|
||||||
- remove all use of go-wire around user interfaces
|
- remove all use of go-wire around user interfaces
|
||||||
- rpc responses no longer have type information :)
|
- rpc responses no longer have type information :)
|
||||||
|
- [types] Do not include the `Accum` field when computing the hash of a validator. This makes the ValidatorSetHash unique for a given validator set, rather than changing with every block (as the Accum changes)
|
||||||
|
|
||||||
|
|
||||||
FEATURES:
|
FEATURES:
|
||||||
|
@ -12,13 +12,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Volatile state for each Validator
|
// Volatile state for each Validator
|
||||||
// TODO: make non-volatile identity
|
// NOTE: The Accum is not included in Validator.Hash();
|
||||||
// - Remove Accum - it can be computed, and now valset becomes identifying
|
// make sure to update that method if changes are made here
|
||||||
type Validator struct {
|
type Validator struct {
|
||||||
Address data.Bytes `json:"address"`
|
Address data.Bytes `json:"address"`
|
||||||
PubKey crypto.PubKey `json:"pub_key"`
|
PubKey crypto.PubKey `json:"pub_key"`
|
||||||
VotingPower int64 `json:"voting_power"`
|
VotingPower int64 `json:"voting_power"`
|
||||||
Accum int64 `json:"accum"`
|
|
||||||
|
Accum int64 `json:"accum"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewValidator(pubKey crypto.PubKey, votingPower int64) *Validator {
|
func NewValidator(pubKey crypto.PubKey, votingPower int64) *Validator {
|
||||||
@ -69,8 +70,18 @@ func (v *Validator) String() string {
|
|||||||
v.Accum)
|
v.Accum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hash computes the unique ID of a validator with a given voting power.
|
||||||
|
// It exludes the Accum value, which changes with every round.
|
||||||
func (v *Validator) Hash() []byte {
|
func (v *Validator) Hash() []byte {
|
||||||
return wire.BinaryRipemd160(v)
|
return wire.BinaryRipemd160(struct {
|
||||||
|
Address data.Bytes
|
||||||
|
PubKey crypto.PubKey
|
||||||
|
VotingPower int64
|
||||||
|
}{
|
||||||
|
v.Address,
|
||||||
|
v.PubKey,
|
||||||
|
v.VotingPower,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
// NOTE: Not goroutine-safe.
|
// NOTE: Not goroutine-safe.
|
||||||
// NOTE: All get/set to validators should copy the value for safety.
|
// NOTE: All get/set to validators should copy the value for safety.
|
||||||
// TODO: consider validator Accum overflow
|
// TODO: consider validator Accum overflow
|
||||||
// TODO: move valset into an iavl tree where key is 'blockbonded|pubkey'
|
|
||||||
type ValidatorSet struct {
|
type ValidatorSet struct {
|
||||||
// NOTE: persisted via reflect, must be exported.
|
// NOTE: persisted via reflect, must be exported.
|
||||||
Validators []*Validator `json:"validators"`
|
Validators []*Validator `json:"validators"`
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: privValidators are in order
|
// NOTE: privValidators are in order
|
||||||
// TODO: Move it out?
|
|
||||||
func randVoteSet(height int, round int, type_ byte, numValidators int, votingPower int64) (*VoteSet, *ValidatorSet, []*PrivValidator) {
|
func randVoteSet(height int, round int, type_ byte, numValidators int, votingPower int64) (*VoteSet, *ValidatorSet, []*PrivValidator) {
|
||||||
valSet, privValidators := RandValidatorSet(numValidators, votingPower)
|
valSet, privValidators := RandValidatorSet(numValidators, votingPower)
|
||||||
return NewVoteSet("test_chain_id", height, round, type_, valSet), valSet, privValidators
|
return NewVoteSet("test_chain_id", height, round, type_, valSet), valSet, privValidators
|
||||||
|
Loading…
x
Reference in New Issue
Block a user