From 6b3f85978abf6353176f215acd09174cfb2eb193 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 31 Oct 2023 09:30:58 +0000
Subject: [PATCH 1/2] chore(deps): Bump github.com/cosmos/ledger-cosmos-go from
0.13.2 to 0.13.3 (#1165)
Bumps [github.com/cosmos/ledger-cosmos-go](https://github.com/cosmos/ledger-cosmos-go) from 0.13.2 to 0.13.3.
Commits
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/cosmos/ledger-cosmos-go&package-manager=go_modules&previous-version=0.13.2&new-version=0.13.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
---
go.mod | 2 +-
go.sum | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/go.mod b/go.mod
index 5912aec0e6..86d17b96de 100644
--- a/go.mod
+++ b/go.mod
@@ -14,7 +14,7 @@ require (
github.com/cosmos/btcutil v1.0.5
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/iavl v0.19.4
- github.com/cosmos/ledger-cosmos-go v0.13.2
+ github.com/cosmos/ledger-cosmos-go v0.13.3
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/go-kit/kit v0.13.0
github.com/gogo/gateway v1.1.0
diff --git a/go.sum b/go.sum
index 981761cf5b..83462ce8ae 100644
--- a/go.sum
+++ b/go.sum
@@ -143,8 +143,8 @@ github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok=
github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8=
-github.com/cosmos/ledger-cosmos-go v0.13.2 h1:aY0KZSmUwNKbBm9OvbIjvf7Ozz2YzzpAbgvN2C8x2T0=
-github.com/cosmos/ledger-cosmos-go v0.13.2/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8=
+github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM=
+github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
From ca35eab1347801d642706ec7a0cd9186882eae63 Mon Sep 17 00:00:00 2001
From: Jayden Lee <41176085+tkxkd0159@users.noreply.github.com>
Date: Tue, 31 Oct 2023 18:41:30 +0900
Subject: [PATCH 2/2] feat: use CacheContext() in AssertInvariants() (#1167)
---
CHANGELOG.md | 1 +
x/crisis/keeper/keeper.go | 4 +++-
x/foundation/keeper/internal/invariants.go | 15 +++------------
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 230a2652d9..6828a2fc0b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (feat) [\#1121](https://github.com/Finschia/finschia-sdk/pull/1121) Add update-censorship cmd to x/foundation cli
* (server) [#1153](https://github.com/Finschia/finschia-sdk/pull/1153) remove grpc replace directive
* (crypto) [\#1163](https://github.com/Finschia/finschia-sdk/pull/1163) Update some secp256k1 logics with latest `dcrec`
+* (x/crisis) [#1167](https://github.com/Finschia/finschia-sdk/pull/1167) Use `CacheContext()` in `AssertInvariants()`
### Bug Fixes
* chore(deps) [\#1141](https://github.com/Finschia/finschia-sdk/pull/1141) Bump github.com/cosmos/ledger-cosmos-go from 0.12.2 to 0.13.2 to fix ledger signing issue
diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go
index 258e7167b0..2318628128 100644
--- a/x/crisis/keeper/keeper.go
+++ b/x/crisis/keeper/keeper.go
@@ -76,7 +76,9 @@ 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())
- 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"+
diff --git a/x/foundation/keeper/internal/invariants.go b/x/foundation/keeper/internal/invariants.go
index 3c6c19b9ef..b2abf2e0ea 100644
--- a/x/foundation/keeper/internal/invariants.go
+++ b/x/foundation/keeper/internal/invariants.go
@@ -25,9 +25,6 @@ func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
func ModuleAccountInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
- // cache, we don't want to write changes
- ctx, _ = ctx.CacheContext()
-
treasuryAcc := k.authKeeper.GetModuleAccount(ctx, foundation.TreasuryName)
balance := k.bankKeeper.GetAllBalances(ctx, treasuryAcc.GetAddress())
@@ -41,14 +38,11 @@ func ModuleAccountInvariant(k Keeper) sdk.Invariant {
func TotalWeightInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
- // cache, we don't want to write changes
- ctx, _ = ctx.CacheContext()
-
expected := k.GetFoundationInfo(ctx).TotalWeight
- real := sdk.NewDec(int64(len(k.GetMembers(ctx))))
+ actual := sdk.NewDec(int64(len(k.GetMembers(ctx))))
- msg := fmt.Sprintf("total weight of foundation; expected %s, got %s\n", expected, real)
- broken := !real.Equal(expected)
+ msg := fmt.Sprintf("total weight of foundation; expected %s, got %s\n", expected, actual)
+ broken := !actual.Equal(expected)
return sdk.FormatInvariant(foundation.ModuleName, totalWeightInvariant, msg), broken
}
@@ -56,9 +50,6 @@ func TotalWeightInvariant(k Keeper) sdk.Invariant {
func ProposalInvariant(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
- // cache, we don't want to write changes
- ctx, _ = ctx.CacheContext()
-
version := k.GetFoundationInfo(ctx).Version
msg := fmt.Sprintf("current foundation version; %d\n", version)
broken := false