From 79a6bd730f7b0e2e08498708921b0ed8cabad474 Mon Sep 17 00:00:00 2001 From: Alex | Interchain Labs Date: Wed, 7 May 2025 09:15:10 -0400 Subject: [PATCH] chore(baseapp): deprecate invariants (#24664) --- CHANGELOG.md | 1 + types/invariant.go | 8 ++++++++ types/module/module.go | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c343eb12eb..b7b27dbeda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/nft) [#24575](https://github.com/cosmos/cosmos-sdk/pull/24575) Deprecate the `x/nft` module in the Cosmos SDK repository. This module will not be maintained to the extent that our core modules will and will be kept in a [legacy repo](https://github.com/cosmos/cosmos-legacy). * (x/group) [#24571](https://github.com/cosmos/cosmos-sdk/pull/24571) Deprecate the `x/group` module in the Cosmos SDK repository. This module will not be maintained to the extent that our core modules will and will be kept in a [legacy repo](https://github.com/cosmos/cosmos-legacy). +* (types) [#24664](https://github.com/cosmos/cosmos-sdk/pull/24664) Deprecate the `Invariant` type in the Cosmos SDK. ### Bug Fixes diff --git a/types/invariant.go b/types/invariant.go index 1e7cae7f8b..2e94191cc3 100644 --- a/types/invariant.go +++ b/types/invariant.go @@ -6,17 +6,25 @@ import "fmt" // The invariant returns a descriptive message about what happened // and a boolean indicating whether the invariant has been broken. // The simulator will then halt and print the logs. +// +// Deprecated: the Invariant type is deprecated and will be removed once x/crisis is removed. type Invariant func(ctx Context) (string, bool) // Invariants defines a group of invariants +// +// Deprecated: the Invariants type is deprecated and will be removed once x/crisis is removed. type Invariants []Invariant // expected interface for registering invariants +// +// Deprecated: the InvariantRegistry type is deprecated and will be removed once x/crisis is removed. type InvariantRegistry interface { RegisterRoute(moduleName, route string, invar Invariant) } // FormatInvariant returns a standardized invariant message. +// +// Deprecated: the FormatInvariant type is deprecated and will be removed once x/crisis is removed. func FormatInvariant(module, name, msg string) string { return fmt.Sprintf("%s: %s invariant\n%s\n", module, name, msg) } diff --git a/types/module/module.go b/types/module/module.go index 4a39dc0971..be252994cd 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -210,7 +210,7 @@ type AppModule interface { // Deprecated: this will be removed in the next Cosmos SDK release. type HasInvariants interface { // RegisterInvariants registers module invariants. - RegisterInvariants(sdk.InvariantRegistry) + RegisterInvariants(sdk.InvariantRegistry) // nolint: staticcheck // deprecated interface } // HasServices is the interface for modules to register services. @@ -268,6 +268,8 @@ func (GenesisOnlyAppModule) IsOnePerModuleType() {} func (GenesisOnlyAppModule) IsAppModule() {} // RegisterInvariants is a placeholder function register no invariants +// +// Deprecated: this function will be removed when x/crisis and invariants are removed from the cosmos SDK. func (GenesisOnlyAppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // ConsensusVersion implements AppModule/ConsensusVersion.