Skip to content

Commit abf09ee

Browse files
jewei1997yzang2019
authored andcommitted
[STO-237] remove unused cosmos invariants (#2719)
## Describe your changes and provide context re-implementing these changes from a sei-cosmos PR that wasn't merged sei-protocol/sei-cosmos#593 ## Testing performed to validate your change
1 parent 6b02851 commit abf09ee

7 files changed

Lines changed: 4 additions & 419 deletions

File tree

sei-cosmos/x/bank/keeper/invariants.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,6 @@ import (
88
"github.com/cosmos/cosmos-sdk/x/bank/types"
99
)
1010

11-
// RegisterInvariants registers the bank module invariants
12-
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
13-
ir.RegisterRoute(types.ModuleName, "nonnegative-outstanding", NonnegativeBalanceInvariant(k))
14-
ir.RegisterRoute(types.ModuleName, "total-supply", TotalSupply(k))
15-
}
16-
17-
// AllInvariants runs all invariants of the X/bank module.
18-
func AllInvariants(k Keeper) sdk.Invariant {
19-
return func(ctx sdk.Context) (string, bool) {
20-
return TotalSupply(k)(ctx)
21-
}
22-
}
23-
24-
// NonnegativeBalanceInvariant checks that all accounts in the application have non-negative balances
25-
func NonnegativeBalanceInvariant(k ViewKeeper) sdk.Invariant {
26-
return func(ctx sdk.Context) (string, bool) {
27-
var (
28-
msg string
29-
count int
30-
)
31-
32-
k.IterateAllBalances(ctx, func(addr sdk.AccAddress, balance sdk.Coin) bool {
33-
if balance.IsNegative() {
34-
count++
35-
msg += fmt.Sprintf("\t%s has a negative balance of %s\n", addr, balance)
36-
}
37-
38-
return false
39-
})
40-
k.IterateAllWeiBalances(ctx, func(addr sdk.AccAddress, balance sdk.Int) bool {
41-
if balance.IsNegative() {
42-
count++
43-
msg += fmt.Sprintf("\t%s has a negative wei balance of %s\n", addr, balance)
44-
}
45-
46-
return false
47-
})
48-
49-
broken := count != 0
50-
51-
return sdk.FormatInvariant(
52-
types.ModuleName, "nonnegative-outstanding",
53-
fmt.Sprintf("amount of negative balances found %d\n%s", count, msg),
54-
), broken
55-
}
56-
}
57-
5811
// TotalSupply checks that the total supply reflects all the coins held in accounts
5912
func TotalSupply(k Keeper) sdk.Invariant {
6013
return func(ctx sdk.Context) (string, bool) {

sei-cosmos/x/bank/module.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.Acc
130130
func (AppModule) Name() string { return types.ModuleName }
131131

132132
// RegisterInvariants registers the bank module invariants.
133-
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
134-
keeper.RegisterInvariants(ir, am.keeper)
135-
}
133+
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
136134

137135
// Route returns the message routing key for the bank module.
138136
func (am AppModule) Route() sdk.Route {

sei-cosmos/x/distribution/keeper/invariants.go

Lines changed: 0 additions & 162 deletions
This file was deleted.

sei-cosmos/x/distribution/module.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ func (AppModule) Name() string {
127127
}
128128

129129
// RegisterInvariants registers the distribution module invariants.
130-
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
131-
keeper.RegisterInvariants(ir, am.keeper)
132-
}
130+
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
133131

134132
// Route returns the message routing key for the distribution module.
135133
func (am AppModule) Route() sdk.Route {

sei-cosmos/x/gov/module.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ func (AppModule) Name() string {
142142
}
143143

144144
// RegisterInvariants registers module invariants
145-
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
146-
keeper.RegisterInvariants(ir, am.keeper, am.bankKeeper)
147-
}
145+
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
148146

149147
// Route returns the message routing key for the gov module.
150148
func (am AppModule) Route() sdk.Route {

0 commit comments

Comments
 (0)