diff --git a/CHANGELOG.md b/CHANGELOG.md index f6b91607a..18b9d5348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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* diff --git a/version/version.go b/version/version.go index a2bee9eb2..707868ae0 100644 --- a/version/version.go +++ b/version/version.go @@ -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 = "" diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index 2f163e57a..373423b2d 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -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) diff --git a/x/slashing/keeper_test.go b/x/slashing/keeper_test.go index d3d6b06ed..dc65933f2 100644 --- a/x/slashing/keeper_test.go +++ b/x/slashing/keeper_test.go @@ -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()) } diff --git a/x/slashing/tick.go b/x/slashing/tick.go index 7478b511c..253daa412 100644 --- a/x/slashing/tick.go +++ b/x/slashing/tick.go @@ -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)) }