From 0bb3497356b016fbc384ea5ba996ddd56519dd9d Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Fri, 27 Jul 2018 21:42:07 -0700 Subject: [PATCH] x/stake: Speed up handleMsgEditValidator This removes running the power update logic on handleMsgEditValidator, as its unnecessary. Closes #1815 --- PENDING.md | 1 + x/stake/handler.go | 4 +++- x/stake/keeper/validator.go | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PENDING.md b/PENDING.md index 95396eac5..60d852c7d 100644 --- a/PENDING.md +++ b/PENDING.md @@ -50,6 +50,7 @@ IMPROVEMENTS * [tests] Fixes ansible scripts to work with AWS too * [tests] \#1806 CLI tests are now behind the build flag 'cli_test', so go test works on a new repo * [x/gov] Initial governance parameters can now be set in the genesis file +* [x/stake] \#1815 Sped up the processing of `EditValidator` txs. BUG FIXES * \#1666 Add intra-tx counter to the genesis validators diff --git a/x/stake/handler.go b/x/stake/handler.go index 3cc122e4c..9a8cee446 100644 --- a/x/stake/handler.go +++ b/x/stake/handler.go @@ -111,7 +111,9 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe } validator.Description = description - k.UpdateValidator(ctx, validator) + // We don't need to run through all the power update logic within k.UpdateValidator + // We just need to override the entry in state, since only the description has changed. + k.SetValidator(ctx, validator) tags := sdk.NewTags( tags.Action, tags.ActionEditValidator, tags.DstValidator, []byte(msg.ValidatorAddr.String()), diff --git a/x/stake/keeper/validator.go b/x/stake/keeper/validator.go index c7ae43cbe..8f9399b2a 100644 --- a/x/stake/keeper/validator.go +++ b/x/stake/keeper/validator.go @@ -191,9 +191,9 @@ func (k Keeper) ClearTendermintUpdates(ctx sdk.Context) { //___________________________________________________________________________ -// Perfom all the nessisary steps for when a validator changes its power. This +// Perfom all the necessary steps for when a validator changes its power. This // function updates all validator stores as well as tendermint update store. -// It may kick out validators if new validator is entering the bonded validator +// It may kick out validators if a new validator is entering the bonded validator // group. // // nolint: gocyclo