diff --git a/modules/apps/27-interchain-accounts/module.go b/modules/apps/27-interchain-accounts/module.go index 6e7b838184c..f99a6953d97 100644 --- a/modules/apps/27-interchain-accounts/module.go +++ b/modules/apps/27-interchain-accounts/module.go @@ -8,6 +8,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/appmodule" coreregistry "cosmossdk.io/core/registry" @@ -30,12 +31,21 @@ import ( ) var ( - _ module.AppModule = (*AppModule)(nil) - _ module.AppModuleBasic = (*AppModule)(nil) - _ module.AppModuleSimulation = (*AppModule)(nil) - _ module.HasGenesis = (*AppModule)(nil) - _ module.HasServices = (*AppModule)(nil) - _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasConsensusVersion = (*AppModule)(nil) + _ appmodule.HasRegisterInterfaces = (*AppModule)(nil) + + _ module.AppModule = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + _ module.HasServices = (*AppModule)(nil) + _ module.HasGRPCGateway = (*AppModule)(nil) + + // Sims + _ module.AppModuleSimulation = (*AppModule)(nil) + _ module.HasLegacyProposalMsgs = (*AppModule)(nil) + + _ autocli.HasCustomTxCommand = (*AppModule)(nil) + _ autocli.HasCustomQueryCommand = (*AppModule)(nil) _ porttypes.IBCModule = (*host.IBCModule)(nil) ) @@ -67,9 +77,6 @@ func (AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (AppModule) IsAppModule() {} -// RegisterLegacyAminoCodec implements AppModule. -func (AppModule) RegisterLegacyAminoCodec(cdc coreregistry.AminoRegistrar) {} - // RegisterInterfaces registers module concrete types into protobuf Any func (AppModule) RegisterInterfaces(registry coreregistry.InterfaceRegistrar) { controllertypes.RegisterInterfaces(registry) @@ -193,11 +200,6 @@ func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Wei return simulation.ProposalMsgs(am.controllerKeeper, am.hostKeeper) } -// WeightedOperations is unimplemented. -func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return nil -} - // RegisterStoreDecoder registers a decoder for interchain accounts module's types func (AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { sdr[controllertypes.StoreKey] = simulation.NewDecodeStore() diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index 058078cdc11..88dc1959c77 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -8,27 +8,30 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/appmodule" coreregistry "cosmossdk.io/core/registry" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/ibc-go/v9/modules/apps/29-fee/client/cli" "github.com/cosmos/ibc-go/v9/modules/apps/29-fee/keeper" "github.com/cosmos/ibc-go/v9/modules/apps/29-fee/types" ) var ( - _ module.AppModule = (*AppModule)(nil) - _ module.HasAminoCodec = AppModule{} - _ module.AppModuleSimulation = (*AppModule)(nil) - _ module.HasGenesis = (*AppModule)(nil) - _ appmodule.HasConsensusVersion = (*AppModule)(nil) - _ module.HasServices = (*AppModule)(nil) - _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasConsensusVersion = (*AppModule)(nil) + _ appmodule.HasAminoCodec = (*AppModule)(nil) + _ appmodule.HasRegisterInterfaces = (*AppModule)(nil) + + _ module.AppModule = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + _ module.HasServices = (*AppModule)(nil) + + _ autocli.HasCustomTxCommand = (*AppModule)(nil) + _ autocli.HasCustomQueryCommand = (*AppModule)(nil) ) // AppModule represents the AppModule for this module @@ -129,18 +132,3 @@ func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return 2 } - -// AppModuleSimulation functions - -// GenerateGenesisState creates a randomized GenState of the 29-fee module. -func (AppModule) GenerateGenesisState(_ *module.SimulationState) { -} - -// RegisterStoreDecoder registers a decoder for 29-fee module's types -func (AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) { -} - -// WeightedOperations returns the all the 29-fee module operations with their respective weights. -func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { - return nil -} diff --git a/modules/apps/transfer/keeper/invariants.go b/modules/apps/transfer/keeper/invariants.go deleted file mode 100644 index dded2822ec9..00000000000 --- a/modules/apps/transfer/keeper/invariants.go +++ /dev/null @@ -1,51 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" -) - -// RegisterInvariants registers all transfer invariants -func RegisterInvariants(ir sdk.InvariantRegistry, k *Keeper) { - ir.RegisterRoute(types.ModuleName, "total-escrow-per-denom", - TotalEscrowPerDenomInvariants(k)) -} - -// AllInvariants runs all invariants of the transfer module. -func AllInvariants(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - return TotalEscrowPerDenomInvariants(k)(ctx) - } -} - -// TotalEscrowPerDenomInvariants checks that the total amount escrowed for -// each denom is not smaller than the amount stored in the state entry. -func TotalEscrowPerDenomInvariants(k *Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - var actualTotalEscrowed sdk.Coins - - expectedTotalEscrowed := k.GetAllTotalEscrowed(ctx) - - portID := k.GetPort(ctx) - transferChannels := k.channelKeeper.GetAllChannelsWithPortPrefix(ctx, portID) - for _, channel := range transferChannels { - escrowAddress := types.GetEscrowAddress(portID, channel.ChannelId) - escrowBalances := k.bankKeeper.GetAllBalances(ctx, escrowAddress) - - actualTotalEscrowed = actualTotalEscrowed.Add(escrowBalances...) - } - - // the actual escrowed amount must be greater than or equal to the expected amount for all denominations - if !actualTotalEscrowed.IsAllGTE(expectedTotalEscrowed) { - return sdk.FormatInvariant( - types.ModuleName, - "total escrow per denom invariance", - fmt.Sprintf("found denom(s) with total escrow amount lower than expected:\nactual total escrowed: %s\nexpected total escrowed: %s", actualTotalEscrowed, expectedTotalEscrowed)), true - } - - return "", false - } -} diff --git a/modules/apps/transfer/keeper/invariants_test.go b/modules/apps/transfer/keeper/invariants_test.go deleted file mode 100644 index c24bb2d40bf..00000000000 --- a/modules/apps/transfer/keeper/invariants_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package keeper_test - -import ( - sdkmath "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/cosmos/ibc-go/v9/modules/apps/transfer/keeper" - "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" - ibctesting "github.com/cosmos/ibc-go/v9/testing" -) - -func (suite *KeeperTestSuite) TestTotalEscrowPerDenomInvariant() { - testCases := []struct { - name string - coinsToTransfer sdk.Coins - malleate func() - expPass bool - }{ - { - "success", - sdk.NewCoins(ibctesting.TestCoin, ibctesting.SecondaryTestCoin), - func() {}, - true, - }, - { - "success with single denom", - sdk.NewCoins(ibctesting.TestCoin), - func() {}, - true, - }, - { - "fails with broken invariant", - sdk.NewCoins(ibctesting.TestCoin), - func() { - // set amount for denom higher than actual value in escrow - amount := ibctesting.TestCoin.Amount.Add(sdkmath.NewInt(100)) - suite.chainA.GetSimApp().TransferKeeper.SetTotalEscrowForDenom(suite.chainA.GetContext(), sdk.NewCoin(sdk.DefaultBondDenom, amount)) - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - path := ibctesting.NewTransferPath(suite.chainA, suite.chainB) - path.Setup() - - msg := types.NewMsgTransfer( - path.EndpointA.ChannelConfig.PortID, - path.EndpointA.ChannelID, - tc.coinsToTransfer, - suite.chainA.SenderAccount.GetAddress().String(), - suite.chainB.SenderAccount.GetAddress().String(), - suite.chainA.GetTimeoutHeight(), 0, "", - nil, - ) - - res, err := suite.chainA.SendMsgs(msg) - suite.Require().NoError(err) - suite.Require().NotNil(res) - - tc.malleate() - - out, broken := keeper.TotalEscrowPerDenomInvariants(&suite.chainA.GetSimApp().TransferKeeper)(suite.chainA.GetContext()) - - if tc.expPass { - suite.Require().False(broken) - suite.Require().Empty(out) - } else { - suite.Require().True(broken) - suite.Require().NotEmpty(out) - } - }) - } -} diff --git a/modules/apps/transfer/module.go b/modules/apps/transfer/module.go index 7b1225a873f..1d054933f0e 100644 --- a/modules/apps/transfer/module.go +++ b/modules/apps/transfer/module.go @@ -8,12 +8,12 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/appmodule" coreregistry "cosmossdk.io/core/registry" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -25,14 +25,22 @@ import ( ) var ( - _ module.AppModule = (*AppModule)(nil) - _ module.AppModuleBasic = (*AppModule)(nil) - _ module.AppModuleSimulation = (*AppModule)(nil) - _ module.HasGenesis = (*AppModule)(nil) - _ appmodule.HasConsensusVersion = (*AppModule)(nil) - _ module.HasInvariants = (*AppModule)(nil) - _ module.HasServices = (*AppModule)(nil) - _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasConsensusVersion = (*AppModule)(nil) + _ appmodule.HasRegisterInterfaces = (*AppModule)(nil) + + _ module.AppModule = (*AppModule)(nil) + _ module.HasGRPCGateway = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + _ module.HasServices = (*AppModule)(nil) + + // Sims + _ module.AppModuleSimulation = (*AppModule)(nil) + _ module.HasLegacyProposalMsgs = (*AppModule)(nil) + _ module.HasLegacyWeightedOperations = (*AppModule)(nil) + + _ autocli.HasCustomTxCommand = (*AppModule)(nil) + _ autocli.HasCustomQueryCommand = (*AppModule)(nil) _ porttypes.IBCModule = (*IBCModule)(nil) ) @@ -109,11 +117,6 @@ func (AppModule) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInvariants implements the AppModule interface -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - keeper.RegisterInvariants(ir, &am.keeper) -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), am.keeper) diff --git a/modules/core/module.go b/modules/core/module.go index 7f350ed69b6..3d39cdd72d0 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -8,6 +8,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/appmodule" coreregistry "cosmossdk.io/core/registry" @@ -32,14 +33,21 @@ import ( ) var ( - _ module.AppModule = (*AppModule)(nil) - _ module.AppModuleBasic = (*AppModule)(nil) - _ module.AppModuleSimulation = (*AppModule)(nil) - _ module.HasGenesis = (*AppModule)(nil) - _ appmodule.HasConsensusVersion = (*AppModule)(nil) - _ module.HasServices = (*AppModule)(nil) - _ appmodule.AppModule = (*AppModule)(nil) - _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.HasConsensusVersion = (*AppModule)(nil) + _ appmodule.HasRegisterInterfaces = (*AppModule)(nil) + + _ module.AppModule = (*AppModule)(nil) + _ module.HasGRPCGateway = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + _ module.HasServices = (*AppModule)(nil) + + _ module.HasLegacyProposalMsgs = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ autocli.HasCustomTxCommand = (*AppModule)(nil) + _ autocli.HasCustomQueryCommand = (*AppModule)(nil) ) // AppModule implements an application module for the ibc module. @@ -67,9 +75,6 @@ func (AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (AppModule) IsAppModule() {} -// RegisterLegacyAminoCodec does nothing. IBC does not support amino. -func (AppModule) RegisterLegacyAminoCodec(coreregistry.AminoRegistrar) {} - // DefaultGenesis returns default genesis state as raw bytes for the ibc // module. func (am AppModule) DefaultGenesis() json.RawMessage { @@ -202,8 +207,3 @@ func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Weight func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { sdr[exported.StoreKey] = simulation.NewDecodeStore(*am.keeper) } - -// WeightedOperations returns the all the ibc module operations with their respective weights. -func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { - return nil -} diff --git a/modules/light-clients/06-solomachine/module.go b/modules/light-clients/06-solomachine/module.go index c940561c64c..cb6f8e1014b 100644 --- a/modules/light-clients/06-solomachine/module.go +++ b/modules/light-clients/06-solomachine/module.go @@ -1,22 +1,13 @@ package solomachine import ( - "encoding/json" - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - "cosmossdk.io/core/appmodule" coreregistry "cosmossdk.io/core/registry" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/types/module" ) var ( - _ module.AppModuleBasic = (*AppModule)(nil) - _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasRegisterInterfaces = (*AppModule)(nil) ) // AppModule is the application module for the Solomachine client module @@ -42,34 +33,8 @@ func (AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. func (AppModule) IsAppModule() {} -// RegisterLegacyAminoCodec performs a no-op. The solo machine client does not support amino. -func (AppModule) RegisterLegacyAminoCodec(coreregistry.AminoRegistrar) {} - // RegisterInterfaces registers module concrete types into protobuf Any. This allows core IBC // to unmarshal solo machine types. func (AppModule) RegisterInterfaces(registry coreregistry.InterfaceRegistrar) { RegisterInterfaces(registry) } - -// DefaultGenesis performs a no-op. Genesis is not supported for solo machine. -func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return nil -} - -// ValidateGenesis performs a no-op. Genesis is not supported for solo machine. -func (AppModule) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - return nil -} - -// RegisterGRPCGatewayRoutes performs a no-op. -func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {} - -// GetTxCmd performs a no-op. Please see the 02-client cli commands. -func (AppModule) GetTxCmd() *cobra.Command { - return nil -} - -// GetQueryCmd performs a no-op. Please see the 02-client cli commands. -func (AppModule) GetQueryCmd() *cobra.Command { - return nil -} diff --git a/modules/light-clients/07-tendermint/module.go b/modules/light-clients/07-tendermint/module.go index 2d426b3c2ce..4f7ef23f1dc 100644 --- a/modules/light-clients/07-tendermint/module.go +++ b/modules/light-clients/07-tendermint/module.go @@ -1,19 +1,13 @@ package tendermint import ( - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - "cosmossdk.io/core/appmodule" coreregistry "cosmossdk.io/core/registry" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/module" ) var ( - _ module.AppModuleBasic = (*AppModule)(nil) - _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasRegisterInterfaces = (*AppModule)(nil) ) // AppModule is the application module for the Tendermint client module @@ -39,24 +33,8 @@ func (AppModule) Name() string { return ModuleName } -// RegisterLegacyAminoCodec performs a no-op. The Tendermint client does not support amino. -func (AppModule) RegisterLegacyAminoCodec(coreregistry.AminoRegistrar) {} - // RegisterInterfaces registers module concrete types into protobuf Any. This allows core IBC // to unmarshal tendermint light client types. func (AppModule) RegisterInterfaces(registry coreregistry.InterfaceRegistrar) { RegisterInterfaces(registry) } - -// RegisterGRPCGatewayRoutes performs a no-op. -func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {} - -// GetTxCmd performs a no-op. Please see the 02-client cli commands. -func (AppModule) GetTxCmd() *cobra.Command { - return nil -} - -// GetQueryCmd performs a no-op. Please see the 02-client cli commands. -func (AppModule) GetQueryCmd() *cobra.Command { - return nil -} diff --git a/modules/light-clients/08-wasm/module.go b/modules/light-clients/08-wasm/module.go index cee85f7ce88..bda17444165 100644 --- a/modules/light-clients/08-wasm/module.go +++ b/modules/light-clients/08-wasm/module.go @@ -8,6 +8,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" + "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/appmodule" coreregistry "cosmossdk.io/core/registry" @@ -21,12 +22,17 @@ import ( ) var ( - _ module.AppModule = (*AppModule)(nil) - _ module.AppModuleBasic = (*AppModule)(nil) - _ module.HasGenesis = (*AppModule)(nil) - _ appmodule.HasConsensusVersion = (*AppModule)(nil) - _ module.HasServices = (*AppModule)(nil) - _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasConsensusVersion = (*AppModule)(nil) + _ appmodule.HasRegisterInterfaces = (*AppModule)(nil) + + _ module.AppModule = (*AppModule)(nil) + _ module.HasGRPCGateway = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + _ module.HasServices = (*AppModule)(nil) + + _ autocli.HasCustomTxCommand = (*AppModule)(nil) + _ autocli.HasCustomQueryCommand = (*AppModule)(nil) ) // AppModule represents the AppModule for this module @@ -54,9 +60,6 @@ func (AppModule) Name() string { return types.ModuleName } -// RegisterLegacyAminoCodec performs a no-op. The Wasm client does not support amino. -func (AppModule) RegisterLegacyAminoCodec(coreregistry.AminoRegistrar) {} - // RegisterInterfaces registers module concrete types into protobuf Any. This allows core IBC // to unmarshal Wasm light client types. func (AppModule) RegisterInterfaces(reg coreregistry.InterfaceRegistrar) {