From b0e50cc8eea6f7e8133eba45866e5b1ea8671159 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 12 Jan 2023 10:07:39 +0000 Subject: [PATCH 1/3] Use CacheContext() in AssertInvariants() --- x/crisis/keeper/keeper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go index e7e85c3683ff..467c15ac880a 100644 --- a/x/crisis/keeper/keeper.go +++ b/x/crisis/keeper/keeper.go @@ -84,6 +84,8 @@ func (k *Keeper) AssertInvariants(ctx sdk.Context) { n := len(invarRoutes) for i, ir := range invarRoutes { logger.Info("asserting crisis invariants", "inv", fmt.Sprint(i+1, "/", n), "name", ir.FullRoute()) + + ctx, _ := ctx.CacheContext() if res, stop := ir.Invar(ctx); stop { // TODO: Include app name as part of context to allow for this to be // variable. From 97ea9bc99b780ed6a4c98674e5e9f62a50655963 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 12 Jan 2023 10:21:01 +0000 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf3820959c19..0ea5463867e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (x/crisis) [#14588](https://github.com/cosmos/cosmos-sdk/pull/14588) Use CacheContext() in AssertInvariants() * (client) [#14342](https://github.com/cosmos/cosmos-sdk/pull/14342) Add `simd config` command is now a sub-command, for setting, getting and migrating Cosmos SDK configuration files. * (query) [#14468](https://github.com/cosmos/cosmos-sdk/pull/14468) Implement pagination for collections. * (x/bank) [#14045](https://github.com/cosmos/cosmos-sdk/pull/14045) Add CLI command `spendable-balances`, which also accepts the flag `--denom`. From b270a049d136fde6fabff4e2d4c93c92675133e0 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Sat, 14 Jan 2023 13:55:28 +0900 Subject: [PATCH 3/3] Apply suggestions from code review Rename the variable for clarity. Co-authored-by: Aleksandr Bezobchuk --- x/crisis/keeper/keeper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go index 467c15ac880a..36e10db476b8 100644 --- a/x/crisis/keeper/keeper.go +++ b/x/crisis/keeper/keeper.go @@ -85,8 +85,8 @@ func (k *Keeper) AssertInvariants(ctx sdk.Context) { for i, ir := range invarRoutes { logger.Info("asserting crisis invariants", "inv", fmt.Sprint(i+1, "/", n), "name", ir.FullRoute()) - ctx, _ := ctx.CacheContext() - if res, stop := ir.Invar(ctx); stop { + invCtx, _ := ctx.CacheContext() + if res, stop := ir.Invar(invCtx); stop { // TODO: Include app name as part of context to allow for this to be // variable. panic(fmt.Errorf("invariant broken: %s\n"+