Merge PR: Merge master back into develop
This commit is contained in:
commit
18b067cd41
|
@ -1,5 +1,14 @@
|
||||||
# Changelog
|
# 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
|
## 0.24.0
|
||||||
|
|
||||||
*August 13th, 2018*
|
*August 13th, 2018*
|
||||||
|
|
|
@ -3,9 +3,9 @@ package version
|
||||||
|
|
||||||
const Maj = "0"
|
const Maj = "0"
|
||||||
const Min = "24"
|
const Min = "24"
|
||||||
const Fix = "0"
|
const Fix = "1"
|
||||||
|
|
||||||
const Version = "0.24.0"
|
const Version = "0.24.1"
|
||||||
|
|
||||||
// GitCommit set by build flags
|
// GitCommit set by build flags
|
||||||
var GitCommit = ""
|
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
|
// 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")
|
logger := ctx.Logger().With("module", "x/slashing")
|
||||||
time := ctx.BlockHeader().Time
|
time := ctx.BlockHeader().Time
|
||||||
age := time.Sub(timestamp)
|
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
|
// Double sign too old
|
||||||
maxEvidenceAge := k.MaxEvidenceAge(ctx)
|
maxEvidenceAge := k.MaxEvidenceAge(ctx)
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestHandleDoubleSign(t *testing.T) {
|
||||||
keeper.handleValidatorSignature(ctx, val.Address(), amtInt, true)
|
keeper.handleValidatorSignature(ctx, val.Address(), amtInt, true)
|
||||||
|
|
||||||
// double sign less than max age
|
// 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
|
// should be revoked
|
||||||
require.True(t, sk.Validator(ctx, addr).GetRevoked())
|
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))})
|
ctx = ctx.WithBlockHeader(abci.Header{Time: time.Unix(1, 0).Add(keeper.MaxEvidenceAge(ctx))})
|
||||||
|
|
||||||
// double sign past max age
|
// 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.NewDecFromInt(amt).Mul(sdk.NewDec(19).Quo(sdk.NewDec(20))), sk.Validator(ctx, addr).GetPower())
|
require.Equal(t, sdk.NewDecFromInt(amt).Mul(sdk.NewDec(19).Quo(sdk.NewDec(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)
|
// Slash any validators (and since-unbonded stake within the unbonding period)
|
||||||
// who contributed to valid infractions
|
// who contributed to valid infractions
|
||||||
for _, evidence := range req.ByzantineValidators {
|
for _, evidence := range req.ByzantineValidators {
|
||||||
pk, err := tmtypes.PB2TM.PubKey(evidence.Validator.PubKey)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
switch evidence.Type {
|
switch evidence.Type {
|
||||||
case tmtypes.ABCIEvidenceTypeDuplicateVote:
|
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:
|
default:
|
||||||
ctx.Logger().With("module", "x/slashing").Error(fmt.Sprintf("ignored unknown evidence type: %s", evidence.Type))
|
ctx.Logger().With("module", "x/slashing").Error(fmt.Sprintf("ignored unknown evidence type: %s", evidence.Type))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue