diff --git a/cmd/gaia/app/app.go b/cmd/gaia/app/app.go index 7ad3709a1..28904e1ac 100644 --- a/cmd/gaia/app/app.go +++ b/cmd/gaia/app/app.go @@ -87,8 +87,8 @@ func NewGaiaApp(logger log.Logger, db dbm.DB) *GaiaApp { app.SetInitChainer(app.initChainer) app.SetBeginBlocker(slashing.NewBeginBlocker(app.slashingKeeper)) app.SetEndBlocker(stake.NewEndBlocker(app.stakeKeeper)) - app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyIBC, app.keyStake) app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper)) + app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyIBC, app.keyStake, app.keySlashing) err := app.LoadLatestVersion(app.keyMain) if err != nil { cmn.Exit(err.Error()) diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index f1aac7f58..4945da6a7 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -85,7 +85,7 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, pubkey crypto.PubKey, } index := height % SignedBlocksWindow address := pubkey.Address() - signInfo := k.getValidatorSigningInfo(ctx, address) + signInfo, _ := k.getValidatorSigningInfo(ctx, address) previous := k.getValidatorSigningBitArray(ctx, address, index) if previous && !signed { k.setValidatorSigningBitArray(ctx, address, index, false) @@ -106,10 +106,15 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, pubkey crypto.PubKey, } } -func (k Keeper) getValidatorSigningInfo(ctx sdk.Context, address sdk.Address) (info validatorSigningInfo) { +func (k Keeper) getValidatorSigningInfo(ctx sdk.Context, address sdk.Address) (info validatorSigningInfo, found bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(validatorSigningInfoKey(address)) - k.cdc.MustUnmarshalBinary(bz, &info) + if bz == nil { + found = false + } else { + k.cdc.MustUnmarshalBinary(bz, &info) + found = true + } return } @@ -122,7 +127,12 @@ func (k Keeper) setValidatorSigningInfo(ctx sdk.Context, address sdk.Address, in func (k Keeper) getValidatorSigningBitArray(ctx sdk.Context, address sdk.Address, index int64) (signed bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(validatorSigningBitArrayKey(address, index)) - k.cdc.MustUnmarshalBinary(bz, &signed) + if bz == nil { + // lazy: treat empty key as unsigned + signed = false + } else { + k.cdc.MustUnmarshalBinary(bz, &signed) + } return }