0.24.1 - Fix validator pubkey bug
This commit is contained in:
parent
d5652d9676
commit
e2691d98fc
|
@ -1,5 +1,14 @@
|
|||
# Changelog
|
||||
|
||||
## 0.24.1
|
||||
|
||||
*August 21st, 2018*
|
||||
|
||||
BUG FIXES
|
||||
|
||||
* Gaia
|
||||
- [x/slashing] Evidence tracking now uses validator address instead of validator pubkey
|
||||
|
||||
## 0.24.0
|
||||
|
||||
*August 13th, 2018*
|
||||
|
|
|
@ -3,9 +3,9 @@ package version
|
|||
|
||||
const Maj = "0"
|
||||
const Min = "24"
|
||||
const Fix = "0"
|
||||
const Fix = "1"
|
||||
|
||||
const Version = "0.24.0"
|
||||
const Version = "0.24.1"
|
||||
|
||||
// GitCommit set by build flags
|
||||
var GitCommit = ""
|
||||
|
|
|
@ -36,11 +36,15 @@ func NewKeeper(cdc *wire.Codec, key sdk.StoreKey, vs sdk.ValidatorSet, params pa
|
|||
}
|
||||
|
||||
// handle a validator signing two blocks at the same height
|
||||
func (k Keeper) handleDoubleSign(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight int64, timestamp time.Time, power int64) {
|
||||
func (k Keeper) handleDoubleSign(ctx sdk.Context, addr crypto.Address, infractionHeight int64, timestamp time.Time, power int64) {
|
||||
logger := ctx.Logger().With("module", "x/slashing")
|
||||
time := ctx.BlockHeader().Time
|
||||
age := time.Sub(timestamp)
|
||||
address := sdk.ValAddress(pubkey.Address())
|
||||
address := sdk.ValAddress(addr)
|
||||
pubkey, err := k.getPubkey(ctx, addr)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Validator address %v not found", addr))
|
||||
}
|
||||
|
||||
// Double sign too old
|
||||
maxEvidenceAge := k.MaxEvidenceAge(ctx)
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestHandleDoubleSign(t *testing.T) {
|
|||
keeper.handleValidatorSignature(ctx, val.Address(), amtInt, true)
|
||||
|
||||
// double sign less than max age
|
||||
keeper.handleDoubleSign(ctx, val, 0, time.Unix(0, 0), amtInt)
|
||||
keeper.handleDoubleSign(ctx, val.Address(), 0, time.Unix(0, 0), amtInt)
|
||||
|
||||
// should be revoked
|
||||
require.True(t, sk.Validator(ctx, addr).GetRevoked())
|
||||
|
@ -48,7 +48,7 @@ func TestHandleDoubleSign(t *testing.T) {
|
|||
ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(1, 0).Add(keeper.MaxEvidenceAge(ctx))})
|
||||
|
||||
// double sign past max age
|
||||
keeper.handleDoubleSign(ctx, val, 0, time.Unix(0, 0), amtInt)
|
||||
keeper.handleDoubleSign(ctx, val.Address(), 0, time.Unix(0, 0), amtInt)
|
||||
require.Equal(t, sdk.NewRatFromInt(amt).Mul(sdk.NewRat(19).Quo(sdk.NewRat(20))), sk.Validator(ctx, addr).GetPower())
|
||||
}
|
||||
|
||||
|
|
|
@ -29,13 +29,9 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, sk Keeper) (tags
|
|||
// Slash any validators (and since-unbonded stake within the unbonding period)
|
||||
// who contributed to valid infractions
|
||||
for _, evidence := range req.ByzantineValidators {
|
||||
pk, err := tmtypes.PB2TM.PubKey(evidence.Validator.PubKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
switch evidence.Type {
|
||||
case tmtypes.ABCIEvidenceTypeDuplicateVote:
|
||||
sk.handleDoubleSign(ctx, pk, evidence.Height, evidence.Time, evidence.Validator.Power)
|
||||
sk.handleDoubleSign(ctx, evidence.Validator.Address, evidence.Height, evidence.Time, evidence.Validator.Power)
|
||||
default:
|
||||
ctx.Logger().With("module", "x/slashing").Error(fmt.Sprintf("ignored unknown evidence type: %s", evidence.Type))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue