Skip to content

Commit

Permalink
Merge branch 'main' into chore-cobra
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 authored Oct 31, 2023
2 parents b2d30d9 + ca35eab commit a719b73
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
* (chore) [\#1168](https://github.com/Finschia/finschia-sdk/pull/1168) Replace `ExactArgs(0)` with `NoArgs()` in `x/upgrade` module

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 3 additions & 1 deletion x/crisis/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"+
Expand Down
15 changes: 3 additions & 12 deletions x/foundation/keeper/internal/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -41,24 +38,18 @@ 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
}
}

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
Expand Down

0 comments on commit a719b73

Please sign in to comment.