diff --git a/PENDING.md b/PENDING.md index 6c731d2248bd..44a4f87b68da 100644 --- a/PENDING.md +++ b/PENDING.md @@ -42,6 +42,7 @@ BREAKING CHANGES * [x/gov] [#2195] Governance uses BFT Time * [x/gov] \#2256 Removed slashing for governance non-voting validators * [simulation] \#2162 Added back correct supply invariants + * [x/slashing] \#2430 Simulate more slashes, check if validator is jailed before jailing * SDK * [core] \#2219 Update to Tendermint 0.24.0 diff --git a/scripts/multisim.sh b/scripts/multisim.sh index c6437f4210e2..8ffa338b84e5 100755 --- a/scripts/multisim.sh +++ b/scripts/multisim.sh @@ -1,6 +1,6 @@ #!/bin/bash -seeds=(1 2 4 7 9 20 32 123 4728 37827 981928 87821 891823782 989182 89182391) +seeds=(1 2 4 7 9 20 32 123 124 582 1893 2989 3012 4728 37827 981928 87821 891823782 989182 89182391) blocks=$1 echo "Running multi-seed simulation with seeds ${seeds[@]}" @@ -28,7 +28,7 @@ for seed in ${seeds[@]}; do sim $seed & pids[${i}]=$! i=$(($i+1)) - sleep 5 # start in order, nicer logs + sleep 10 # start in order, nicer logs done echo "Simulation processes spawned, waiting for completion..." @@ -40,11 +40,12 @@ for pid in ${pids[*]}; do wait $pid last=$? seed=${seeds[${i}]} - if [ $last -ne 0 ]; then + if [ $last -ne 0 ] + then echo "Simulation with seed $seed failed!" code=1 else - echo "Simulation with seed $seed OK!" + echo "Simulation with seed $seed OK" fi i=$(($i+1)) done diff --git a/x/mock/simulation/constants.go b/x/mock/simulation/constants.go index 544da50e3e3e..a96d4541f186 100644 --- a/x/mock/simulation/constants.go +++ b/x/mock/simulation/constants.go @@ -14,7 +14,7 @@ const ( numKeys int = 250 // Chance that double-signing evidence is found on a given block - evidenceFraction float64 = 0.01 + evidenceFraction float64 = 0.5 // TODO Remove in favor of binary search for invariant violation onOperation bool = false diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index e61c1d9fbf9b..dc316b2b6f78 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -77,7 +77,7 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio k.validatorSet.Jail(ctx, consAddr) } - // Set validator jail duration + // Set or updated validator jail duration signInfo, found := k.getValidatorSigningInfo(ctx, consAddr) if !found { panic(fmt.Sprintf("Expected signing info for validator %s but not found", consAddr)) diff --git a/x/slashing/keys.go b/x/slashing/keys.go index 183dfde60d18..4303f4635e4c 100644 --- a/x/slashing/keys.go +++ b/x/slashing/keys.go @@ -35,7 +35,7 @@ func GetValidatorSlashingPeriodPrefix(v sdk.ConsAddress) []byte { func GetValidatorSlashingPeriodKey(v sdk.ConsAddress, startHeight int64) []byte { b := make([]byte, 8) // this needs to be height + 1 because the slashing period for genesis validators starts at height -1 - binary.LittleEndian.PutUint64(b, uint64(startHeight+1)) + binary.BigEndian.PutUint64(b, uint64(startHeight+1)) return append(GetValidatorSlashingPeriodPrefix(v), b...) } diff --git a/x/slashing/slashing_period.go b/x/slashing/slashing_period.go index 923cac44c9c3..1d94aa55993e 100644 --- a/x/slashing/slashing_period.go +++ b/x/slashing/slashing_period.go @@ -15,7 +15,7 @@ func (k Keeper) capBySlashingPeriod(ctx sdk.Context, address sdk.ConsAddress, fr // Sanity check if slashingPeriod.EndHeight > 0 && slashingPeriod.EndHeight < infractionHeight { - panic(fmt.Sprintf("slashing period ended before infraction: infraction height %d, slashing period ended at %d", infractionHeight, slashingPeriod.EndHeight)) + panic(fmt.Sprintf("slashing period ended before infraction: validator %s, infraction height %d, slashing period ended at %d", address, infractionHeight, slashingPeriod.EndHeight)) } // Calculate the updated total slash amount @@ -43,7 +43,7 @@ func (k Keeper) getValidatorSlashingPeriodForHeight(ctx sdk.Context, address sdk end := sdk.PrefixEndBytes(GetValidatorSlashingPeriodKey(address, height)) iterator := store.ReverseIterator(start, end) if !iterator.Valid() { - panic("expected to find slashing period, but none was found") + panic(fmt.Sprintf("expected to find slashing period for validator %s before height %d, but none was found", address, height)) } slashingPeriod = k.unmarshalSlashingPeriodKeyValue(iterator.Key(), iterator.Value()) return @@ -68,7 +68,7 @@ func (k Keeper) unmarshalSlashingPeriodKeyValue(key []byte, value []byte) Valida var slashingPeriodValue ValidatorSlashingPeriodValue k.cdc.MustUnmarshalBinary(value, &slashingPeriodValue) address := sdk.ConsAddress(key[1 : 1+sdk.AddrLen]) - startHeight := int64(binary.LittleEndian.Uint64(key[1+sdk.AddrLen:1+sdk.AddrLen+8]) - 1) + startHeight := int64(binary.BigEndian.Uint64(key[1+sdk.AddrLen:1+sdk.AddrLen+8]) - 1) return ValidatorSlashingPeriod{ ValidatorAddr: address, StartHeight: startHeight,