diff --git a/x/gov/handler.go b/x/gov/handler.go index 6424bb0a1056..5e45571552a6 100644 --- a/x/gov/handler.go +++ b/x/gov/handler.go @@ -114,8 +114,14 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) (resTags sdk.Tags) { resTags.AppendTag(tags.Action, tags.ActionProposalDropped) resTags.AppendTag(tags.ProposalID, proposalIDBytes) - logger.Info(fmt.Sprintf("Proposal %d - \"%s\" - didn't mean minimum deposit (had only %s), deleted", - inactiveProposal.GetProposalID(), inactiveProposal.GetTitle(), inactiveProposal.GetTotalDeposit())) + logger.Info( + fmt.Sprintf("proposal %d (%s) didn't meet minimum deposit of %v steak (had only %s steak); deleted", + inactiveProposal.GetProposalID(), + inactiveProposal.GetTitle(), + keeper.GetDepositProcedure(ctx).MinDeposit.AmountOf("steak"), + inactiveProposal.GetTotalDeposit().AmountOf("steak"), + ), + ) } // Check if earliest Active Proposal ended voting period yet @@ -143,7 +149,7 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) (resTags sdk.Tags) { activeProposal.SetTallyResult(tallyResults) keeper.SetProposal(ctx, activeProposal) - logger.Info(fmt.Sprintf("Proposal %d - \"%s\" - tallied, passed: %v", + logger.Info(fmt.Sprintf("proposal %d (%s) tallied; passed: %v", activeProposal.GetProposalID(), activeProposal.GetTitle(), passes)) for _, valAddr := range nonVotingVals { @@ -154,7 +160,7 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) (resTags sdk.Tags) { val.GetPower().RoundInt64(), keeper.GetTallyingProcedure(ctx).GovernancePenalty) - logger.Info(fmt.Sprintf("Validator %s failed to vote on proposal %d, slashing", + logger.Info(fmt.Sprintf("validator %s failed to vote on proposal %d; slashing", val.GetOperator(), activeProposal.GetProposalID())) } diff --git a/x/gov/queryable.go b/x/gov/queryable.go index 090b9a91455a..6aa0c9884a44 100644 --- a/x/gov/queryable.go +++ b/x/gov/queryable.go @@ -8,22 +8,33 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) +// query endpoints supported by the governance Querier +const ( + QueryProposals = "proposals" + QueryProposal = "proposal" + QueryDeposits = "deposits" + QueryDeposit = "deposit" + QueryVotes = "votes" + QueryVote = "vote" + QueryTally = "tally" +) + func NewQuerier(keeper Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err sdk.Error) { switch path[0] { - case "proposal": + case QueryProposals: + return queryProposals(ctx, path[1:], req, keeper) + case QueryProposal: return queryProposal(ctx, path[1:], req, keeper) - case "deposit": - return queryDeposit(ctx, path[1:], req, keeper) - case "vote": - return queryVote(ctx, path[1:], req, keeper) - case "deposits": + case QueryDeposits: return queryDeposits(ctx, path[1:], req, keeper) - case "votes": + case QueryDeposit: + return queryDeposit(ctx, path[1:], req, keeper) + case QueryVotes: return queryVotes(ctx, path[1:], req, keeper) - case "proposals": - return queryProposals(ctx, path[1:], req, keeper) - case "tally": + case QueryVote: + return queryVote(ctx, path[1:], req, keeper) + case QueryTally: return queryTally(ctx, path[1:], req, keeper) default: return nil, sdk.ErrUnknownRequest("unknown gov query endpoint") diff --git a/x/stake/keeper/slash.go b/x/stake/keeper/slash.go index 5a004e807a54..52dbd21c7e19 100644 --- a/x/stake/keeper/slash.go +++ b/x/stake/keeper/slash.go @@ -28,7 +28,7 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in logger := ctx.Logger().With("module", "x/stake") if slashFactor.LT(sdk.ZeroDec()) { - panic(fmt.Errorf("attempted to slash with a negative slashFactor: %v", slashFactor)) + panic(fmt.Errorf("attempted to slash with a negative slash factor: %v", slashFactor)) } // Amount of slashing = slash slashFactor * power at time of infraction @@ -50,7 +50,7 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in // should not be slashing unbonded if validator.IsUnbonded(ctx) { - panic(fmt.Sprintf("should not be slashing unbonded validator: %v", validator)) + panic(fmt.Sprintf("should not be slashing unbonded validator: %s", validator.GetOperator())) } operatorAddress := validator.GetOperator() @@ -72,7 +72,7 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in // Special-case slash at current height for efficiency - we don't need to look through unbonding delegations or redelegations logger.Info(fmt.Sprintf( - "Slashing at current height %d, not scanning unbonding delegations & redelegations", + "slashing at current height %d, not scanning unbonding delegations & redelegations", infractionHeight)) case infractionHeight < ctx.BlockHeight(): @@ -117,8 +117,8 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in // Log that a slash occurred! logger.Info(fmt.Sprintf( - "Validator %s slashed by slashFactor %s, burned %v tokens", - pubkey.Address(), slashFactor.String(), tokensToBurn)) + "validator %s slashed by slash factor of %s; burned %v tokens", + validator.GetOperator(), slashFactor.String(), tokensToBurn)) // TODO Return event(s), blocked on https://github.com/tendermint/tendermint/pull/1803 return @@ -127,8 +127,12 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in // jail a validator func (k Keeper) Jail(ctx sdk.Context, pubkey crypto.PubKey) { k.setJailed(ctx, pubkey, true) + validatorAddr, err := sdk.ValAddressFromHex(pubkey.Address().String()) + if err != nil { + panic(err.Error()) + } logger := ctx.Logger().With("module", "x/stake") - logger.Info(fmt.Sprintf("Validator %s jailed", pubkey.Address())) + logger.Info(fmt.Sprintf("validator %s jailed", validatorAddr)) // TODO Return event(s), blocked on https://github.com/tendermint/tendermint/pull/1803 return } @@ -136,8 +140,12 @@ func (k Keeper) Jail(ctx sdk.Context, pubkey crypto.PubKey) { // unjail a validator func (k Keeper) Unjail(ctx sdk.Context, pubkey crypto.PubKey) { k.setJailed(ctx, pubkey, false) + validatorAddr, err := sdk.ValAddressFromHex(pubkey.Address().String()) + if err != nil { + panic(err.Error()) + } logger := ctx.Logger().With("module", "x/stake") - logger.Info(fmt.Sprintf("Validator %s unjailed", pubkey.Address())) + logger.Info(fmt.Sprintf("validator %s unjailed", validatorAddr)) // TODO Return event(s), blocked on https://github.com/tendermint/tendermint/pull/1803 return } @@ -146,7 +154,7 @@ func (k Keeper) Unjail(ctx sdk.Context, pubkey crypto.PubKey) { func (k Keeper) setJailed(ctx sdk.Context, pubkey crypto.PubKey, isJailed bool) { validator, found := k.GetValidatorByPubKey(ctx, pubkey) if !found { - panic(fmt.Errorf("Validator with pubkey %s not found, cannot set jailed to %v", pubkey, isJailed)) + panic(fmt.Errorf("validator with pubkey %s not found, cannot set jailed to %v", pubkey, isJailed)) } validator.Jailed = isJailed k.UpdateValidator(ctx, validator) // update validator, possibly unbonding or bonding it