diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7dfca2bdc1..7b610eb219f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (crypto/keys) [#18026](https://github.com/cosmos/cosmos-sdk/pull/18026) Made public key generation constant time on `secp256k1` * (crypto | x/auth) [#14372](https://github.com/cosmos/cosmos-sdk/pull/18194) Key checks on signatures antehandle. * (types) [#18963](https://github.com/cosmos/cosmos-sdk/pull/18963) Swap out amino json encoding of `ABCIMessageLogs` for std lib json encoding +* (x/auth) [#19651](https://github.com/cosmos/cosmos-sdk/pull/19651) Allow empty public keys in `GetSignBytesAdapter`. ### Bug Fixes @@ -96,6 +97,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes +* (types) [#19447](https://github.com/cosmos/cosmos-sdk/pull/19447) `module.testutil.MakeTestEncodingConfig` now takes `CodecOptions` as argument. * (types) [#19512](https://github.com/cosmos/cosmos-sdk/pull/19512) Remove basic manager and all related functions (`module.BasicManager`, `module.NewBasicManager`, `module.NewBasicManagerFromManager`, `NewGenesisOnlyAppModule`). * The module manager now can do everything that the basic manager was doing. * When using runtime, just inject the module manager when needed using your app config. @@ -139,6 +141,9 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (types) [#18607](https://github.com/cosmos/cosmos-sdk/pull/18607) Removed address verifier from global config, moved verifier function to bech32 codec. * (server) [#18909](https://github.com/cosmos/cosmos-sdk/pull/18909) Remove configuration endpoint on grpc reflection endpoint in favour of auth module bech32prefix endpoint already exposed. * (crypto) [#19541](https://github.com/cosmos/cosmos-sdk/pull/19541) The deprecated `FromTmProtoPublicKey`, `ToTmProtoPublicKey`, `FromTmPubKeyInterface` and `ToTmPubKeyInterface` functions have been removed. Use their replacements (`Cmt` instead of `Tm`) instead. +* (types) [#19652](https://github.com/cosmos/cosmos-sdk/pull/19652) + * Moved`types/module.HasRegisterInterfaces` to `cosmossdk.io/core`. + * Moved `RegisterInterfaces` and `RegisterImplementations` from `InterfaceRegistry` to `cosmossdk.io/core/registry.LegacyRegistry` interface. ### Client Breaking Changes diff --git a/UPGRADING.md b/UPGRADING.md index 8ed75edacba2..2d04c35f6806 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -12,16 +12,19 @@ In this section we describe the changes made in Cosmos SDK' SimApp. #### Client (`root.go`) -The `client` package has been refactored to make use of the address codecs (address, validator address, consensus address, etc.). +The `client` package has been refactored to make use of the address codecs (address, validator address, consensus address, etc.) +and address bech32 prefixes (address and validator address). This is part of the work of abstracting the SDK from the global bech32 config. -This means the address codecs must be provided in the `client.Context` in the application client (usually `root.go`). +This means the address codecs and prefixes must be provided in the `client.Context` in the application client (usually `root.go`). ```diff clientCtx = clientCtx. + WithAddressCodec(addressCodec). + WithValidatorAddressCodec(validatorAddressCodec). -+ WithConsensusAddressCodec(consensusAddressCodec) ++ WithConsensusAddressCodec(consensusAddressCodec). ++ WithAddressPrefix("cosmos"). ++ WithValidatorPrefix("cosmosvaloper") ``` **When using `depinject` / `app v2`, the client codecs can be provided directly from application config.** @@ -148,12 +151,26 @@ Additionally, the `appmodule.Environment` interface is introduced to fetch diffe This should be used as an alternative to using `sdk.UnwrapContext(ctx)` to fetch the services. It needs to be passed into a module at instantiation. -`x/circuit` is used as an example.: +`x/circuit` is used as an example: ```go app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment((keys[circuittypes.StoreKey])), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec()) ``` +If your module requires a message server or query server, it should be passed in the environment as well. + +```diff +-govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AuthKeeper, app.BankKeeper,app.StakingKeeper, app.PoolKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String()) ++govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger, runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String()) +``` + +The signature of the extension interface `HasRegisterInterfaces` has been changed to accept a `cosmossdk.io/core/registry.LegacyRegistry` instead of a `codec.InterfaceRegistry`. `HasRegisterInterfaces` is now a part of `cosmossdk.io/core/appmodule`. Modules should update their `HasRegisterInterfaces` implementation to accept a `cosmossdk.io/core/registry.LegacyRegistry` interface. + +```diff +-func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { ++func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { +``` + ##### Dependency Injection Previously `cosmossdk.io/core` held functions `Invoke`, `Provide` and `Register` were moved to `cosmossdk.io/depinject/appconfig`. @@ -210,6 +227,11 @@ Group was spun out into its own `go.mod`. To import it use `cosmossdk.io/x/group Gov was spun out into its own `go.mod`. To import it use `cosmossdk.io/x/gov` +Gov v1beta1 proposal handler has been changed to take in a `context.Context` instead of `sdk.Context`. +This change was made to allow legacy proposals to be compatible with server/v2. +If you wish to migrate to server/v2, you should update your proposal handler to take in a `context.Context` and use services. +On the other hand, if you wish to keep using baseapp, simply unwrap the sdk context in your proposal handler. + #### `x/mint` Mint was spun out into its own `go.mod`. To import it use `cosmossdk.io/x/mint` diff --git a/baseapp/abci_utils_test.go b/baseapp/abci_utils_test.go index f2b636fc39d3..a99177ac5225 100644 --- a/baseapp/abci_utils_test.go +++ b/baseapp/abci_utils_test.go @@ -469,9 +469,10 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() // create a codec for marshaling cdc := codectestutil.CodecOptions{}.NewCodec() baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry()) + signingCtx := cdc.InterfaceRegistry().SigningContext() // create a baseapp along with a tx config for tx generation - txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) + txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) app := baseapp.NewBaseApp(s.T().Name(), log.NewNopLogger(), dbm.NewMemDB(), txConfig.TxDecoder()) // create a proposal handler @@ -566,7 +567,8 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSelection() { cdc := codectestutil.CodecOptions{}.NewCodec() baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry()) - txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) + signingCtx := cdc.InterfaceRegistry().SigningContext() + txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) var ( secret1 = []byte("secret1") diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 68bea9795016..910be1a93e84 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -29,7 +29,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -65,8 +64,9 @@ func NewBaseAppSuite(t *testing.T, opts ...func(*baseapp.BaseApp)) *BaseAppSuite t.Helper() cdc := codectestutil.CodecOptions{}.NewCodec() baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry()) + signingCtx := cdc.InterfaceRegistry().SigningContext() - txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) + txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) db := dbm.NewMemDB() logBuffer := new(bytes.Buffer) logger := log.NewLogger(logBuffer, log.ColorOption(false)) @@ -499,11 +499,12 @@ func TestBaseAppOptionSeal(t *testing.T) { } func TestTxDecoder(t *testing.T) { - cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + cdc := codectestutil.CodecOptions{}.NewCodec() baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry()) + signingCtx := cdc.InterfaceRegistry().SigningContext() // patch in TxConfig instead of using an output from x/auth/tx - txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) + txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) tx := newTxCounter(t, txConfig, 1, 0) txBytes, err := txConfig.TxEncoder()(tx) diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index 2f9807997e25..725e90d79264 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -136,9 +136,10 @@ func TestMsgService(t *testing.T) { ), &appBuilder, &cdc, &interfaceRegistry) require.NoError(t, err) app := appBuilder.Build(dbm.NewMemDB(), nil) + signingCtx := interfaceRegistry.SigningContext() // patch in TxConfig instead of using an output from x/auth/tx - txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) + txConfig := authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) // set the TxDecoder in the BaseApp for minimal tx simulations app.SetTxDecoder(txConfig.TxDecoder()) diff --git a/client/context.go b/client/context.go index b93fab97840c..b4f8e54fe024 100644 --- a/client/context.go +++ b/client/context.go @@ -79,6 +79,10 @@ type Context struct { AddressCodec address.Codec ValidatorAddressCodec address.Codec ConsensusAddressCodec address.Codec + + // Bech32 address prefixes. + AddressPrefix string + ValidatorPrefix string } // WithCmdContext returns a copy of the context with an updated context.Context, @@ -337,6 +341,18 @@ func (ctx Context) WithConsensusAddressCodec(consensusAddressCodec address.Codec return ctx } +// WithAddressPrefix returns the context with the provided address bech32 prefix. +func (ctx Context) WithAddressPrefix(addressPrefix string) Context { + ctx.AddressPrefix = addressPrefix + return ctx +} + +// WithValidatorPrefix returns the context with the provided validator bech32 prefix. +func (ctx Context) WithValidatorPrefix(validatorPrefix string) Context { + ctx.ValidatorPrefix = validatorPrefix + return ctx +} + // PrintString prints the raw string to ctx.Output if it's defined, otherwise to os.Stdout func (ctx Context) PrintString(str string) error { return ctx.PrintBytes([]byte(str)) diff --git a/client/context_test.go b/client/context_test.go index 7c0397540c50..98c6d9f76752 100644 --- a/client/context_test.go +++ b/client/context_test.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -98,7 +99,7 @@ x: "10" } func TestGetFromFields(t *testing.T) { - cfg := testutil.MakeTestEncodingConfig() + cfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) path := hd.CreateHDPath(118, 0, 0).String() testCases := []struct { diff --git a/client/grpc_query_test.go b/client/grpc_query_test.go index a493fc548ff1..a07226e118b4 100644 --- a/client/grpc_query_test.go +++ b/client/grpc_query_test.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -39,7 +40,7 @@ func (s *IntegrationTestSuite) SetupSuite() { keys := storetypes.NewKVStoreKeys(countertypes.StoreKey) cms := integration.CreateMultiStore(keys, logger) s.ctx = sdk.NewContext(cms, true, logger) - cfg := moduletestutil.MakeTestEncodingConfig(counter.AppModule{}) + cfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, counter.AppModule{}) s.cdc = cfg.Codec queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, cfg.InterfaceRegistry) diff --git a/client/keys/add.go b/client/keys/add.go index 4e6e4f27f756..e61715f37399 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -269,7 +269,7 @@ func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf // If we're using ledger, only thing we need is the path and the bech32 prefix. if useLedger { - bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix() + bech32PrefixAccAddr := ctx.AddressPrefix k, err := kb.SaveLedgerKey(name, hd.Secp256k1, bech32PrefixAccAddr, coinType, account, index) if err != nil { return err diff --git a/client/keys/add_ledger_test.go b/client/keys/add_ledger_test.go index 2e1865823c30..3d04cc5e3b92 100644 --- a/client/keys/add_ledger_test.go +++ b/client/keys/add_ledger_test.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -39,7 +40,7 @@ func Test_runAddCmdLedgerWithCustomCoinType(t *testing.T) { // Prepare a keybase kbHome := t.TempDir() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec clientCtx := client.Context{}. WithKeyringDir(kbHome). WithCodec(cdc). @@ -97,7 +98,7 @@ func Test_runAddCmdLedger(t *testing.T) { mockIn := testutil.ApplyMockIODiscardOutErr(cmd) kbHome := t.TempDir() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec clientCtx := client.Context{}. WithKeyringDir(kbHome). @@ -144,7 +145,7 @@ func Test_runAddCmdLedger(t *testing.T) { } func Test_runAddCmdLedgerDryRun(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec testData := []struct { name string args []string diff --git a/client/keys/add_test.go b/client/keys/add_test.go index 95cf3347810a..687aff609235 100644 --- a/client/keys/add_test.go +++ b/client/keys/add_test.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -28,7 +29,7 @@ func Test_runAddCmdBasic(t *testing.T) { mockIn := testutil.ApplyMockIODiscardOutErr(cmd) kbHome := t.TempDir() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc) require.NoError(t, err) @@ -149,7 +150,7 @@ func Test_runAddCmdMultisigDupKeys(t *testing.T) { mockIn := testutil.ApplyMockIODiscardOutErr(cmd) kbHome := t.TempDir() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc) require.NoError(t, err) @@ -217,7 +218,7 @@ func Test_runAddCmdDryRun(t *testing.T) { pubkey1 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AtObiFVE4s+9+RX5SP8TN9r2mxpoaT4eGj9CJfK7VRzN"}` pubkey2 := `{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/se1vkqgdQ7VJQCM4mxN+L+ciGhnnJ4XYsQCRBMrdRi"}` b64Pubkey := "QWhnOHhpdXBJcGZ2UlR2ak5la1ExclROUThTOW96YjdHK2RYQmFLVjl4aUo=" - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec testData := []struct { name string @@ -349,7 +350,7 @@ func Test_runAddCmdDryRun(t *testing.T) { func TestAddRecoverFileBackend(t *testing.T) { cmd := AddKeyCommand() cmd.Flags().AddFlagSet(Commands().PersistentFlags()) - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec mockIn := testutil.ApplyMockIODiscardOutErr(cmd) kbHome := t.TempDir() diff --git a/client/keys/delete_test.go b/client/keys/delete_test.go index dd1a38bd875b..69a5b8571207 100644 --- a/client/keys/delete_test.go +++ b/client/keys/delete_test.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -34,7 +35,7 @@ func Test_runDeleteCmd(t *testing.T) { fakeKeyName2 := "runDeleteCmd_Key2" path := sdk.GetFullBIP44Path() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec cmd.SetArgs([]string{"blah", fmt.Sprintf("--%s=%s", flags.FlagKeyringDir, kbHome)}) kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc) diff --git a/client/keys/export_test.go b/client/keys/export_test.go index db49eb5b8c37..8da6922ca908 100644 --- a/client/keys/export_test.go +++ b/client/keys/export_test.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -19,7 +20,7 @@ import ( ) func Test_runExportCmd(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec testCases := []struct { name string keyringBackend string diff --git a/client/keys/import_test.go b/client/keys/import_test.go index 006f8ce672b2..bc9c5d34abb7 100644 --- a/client/keys/import_test.go +++ b/client/keys/import_test.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,7 +19,7 @@ import ( ) func Test_runImportCmd(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec testCases := []struct { name string keyringBackend string @@ -122,7 +123,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO } func Test_runImportHexCmd(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec testCases := []struct { name string keyringBackend string @@ -184,7 +185,7 @@ func Test_runImportCmdWithEmptyName(t *testing.T) { mockIn := testutil.ApplyMockIODiscardOutErr(cmd) // Now add a temporary keybase kbHome := t.TempDir() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc) require.NoError(t, err) diff --git a/client/keys/list_test.go b/client/keys/list_test.go index b81a9d9aabaa..8f2752e5af9f 100644 --- a/client/keys/list_test.go +++ b/client/keys/list_test.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -39,7 +40,7 @@ func Test_runListCmd(t *testing.T) { kbHome2 := t.TempDir() mockIn := testutil.ApplyMockIODiscardOutErr(cmd) - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome2, mockIn, cdc) assert.NilError(t, err) @@ -92,7 +93,7 @@ func Test_runListCmd(t *testing.T) { func Test_runListKeyTypeCmd(t *testing.T) { cmd := ListKeyTypesCmd() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec kbHome := t.TempDir() mockIn := testutil.ApplyMockIODiscardOutErr(cmd) diff --git a/client/keys/migrate_test.go b/client/keys/migrate_test.go index 4d3abe0007da..0e7adb4e6ca1 100644 --- a/client/keys/migrate_test.go +++ b/client/keys/migrate_test.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -41,7 +42,7 @@ func TestMigrateTestSuite(t *testing.T) { func (s *MigrateTestSuite) SetupSuite() { s.dir = s.T().TempDir() - s.cdc = moduletestutil.MakeTestEncodingConfig().Codec + s.cdc = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec s.appName = "cosmos" s.priv = cryptotypes.PrivKey(secp256k1.GenPrivKey()) s.pub = s.priv.PubKey() diff --git a/client/keys/parse.go b/client/keys/parse.go index 5fb34935c477..62bb5f75011a 100644 --- a/client/keys/parse.go +++ b/client/keys/parse.go @@ -11,19 +11,20 @@ import ( "github.com/spf13/cobra" "sigs.k8s.io/yaml" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" ) -func bech32Prefixes(config *sdk.Config) []string { +func bech32Prefixes(mainBech32Prefix string) []string { return []string{ - config.GetBech32AccountAddrPrefix(), - config.GetBech32AccountPubPrefix(), - config.GetBech32ValidatorAddrPrefix(), - config.GetBech32ValidatorPubPrefix(), - config.GetBech32ConsensusAddrPrefix(), - config.GetBech32ConsensusPubPrefix(), + mainBech32Prefix, + sdk.GetBech32PrefixAccPub(mainBech32Prefix), + sdk.GetBech32PrefixValAddr(mainBech32Prefix), + sdk.GetBech32PrefixValPub(mainBech32Prefix), + sdk.GetBech32PrefixConsAddr(mainBech32Prefix), + sdk.GetBech32PrefixConsPub(mainBech32Prefix), } } @@ -44,8 +45,8 @@ type bech32Output struct { Formats []string `json:"formats"` } -func newBech32Output(config *sdk.Config, bs []byte) bech32Output { - bech32Prefixes := bech32Prefixes(config) +func newBech32Output(bech32Prefix string, bs []byte) bech32Output { + bech32Prefixes := bech32Prefixes(bech32Prefix) out := bech32Output{Formats: make([]string, len(bech32Prefixes))} for i, prefix := range bech32Prefixes { @@ -80,15 +81,18 @@ hexadecimal into bech32 cosmos prefixed format and vice versa. `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - config, _ := sdk.GetSealedConfig(cmd.Context()) - return doParseKey(cmd, config, args) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + return doParseKey(cmd, clientCtx.AddressPrefix, args) }, } return cmd } -func doParseKey(cmd *cobra.Command, config *sdk.Config, args []string) error { +func doParseKey(cmd *cobra.Command, bech32Prefix string, args []string) error { addr := strings.TrimSpace(args[0]) outstream := cmd.OutOrStdout() @@ -97,7 +101,7 @@ func doParseKey(cmd *cobra.Command, config *sdk.Config, args []string) error { } output, _ := cmd.Flags().GetString(flags.FlagOutput) - if !(runFromBech32(outstream, addr, output) || runFromHex(config, outstream, addr, output)) { + if !(runFromBech32(outstream, addr, output) || runFromHex(bech32Prefix, outstream, addr, output)) { return errors.New("couldn't find valid bech32 nor hex data") } @@ -117,13 +121,13 @@ func runFromBech32(w io.Writer, bech32str, output string) bool { } // print info from hex -func runFromHex(config *sdk.Config, w io.Writer, hexstr, output string) bool { +func runFromHex(bech32Prefix string, w io.Writer, hexstr, output string) bool { bz, err := hex.DecodeString(hexstr) if err != nil { return false } - displayParseKeyInfo(w, newBech32Output(config, bz), output) + displayParseKeyInfo(w, newBech32Output(bech32Prefix, bz), output) return true } diff --git a/client/keys/parse_test.go b/client/keys/parse_test.go index 687922db3c6c..650cb7c501f0 100644 --- a/client/keys/parse_test.go +++ b/client/keys/parse_test.go @@ -4,16 +4,12 @@ import ( "testing" "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" ) func TestParseKey(t *testing.T) { bech32str := "cosmos104ytdpvrx9284zd50v9ep8c6j7pua7dkk0x3ek" hexstr := "EB5AE9872103497EC092EF901027049E4F39200C60040D3562CD7F104A39F62E6E5A39A818F4" - config := sdk.NewConfig() - tests := []struct { name string args []string @@ -27,7 +23,7 @@ func TestParseKey(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.wantErr, doParseKey(ParseKeyStringCommand(), config, tt.args) != nil) + require.Equal(t, tt.wantErr, doParseKey(ParseKeyStringCommand(), "cosmos", tt.args) != nil) }) } } diff --git a/client/keys/rename_test.go b/client/keys/rename_test.go index 62253d382be5..e67d0df8d4c8 100644 --- a/client/keys/rename_test.go +++ b/client/keys/rename_test.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -33,7 +34,7 @@ func Test_runRenameCmd(t *testing.T) { path := sdk.GetFullBIP44Path() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc) require.NoError(t, err) diff --git a/client/keys/show.go b/client/keys/show.go index fd2abe33b720..22c14ddaeb58 100644 --- a/client/keys/show.go +++ b/client/keys/show.go @@ -175,7 +175,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) { return err } - return ledger.ShowAddress(*ledgerItem.Path, pk, sdk.GetConfig().GetBech32AccountAddrPrefix()) + return ledger.ShowAddress(*ledgerItem.Path, pk, clientCtx.AddressPrefix) } return nil diff --git a/client/keys/show_test.go b/client/keys/show_test.go index 5d7f9c033263..ac6c162b5076 100644 --- a/client/keys/show_test.go +++ b/client/keys/show_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -56,7 +57,7 @@ func Test_runShowCmd(t *testing.T) { mockIn := testutil.ApplyMockIODiscardOutErr(cmd) kbHome := t.TempDir() - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn, cdc) require.NoError(t, err) diff --git a/client/tx/aux_builder.go b/client/tx/aux_builder.go index be9616ae759e..ade6622f87a0 100644 --- a/client/tx/aux_builder.go +++ b/client/tx/aux_builder.go @@ -151,7 +151,7 @@ func (b *AuxTxBuilder) SetExtensionOptions(extOpts ...*codectypes.Any) { b.auxSignerData.SignDoc.BodyBytes = nil } -// SetSignature sets the aux signer's signature. +// SetNonCriticalExtensionOptions sets the aux signer's non-critical extension options. func (b *AuxTxBuilder) SetNonCriticalExtensionOptions(extOpts ...*codectypes.Any) { b.checkEmptyFields() diff --git a/client/tx/aux_builder_test.go b/client/tx/aux_builder_test.go index f177ba730a89..b0c7e3e874eb 100644 --- a/client/tx/aux_builder_test.go +++ b/client/tx/aux_builder_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -33,7 +34,7 @@ var ( func TestAuxTxBuilder(t *testing.T) { counterModule := counter.AppModule{} - cdc := moduletestutil.MakeTestEncodingConfig(counterModule).Codec + cdc := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, counterModule).Codec reg := codectypes.NewInterfaceRegistry() testdata.RegisterInterfaces(reg) diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index 205f388fdbe3..8859531dbdd2 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -28,8 +29,10 @@ import ( ) func newTestTxConfig() (client.TxConfig, codec.Codec) { - encodingConfig := moduletestutil.MakeTestEncodingConfig() - return authtx.NewTxConfig(codec.NewProtoCodec(encodingConfig.InterfaceRegistry), authtx.DefaultSignModes), encodingConfig.Codec + encodingConfig := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}) + cdc := codec.NewProtoCodec(encodingConfig.InterfaceRegistry) + signingCtx := encodingConfig.InterfaceRegistry.SigningContext() + return authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes), encodingConfig.Codec } // mockContext is a mock client.Context to return arbitrary simulation response, used to @@ -153,7 +156,7 @@ func TestBuildUnsignedTx(t *testing.T) { } func TestBuildUnsignedTxWithWithExtensionOptions(t *testing.T) { - txCfg := moduletestutil.MakeBuilderTestTxConfig() + txCfg := moduletestutil.MakeBuilderTestTxConfig(testutil.CodecOptions{}) extOpts := []*codectypes.Any{ { TypeUrl: "/test", diff --git a/client/v2/CHANGELOG.md b/client/v2/CHANGELOG.md index 3d2b21baa384..00ebfc727d27 100644 --- a/client/v2/CHANGELOG.md +++ b/client/v2/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* [#19618](https://github.com/cosmos/cosmos-sdk/pull/19618) Marshal enum as string in queries. * [#19060](https://github.com/cosmos/cosmos-sdk/pull/19060) Use client context from root (or enhanced) command in autocli commands. * Note, the given command must have a `client.Context` in its context. * [#19216](https://github.com/cosmos/cosmos-sdk/pull/19216) Do not overwrite TxConfig, use directly the one provided in context. TxConfig should always be set in the `client.Context` in `root.go` of an app. diff --git a/client/v2/autocli/common_test.go b/client/v2/autocli/common_test.go index c75eaa5b17a4..2850abc226f3 100644 --- a/client/v2/autocli/common_test.go +++ b/client/v2/autocli/common_test.go @@ -22,6 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/codec/testutil" sdkkeyring "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -51,7 +52,7 @@ func initFixture(t *testing.T) *fixture { clientConn, err := grpc.Dial(listener.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) assert.NilError(t, err) - encodingConfig := moduletestutil.MakeTestEncodingConfig(bank.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, bank.AppModule{}) kr, err := sdkkeyring.New(sdk.KeyringServiceName(), sdkkeyring.BackendMemory, home, nil, encodingConfig.Codec) assert.NilError(t, err) @@ -62,8 +63,8 @@ func initFixture(t *testing.T) *fixture { banktypes.RegisterInterfaces(interfaceRegistry) clientCtx := client.Context{}. - WithAddressCodec(addresscodec.NewBech32Codec("cosmos")). - WithValidatorAddressCodec(addresscodec.NewBech32Codec("cosmosvaloper")). + WithAddressCodec(interfaceRegistry.SigningContext().AddressCodec()). + WithValidatorAddressCodec(interfaceRegistry.SigningContext().ValidatorAddressCodec()). WithConsensusAddressCodec(addresscodec.NewBech32Codec("cosmosvalcons")). WithKeyring(kr). WithKeyringDir(home). diff --git a/client/v2/autocli/query.go b/client/v2/autocli/query.go index 7b9d8bdcbf00..d93edb4dfce7 100644 --- a/client/v2/autocli/query.go +++ b/client/v2/autocli/query.go @@ -111,6 +111,7 @@ func (b *Builder) BuildQueryMethodCommand(ctx context.Context, descriptor protor outputType := util.ResolveMessageType(b.TypeResolver, descriptor.Output()) encoderOptions := aminojson.EncoderOptions{ Indent: " ", + EnumAsString: true, DoNotSortFields: true, TypeResolver: b.TypeResolver, FileResolver: b.FileResolver, diff --git a/client/v2/go.mod b/client/v2/go.mod index 62468c46493f..0473c4c9320c 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -148,13 +148,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/client/v2/go.sum b/client/v2/go.sum index e8330138e4c2..6fe8a6de5077 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -755,8 +755,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -875,12 +875,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/codec/any_test.go b/codec/any_test.go index ccb63f129682..d9996ec3d3c4 100644 --- a/codec/any_test.go +++ b/codec/any_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -71,7 +72,7 @@ func TestMarshalAny(t *testing.T) { func TestMarshalProtoPubKey(t *testing.T) { require := require.New(t) - ccfg := testutil.MakeTestEncodingConfig() + ccfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) privKey := ed25519.GenPrivKey() pk := privKey.PubKey() @@ -111,7 +112,7 @@ func TestMarshalProtoPubKey(t *testing.T) { // helper functions func TestMarshalProtoInterfacePubKey(t *testing.T) { require := require.New(t) - ccfg := testutil.MakeTestEncodingConfig() + ccfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) privKey := ed25519.GenPrivKey() pk := privKey.PubKey() diff --git a/codec/testutil/codec.go b/codec/testutil/codec.go index 4887aa2727b5..c3c14ee1f40e 100644 --- a/codec/testutil/codec.go +++ b/codec/testutil/codec.go @@ -3,6 +3,7 @@ package testutil import ( "github.com/cosmos/gogoproto/proto" + coreaddress "cosmossdk.io/core/address" "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/codec" @@ -10,34 +11,45 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) -// CodecOptions are options for creating a test codec. +// CodecOptions are options for creating a test codec. If set, provided address codecs will be prioritized when +// building the InterfaceRegistry and ProtoCodec. If not set, new address bech32 codecs will be created using +// the provided prefixes. type CodecOptions struct { AccAddressPrefix string ValAddressPrefix string + AddressCodec coreaddress.Codec + ValidatorCodec coreaddress.Codec } -// NewInterfaceRegistry returns a new InterfaceRegistry with the given options. -func (o CodecOptions) NewInterfaceRegistry() codectypes.InterfaceRegistry { - accAddressPrefix := o.AccAddressPrefix - if accAddressPrefix == "" { - accAddressPrefix = "cosmos" +// NewCodecOptionsWithPrefixes returns CodecOptions with provided prefixes. +func NewCodecOptionsWithPrefixes(addressPrefix, validatorPrefix string) CodecOptions { + return CodecOptions{ + AccAddressPrefix: addressPrefix, + ValAddressPrefix: validatorPrefix, } +} - valAddressPrefix := o.ValAddressPrefix - if valAddressPrefix == "" { - valAddressPrefix = "cosmosvaloper" +// NewCodecOptionsWithCodecs returns CodecOptions with provided address codecs. +func NewCodecOptionsWithCodecs(addressCodec, validatorCodec coreaddress.Codec) CodecOptions { + return CodecOptions{ + AddressCodec: addressCodec, + ValidatorCodec: validatorCodec, } +} +// NewInterfaceRegistry returns a new InterfaceRegistry with the given options. +func (o CodecOptions) NewInterfaceRegistry() codectypes.InterfaceRegistry { ir, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{ ProtoFiles: proto.HybridResolver, SigningOptions: signing.Options{ - AddressCodec: address.NewBech32Codec(accAddressPrefix), - ValidatorAddressCodec: address.NewBech32Codec(valAddressPrefix), + AddressCodec: o.GetAddressCodec(), + ValidatorAddressCodec: o.GetValidatorCodec(), }, }) if err != nil { panic(err) } + return ir } @@ -45,3 +57,33 @@ func (o CodecOptions) NewInterfaceRegistry() codectypes.InterfaceRegistry { func (o CodecOptions) NewCodec() *codec.ProtoCodec { return codec.NewProtoCodec(o.NewInterfaceRegistry()) } + +// GetAddressCodec returns the address codec. If not address codec was provided it'll create a new one based on the +// bech32 prefix. +func (o CodecOptions) GetAddressCodec() coreaddress.Codec { + if o.AddressCodec != nil { + return o.AddressCodec + } + + accAddressPrefix := o.AccAddressPrefix + if accAddressPrefix == "" { + accAddressPrefix = "cosmos" + } + + return address.NewBech32Codec(accAddressPrefix) +} + +// GetValidatorCodec returns the validator address codec. If not validator codec was provided it'll create a new one +// based on the bech32 prefix. +func (o CodecOptions) GetValidatorCodec() coreaddress.Codec { + if o.ValidatorCodec != nil { + return o.ValidatorCodec + } + + valAddressPrefix := o.ValAddressPrefix + if valAddressPrefix == "" { + valAddressPrefix = "cosmosvaloper" + } + + return address.NewBech32Codec(valAddressPrefix) +} diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go index babd46a446d3..cbeb1913ace0 100644 --- a/codec/types/interface_registry.go +++ b/codec/types/interface_registry.go @@ -9,7 +9,9 @@ import ( "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/runtime/protoiface" + "cosmossdk.io/core/registry" "cosmossdk.io/x/tx/signing" ) @@ -33,24 +35,7 @@ type AnyUnpacker interface { type InterfaceRegistry interface { AnyUnpacker jsonpb.AnyResolver - - // RegisterInterface associates protoName as the public name for the - // interface passed in as iface. This is to be used primarily to create - // a public facing registry of interface implementations for clients. - // protoName should be a well-chosen public facing name that remains stable. - // RegisterInterface takes an optional list of impls to be registered - // as implementations of iface. - // - // Ex: - // registry.RegisterInterface("cosmos.base.v1beta1.Msg", (*sdk.Msg)(nil)) - RegisterInterface(protoName string, iface interface{}, impls ...proto.Message) - - // RegisterImplementations registers impls as concrete implementations of - // the interface iface. - // - // Ex: - // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, &MsgMultiSend{}) - RegisterImplementations(iface interface{}, impls ...proto.Message) + registry.LegacyRegistry // ListAllInterfaces list the type URLs of all registered interfaces. ListAllInterfaces() []string @@ -158,7 +143,7 @@ func NewInterfaceRegistryWithOptions(options InterfaceRegistryOptions) (Interfac }, nil } -func (registry *interfaceRegistry) RegisterInterface(protoName string, iface interface{}, impls ...proto.Message) { +func (registry *interfaceRegistry) RegisterInterface(protoName string, iface interface{}, impls ...protoiface.MessageV1) { typ := reflect.TypeOf(iface) if typ.Elem().Kind() != reflect.Interface { panic(fmt.Errorf("%T is not an interface type", iface)) @@ -188,7 +173,7 @@ func (registry *interfaceRegistry) EnsureRegistered(impl interface{}) error { // // This function PANICs if different concrete types are registered under the // same typeURL. -func (registry *interfaceRegistry) RegisterImplementations(iface interface{}, impls ...proto.Message) { +func (registry *interfaceRegistry) RegisterImplementations(iface interface{}, impls ...protoiface.MessageV1) { for _, impl := range impls { typeURL := MsgTypeURL(impl) registry.registerImpl(iface, typeURL, impl) diff --git a/codec/unknownproto/regression_test.go b/codec/unknownproto/regression_test.go index 3473e6481c14..84ee71cc5838 100644 --- a/codec/unknownproto/regression_test.go +++ b/codec/unknownproto/regression_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/types/module/testutil" ) @@ -14,7 +15,7 @@ import ( // protowire.ConsumeFieldValue. Discovered from fuzzing. func TestBadBytesPassedIntoDecoder(t *testing.T) { data, _ := hex.DecodeString("0A9F010A9C200A2D2F6962632E636F72652E636F6E6E656374696F6E2E76312E4D7367436F6E6E656374696F584F75656E496E6974126B0A0D6962637A65726F636C69656E74120B6962637A65726F636F6E6E1A1C0A0C6962636F6E65636C69656E74120A6962636F6E65636F6E6E00002205312E302E302A283235454635364341373935313335453430393336384536444238313130463232413442453035433212080A0612040A0208011A40143342993E25DA936CDDC7BE3D8F603CA6E9661518D536D0C482E18A0154AA096E438A6B9BCADFCFC2F0D689DCCAF55B96399D67A8361B70F5DA13091E2F929") - cfg := testutil.MakeTestEncodingConfig() + cfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) decoder := cfg.TxConfig.TxDecoder() tx, err := decoder(data) diff --git a/core/appmodule/module.go b/core/appmodule/module.go index 7f352a28e7b6..e36e271eab6f 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -6,7 +6,7 @@ import ( "google.golang.org/grpc" "google.golang.org/protobuf/runtime/protoiface" - appmodule "cosmossdk.io/core/appmodule/v2" + "cosmossdk.io/core/appmodule/v2" ) // AppModule is a tag interface for app module implementations to use as a basis @@ -70,6 +70,9 @@ type HasBeginBlocker = appmodule.HasBeginBlocker // custom logic after transaction processing in a block. type HasEndBlocker = appmodule.HasEndBlocker +// HasRegisterInterfaces is the interface for modules to register their msg types. +type HasRegisterInterfaces = appmodule.HasRegisterInterfaces + // MsgHandlerRouter is implemented by the runtime provider. type MsgHandlerRouter interface { // RegisterHandler is called by modules to register msg handler functions. diff --git a/core/appmodule/v2/appmodule.go b/core/appmodule/v2/appmodule.go index eb44c9f513b8..b0bfb19d2fcc 100644 --- a/core/appmodule/v2/appmodule.go +++ b/core/appmodule/v2/appmodule.go @@ -3,6 +3,7 @@ package appmodule import ( "context" + "cosmossdk.io/core/registry" "cosmossdk.io/core/transaction" ) @@ -90,3 +91,8 @@ type ValidatorUpdate struct { PubKeyType string Power int64 // updated power of the validtor } + +// HasRegisterInterfaces is the interface for modules to register their msg types. +type HasRegisterInterfaces interface { + RegisterInterfaces(registry.LegacyRegistry) +} diff --git a/core/gas/service.go b/core/gas/service.go index 9495201aa4c0..40d212e943f1 100644 --- a/core/gas/service.go +++ b/core/gas/service.go @@ -39,6 +39,8 @@ type Service interface { // WithBlockGasMeter returns a new context with the provided block-level gas meter. WithBlockGasMeter(ctx context.Context, meter Meter) context.Context + + GetGasConfig(ctx context.Context) GasConfig } // Meter represents a gas meter for modules consumption @@ -48,3 +50,13 @@ type Meter interface { Remaining() Gas Limit() Gas } + +type GasConfig struct { + HasCost Gas + DeleteCost Gas + ReadCostFlat Gas + ReadCostPerByte Gas + WriteCostFlat Gas + WriteCostPerByte Gas + IterNextCostFlat Gas +} diff --git a/core/registry/legacy.go b/core/registry/legacy.go new file mode 100644 index 000000000000..0f921132c1c1 --- /dev/null +++ b/core/registry/legacy.go @@ -0,0 +1,25 @@ +package registry + +import ( + "google.golang.org/protobuf/runtime/protoiface" +) + +type LegacyRegistry interface { + // RegisterInterface associates protoName as the public name for the + // interface passed in as iface. This is to be used primarily to create + // a public facing registry of interface implementations for clients. + // protoName should be a well-chosen public facing name that remains stable. + // RegisterInterface takes an optional list of impls to be registered + // as implementations of iface. + // + // Ex: + // registry.RegisterInterface("cosmos.base.v1beta1.Msg", (*sdk.Msg)(nil)) + RegisterInterface(protoName string, iface interface{}, impls ...protoiface.MessageV1) + + // RegisterImplementations registers impls as concrete implementations of + // the interface iface. + // + // Ex: + // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, &MsgMultiSend{}) + RegisterImplementations(iface interface{}, impls ...protoiface.MessageV1) +} diff --git a/crypto/armor.go b/crypto/armor.go index 47eba69d8a63..d7bebe96e15a 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -241,7 +241,7 @@ func decryptPrivKey(saltBytes, encBytes []byte, passphrase, kdf string) (privKey key = crypto.Sha256(key) // Get 32 bytes privKeyBytes, err = xsalsa20symmetric.DecryptSymmetric(encBytes, key) - if err == xsalsa20symmetric.ErrCiphertextDecrypt { + if errors.Is(err, xsalsa20symmetric.ErrCiphertextDecrypt) { return privKey, sdkerrors.ErrWrongPassword } default: diff --git a/crypto/hd/hdpath.go b/crypto/hd/hdpath.go index 4c0529e8324e..9ef9961d1213 100644 --- a/crypto/hd/hdpath.go +++ b/crypto/hd/hdpath.go @@ -4,6 +4,7 @@ import ( "crypto/hmac" "crypto/sha512" "encoding/binary" + "errors" "fmt" "math/big" "path/filepath" @@ -88,7 +89,7 @@ func NewParamsFromPath(path string) (*BIP44Params, error) { } if !(change == 0 || change == 1) { - return nil, fmt.Errorf("change field can only be 0 or 1") + return nil, errors.New("change field can only be 0 or 1") } return &BIP44Params{ diff --git a/crypto/keyring/errors.go b/crypto/keyring/errors.go index 3ebbb2409481..13ea72356c5b 100644 --- a/crypto/keyring/errors.go +++ b/crypto/keyring/errors.go @@ -1,6 +1,6 @@ package keyring -import "github.com/cockroachdb/errors" +import "errors" var ( // ErrUnsupportedSigningAlgo is raised when the caller tries to use a @@ -14,8 +14,8 @@ var ( // ErrOverwriteKey is raised when a key cannot be overwritten ErrOverwriteKey = errors.New("cannot overwrite key") // ErrKeyAlreadyExists is raised when creating a key that already exists - ErrKeyAlreadyExists = errors.Newf("key already exists") - // ErrInvalidSignMode is raised when trying to sign with an invaled method + ErrKeyAlreadyExists = errors.New("key already exists") + // ErrInvalidSignMode is raised when trying to sign with an invalid method ErrInvalidSignMode = errors.New("invalid sign mode, expected LEGACY_AMINO_JSON or TEXTUAL") // ErrMaxPassPhraseAttempts is raised when the maxPassphraseEntryAttempts is reached ErrMaxPassPhraseAttempts = errors.New("too many failed passphrase attempts") @@ -30,7 +30,7 @@ var ( // ErrNotLedgerObj is raised when record.GetLedger() returns nil. ErrNotLedgerObj = errors.New("not a ledger object") // ErrLedgerInvalidSignature is raised when ledger generates an invalid signature. - ErrLedgerInvalidSignature = errors.New("Ledger generated an invalid signature. Perhaps you have multiple ledgers and need to try another one") + ErrLedgerInvalidSignature = errors.New("ledger generated an invalid signature. Perhaps you have multiple ledgers and need to try another one") // ErrLegacyToRecord is raised when cannot be converted to a Record ErrLegacyToRecord = errors.New("unable to convert LegacyInfo to Record") // ErrUnknownLegacyType is raised when a LegacyInfo type is unknown. diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index 22673e06fa09..e46db74693b3 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -3,6 +3,7 @@ package keyring import ( "bufio" "encoding/hex" + "errors" "fmt" "io" "os" @@ -11,7 +12,6 @@ import ( "strings" "github.com/99designs/keyring" - "github.com/cockroachdb/errors" "github.com/cosmos/go-bip39" "golang.org/x/crypto/bcrypt" @@ -435,7 +435,7 @@ func (ks keystore) SaveLedgerKey(uid string, algo SignatureAlgo, hrp string, coi priv, _, err := ledger.NewPrivKeySecp256k1(*hdPath, hrp) if err != nil { - return nil, errors.CombineErrors(ErrLedgerGenerateKey, err) + return nil, errorsmod.Wrap(ErrLedgerGenerateKey, err.Error()) } return ks.writeLedgerKey(uid, priv.PubKey(), hdPath) @@ -534,7 +534,7 @@ func (ks keystore) KeyByAddress(address []byte) (*Record, error) { } func wrapKeyNotFound(err error, msg string) error { - if err == keyring.ErrKeyNotFound { + if errors.Is(err, keyring.ErrKeyNotFound) { return errorsmod.Wrap(sdkerrors.ErrKeyNotFound, msg) } return err @@ -822,7 +822,7 @@ func (ks keystore) writeRecord(k *Record) error { serializedRecord, err := ks.cdc.Marshal(k) if err != nil { - return errors.CombineErrors(ErrUnableToSerialize, err) + return errorsmod.Wrap(ErrUnableToSerialize, err.Error()) } item := keyring.Item{ @@ -977,7 +977,7 @@ func (ks keystore) migrate(key string) (*Record, error) { serializedRecord, err := ks.cdc.Marshal(k) if err != nil { - return nil, errors.CombineErrors(ErrUnableToSerialize, err) + return nil, errorsmod.Wrap(ErrUnableToSerialize, err.Error()) } item = keyring.Item{ diff --git a/crypto/keyring/keyring_ledger_test.go b/crypto/keyring/keyring_ledger_test.go index ca1b79bfbf99..89f1013b6428 100644 --- a/crypto/keyring/keyring_ledger_test.go +++ b/crypto/keyring/keyring_ledger_test.go @@ -5,9 +5,9 @@ package keyring import ( "bytes" + "errors" "testing" - "github.com/cockroachdb/errors" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/hd" diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index acd4c6d7f3cc..142360dd7fef 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -1119,7 +1119,7 @@ func TestNewAccount(t *testing.T) { bip39Passphrease: "", algo: hd.Secp256k1, mnemonic: "fresh enact fresh ski large bicycle marine abandon motor end pact mixture annual elite bind fan write warrior adapt common manual cool happy dutch", - expectedErr: fmt.Errorf("Invalid byte at position"), + expectedErr: errors.New("invalid byte at position"), }, { name: "in memory invalid mnemonic", @@ -1129,7 +1129,7 @@ func TestNewAccount(t *testing.T) { bip39Passphrease: "", algo: hd.Secp256k1, mnemonic: "malarkey pair crucial catch public canyon evil outer stage ten gym tornado", - expectedErr: fmt.Errorf("Invalid mnemonic"), + expectedErr: errors.New("invalid mnemonic"), }, } for _, tt := range tests { diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 7bdaad0e5b00..47cbe3e9a920 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -1,6 +1,7 @@ package keyring import ( + "errors" "fmt" "github.com/cosmos/cosmos-sdk/codec/legacy" @@ -77,7 +78,7 @@ func (i legacyLocalInfo) GetAlgo() hd.PubKeyType { // GetPath returns bip44 path, but not available for this type func (i legacyLocalInfo) GetPath() (*hd.BIP44Params, error) { - return nil, fmt.Errorf("BIP44 Paths are not available for this type") + return nil, errors.New("BIP44 Paths are not available for this type") } // legacyLedgerInfo is the public information about a Ledger key @@ -155,7 +156,7 @@ func (i legacyOfflineInfo) GetAddress() sdk.AccAddress { // GetPath returns bip44 path, but not available for this type func (i legacyOfflineInfo) GetPath() (*hd.BIP44Params, error) { - return nil, fmt.Errorf("BIP44 Paths are not available for this type") + return nil, errors.New("BIP44 Paths are not available for this type") } // Deprecated: this structure is not used anymore and it's here only to allow @@ -213,7 +214,7 @@ func (i LegacyMultiInfo) GetAlgo() hd.PubKeyType { // GetPath returns bip44 path, but not available for this type func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) { - return nil, fmt.Errorf("BIP44 Paths are not available for this type") + return nil, errors.New("BIP44 Paths are not available for this type") } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces @@ -258,7 +259,7 @@ func privKeyFromLegacyInfo(info LegacyInfo) (cryptotypes.PrivKey, error) { switch linfo := info.(type) { case legacyLocalInfo: if linfo.PrivKeyArmor == "" { - return nil, fmt.Errorf("private key not available") + return nil, errors.New("private key not available") } priv, err := legacy.PrivKeyFromBytes([]byte(linfo.PrivKeyArmor)) if err != nil { diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index c461f7f6a4c4..96141e4c906e 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -1,7 +1,7 @@ package keyring import ( - "github.com/cockroachdb/errors" + "errors" errorsmod "cosmossdk.io/errors" diff --git a/crypto/keyring/signing_algorithms.go b/crypto/keyring/signing_algorithms.go index 4a22a98a8e19..eb5e5d43ae6f 100644 --- a/crypto/keyring/signing_algorithms.go +++ b/crypto/keyring/signing_algorithms.go @@ -3,7 +3,7 @@ package keyring import ( "strings" - "github.com/cockroachdb/errors" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/crypto/hd" ) @@ -22,7 +22,7 @@ func NewSigningAlgoFromString(str string, algoList SigningAlgoList) (SignatureAl return algo, nil } } - return nil, errors.Wrap(ErrUnsupportedSigningAlgo, str) + return nil, errorsmod.Wrap(ErrUnsupportedSigningAlgo, str) } // SigningAlgoList is a slice of signature algorithms diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index b0c28052a8cf..8ded87ec3f77 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -3,6 +3,7 @@ package ed25519 import ( "crypto/ed25519" "crypto/subtle" + "errors" "fmt" "io" @@ -14,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) //------------------------------------- @@ -102,7 +103,7 @@ func (privKey PrivKey) MarshalAmino() ([]byte, error) { // UnmarshalAmino overrides Amino binary marshaling. func (privKey *PrivKey) UnmarshalAmino(bz []byte) error { if len(bz) != PrivKeySize { - return fmt.Errorf("invalid privkey size") + return errors.New("invalid privkey size") } privKey.Key = bz @@ -211,7 +212,7 @@ func (pubKey PubKey) MarshalAmino() ([]byte, error) { // UnmarshalAmino overrides Amino binary marshaling. func (pubKey *PubKey) UnmarshalAmino(bz []byte) error { if len(bz) != PubKeySize { - return errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size") + return errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "invalid pubkey size") } pubKey.Key = bz diff --git a/crypto/keys/secp256k1/secp256k1.go b/crypto/keys/secp256k1/secp256k1.go index b995eb633492..4073684076ff 100644 --- a/crypto/keys/secp256k1/secp256k1.go +++ b/crypto/keys/secp256k1/secp256k1.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/sha256" "crypto/subtle" + "errors" "fmt" "io" "math/big" @@ -17,7 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) var ( @@ -66,7 +67,7 @@ func (privKey PrivKey) MarshalAmino() ([]byte, error) { // UnmarshalAmino overrides Amino binary marshaling. func (privKey *PrivKey) UnmarshalAmino(bz []byte) error { if len(bz) != PrivKeySize { - return fmt.Errorf("invalid privkey size") + return errors.New("invalid privkey size") } privKey.Key = bz @@ -202,7 +203,7 @@ func (pubKey PubKey) MarshalAmino() ([]byte, error) { // UnmarshalAmino overrides Amino binary marshaling. func (pubKey *PubKey) UnmarshalAmino(bz []byte) error { if len(bz) != PubKeySize { - return errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size") + return errorsmod.Wrap(sdkerrors.ErrInvalidPubKey, "invalid pubkey size") } pubKey.Key = bz diff --git a/crypto/ledger/ledger_test.go b/crypto/ledger/ledger_test.go index 1c742791a35f..a0ff890b935c 100644 --- a/crypto/ledger/ledger_test.go +++ b/crypto/ledger/ledger_test.go @@ -95,7 +95,7 @@ func TestPublicKeySafe(t *testing.T) { require.NoError(t, err) require.NotNil(t, priv) - require.Nil(t, ShowAddress(path, priv.PubKey(), sdk.GetConfig().GetBech32AccountAddrPrefix())) + require.Nil(t, ShowAddress(path, priv.PubKey(), "cosmos")) checkDefaultPubKey(t, priv) addr2 := sdk.AccAddress(priv.PubKey().Address()).String() diff --git a/docs/build/building-apps/05-app-testnet.md b/docs/build/building-apps/05-app-testnet.md new file mode 100644 index 000000000000..c799236872d7 --- /dev/null +++ b/docs/build/building-apps/05-app-testnet.md @@ -0,0 +1,235 @@ +--- +sidebar_position: 1 +--- + +# Application Testnets + +Building an application is complicated and requires a lot of testing. The Cosmos SDK provides a way to test your application in a real-world environment: a testnet. + +We allow developers to take the state from their mainnet and run tests against the state. This is useful for testing upgrade migrations, or for testing the application in a real-world environment. + +## Testnet Setup + +We will be breaking down the steps to create a testnet from mainnet state. + +```go + // InitMerlinAppForTestnet is broken down into two sections: + // Required Changes: Changes that, if not made, will cause the testnet to halt or panic + // Optional Changes: Changes to customize the testnet to one's liking (lower vote times, fund accounts, etc) + func InitMerlinAppForTestnet(app *MerlinApp, newValAddr bytes.HexBytes, newValPubKey crypto.PubKey, newOperatorAddress, upgradeToTrigger string) *MerlinApp { + ... + } +``` + +### Required Changes + +#### Staking + +When creating a testnet the important part is migrate the validator set from many validators to one or a few. This allows developers to spin up the chain without needing to replace validator keys. + +```go + ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) + pubkey := &ed25519.PubKey{Key: newValPubKey.Bytes()} + pubkeyAny, err := types.NewAnyWithValue(pubkey) + if err != nil { + tmos.Exit(err.Error()) + } + + // STAKING + // + + // Create Validator struct for our new validator. + _, bz, err := bech32.DecodeAndConvert(newOperatorAddress) + if err != nil { + tmos.Exit(err.Error()) + } + bech32Addr, err := bech32.ConvertAndEncode("simvaloper", bz) + if err != nil { + tmos.Exit(err.Error()) + } + newVal := stakingtypes.Validator{ + OperatorAddress: bech32Addr, + ConsensusPubkey: pubkeyAny, + Jailed: false, + Status: stakingtypes.Bonded, + Tokens: sdk.NewInt(900000000000000), + DelegatorShares: sdk.MustNewDecFromStr("10000000"), + Description: stakingtypes.Description{ + Moniker: "Testnet Validator", + }, + Commission: stakingtypes.Commission{ + CommissionRates: stakingtypes.CommissionRates{ + Rate: sdk.MustNewDecFromStr("0.05"), + MaxRate: sdk.MustNewDecFromStr("0.1"), + MaxChangeRate: sdk.MustNewDecFromStr("0.05"), + }, + }, + MinSelfDelegation: sdk.OneInt(), + } + + // Remove all validators from power store + stakingKey := app.GetKey(stakingtypes.ModuleName) + stakingStore := ctx.KVStore(stakingKey) + iterator := app.StakingKeeper.ValidatorsPowerStoreIterator(ctx) + for ; iterator.Valid(); iterator.Next() { + stakingStore.Delete(iterator.Key()) + } + iterator.Close() + + // Remove all valdiators from last validators store + iterator = app.StakingKeeper.LastValidatorsIterator(ctx) + for ; iterator.Valid(); iterator.Next() { + app.StakingKeeper.LastValidatorPower.Delete(iterator.Key()) + } + iterator.Close() + + // Add our validator to power and last validators store + app.StakingKeeper.SetValidator(ctx, newVal) + err = app.StakingKeeper.SetValidatorByConsAddr(ctx, newVal) + if err != nil { + panic(err) + } + app.StakingKeeper.SetValidatorByPowerIndex(ctx, newVal) + app.StakingKeeper.SetLastValidatorPower(ctx, newVal.GetOperator(), 0) + if err := app.StakingKeeper.Hooks().AfterValidatorCreated(ctx, newVal.GetOperator()); err != nil { + panic(err) + } +``` + +#### Distribution + +Since the validator set has changed, we need to update the distribution records for the new validator. + + +```go + // Initialize records for this validator across all distribution stores + app.DistrKeeper.ValidatorHistoricalRewards.Set(ctx, newVal.GetOperator(), 0, distrtypes.NewValidatorHistoricalRewards(sdk.DecCoins{}, 1)) + app.DistrKeeper.ValidatorCurrentRewards.Set(ctx, newVal.GetOperator(), distrtypes.NewValidatorCurrentRewards(sdk.DecCoins{}, 1)) + app.DistrKeeper.ValidatorAccumulatedCommission.Set(ctx, newVal.GetOperator(), distrtypes.InitialValidatorAccumulatedCommission()) + app.DistrKeeper.ValidatorOutstandingRewards.Set(ctx, newVal.GetOperator(), distrtypes.ValidatorOutstandingRewards{Rewards: sdk.DecCoins{}}) +``` + +#### Slashing + +We also need to set the validator signing info for the new validator. + +```go + // SLASHING + // + + // Set validator signing info for our new validator. + newConsAddr := sdk.ConsAddress(newValAddr.Bytes()) + newValidatorSigningInfo := slashingtypes.ValidatorSigningInfo{ + Address: newConsAddr.String(), + StartHeight: app.LastBlockHeight() - 1, + Tombstoned: false, + } + app.SlashingKeeper.ValidatorSigningInfo.Set(ctx, newConsAddr, newValidatorSigningInfo) +``` + +#### Bank + +It is useful to create new accounts for your testing purposes. This avoids the need to have the same key as you may have on mainnet. + +```go + // BANK + // + + defaultCoins := sdk.NewCoins(sdk.NewInt64Coin("ustake", 1000000000000)) + + localMerlinAccounts := []sdk.AccAddress{ + sdk.MustAccAddressFromBech32("cosmos12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj"), + sdk.MustAccAddressFromBech32("cosmos1cyyzpxplxdzkeea7kwsydadg87357qnahakaks"), + sdk.MustAccAddressFromBech32("cosmos18s5lynnmx37hq4wlrw9gdn68sg2uxp5rgk26vv"), + sdk.MustAccAddressFromBech32("cosmos1qwexv7c6sm95lwhzn9027vyu2ccneaqad4w8ka"), + sdk.MustAccAddressFromBech32("cosmos14hcxlnwlqtq75ttaxf674vk6mafspg8xwgnn53"), + sdk.MustAccAddressFromBech32("cosmos12rr534cer5c0vj53eq4y32lcwguyy7nndt0u2t"), + sdk.MustAccAddressFromBech32("cosmos1nt33cjd5auzh36syym6azgc8tve0jlvklnq7jq"), + sdk.MustAccAddressFromBech32("cosmos10qfrpash5g2vk3hppvu45x0g860czur8ff5yx0"), + sdk.MustAccAddressFromBech32("cosmos1f4tvsdukfwh6s9swrc24gkuz23tp8pd3e9r5fa"), + sdk.MustAccAddressFromBech32("cosmos1myv43sqgnj5sm4zl98ftl45af9cfzk7nhjxjqh"), + sdk.MustAccAddressFromBech32("cosmos14gs9zqh8m49yy9kscjqu9h72exyf295afg6kgk"), + sdk.MustAccAddressFromBech32("cosmos1jllfytsz4dryxhz5tl7u73v29exsf80vz52ucc")} + + // Fund localMerlin accounts + for _, account := range localMerlinAccounts { + err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, defaultCoins) + if err != nil { + tmos.Exit(err.Error()) + } + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, account, defaultCoins) + if err != nil { + tmos.Exit(err.Error()) + } + } +``` + +#### Upgrade + +If you would like to schedule an upgrade the below can be used. + +```go + // UPGRADE + // + + if upgradeToTrigger != "" { + upgradePlan := upgradetypes.Plan{ + Name: upgradeToTrigger, + Height: app.LastBlockHeight(), + } + err = app.UpgradeKeeper.ScheduleUpgrade(ctx, upgradePlan) + if err != nil { + panic(err) + } + } +``` + +### Optional Changes + +If you have custom modules that rely on specific state from the above modules and/or you would like to test your custom module, you will need to update the state of your custom module to reflect your needs + +## Running the Testnet + +Before we can run the testnet we must plug everything together. + +in `root.go`, in the `initRootCmd` function we add: + +```diff + server.AddCommands(rootCmd, simapp.DefaultNodeHome, newApp, createMerlinAppAndExport, addModuleInitFlags) + ++ server.AddTestnetCreatorCommand(rootCmd, simapp.DefaultNodeHome, newTestnetApp, addModuleInitFlags) +``` + +Next we will add a newTestnetApp helper function: + +```diff +// newTestnetApp starts by running the normal newApp method. From there, the app interface returned is modified in order +// for a testnet to be created from the provided app. +func newTestnetApp(logger log.Logger, db cometbftdb.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { + // Create an app and type cast to an MerlinApp + app := newApp(logger, db, traceStore, appOpts) + simApp, ok := app.(*simapp.SimApp) + if !ok { + panic("app created from newApp is not of type simApp") + } + + newValAddr, ok := appOpts.Get(server.KeyNewValAddr).(bytes.HexBytes) + if !ok { + panic("newValAddr is not of type bytes.HexBytes") + } + newValPubKey, ok := appOpts.Get(server.KeyUserPubKey).(crypto.PubKey) + if !ok { + panic("newValPubKey is not of type crypto.PubKey") + } + newOperatorAddress, ok := appOpts.Get(server.KeyNewOpAddr).(string) + if !ok { + panic("newOperatorAddress is not of type string") + } + upgradeToTrigger, ok := appOpts.Get(server.KeyTriggerTestnetUpgrade).(string) + if !ok { + panic("upgradeToTrigger is not of type string") + } + + // Make modifications to the normal MerlinApp required to run the network locally + return meriln.InitMerlinAppForTestnet(simApp, newValAddr, newValPubKey, newOperatorAddress, upgradeToTrigger) +} +``` diff --git a/go.mod b/go.mod index 567c7107d7c8..f6a60c02dd80 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/tendermint/go-amino v0.16.0 gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b - golang.org/x/crypto v0.20.0 + golang.org/x/crypto v0.21.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 golang.org/x/sync v0.6.0 google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 @@ -161,8 +161,8 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/go.sum b/go.sum index 315dd1392a26..dcdbce372a92 100644 --- a/go.sum +++ b/go.sum @@ -764,8 +764,8 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -894,15 +894,15 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/go.work.example b/go.work.example index 89c48b57cec8..11cf4a9864dd 100644 --- a/go.work.example +++ b/go.work.example @@ -1,6 +1,6 @@ go 1.22 -toolchain go1.22.0 +toolchain go1.22 use ( . diff --git a/runtime/gas.go b/runtime/gas.go index 5a18ec511b54..f6e28c9f2f56 100644 --- a/runtime/gas.go +++ b/runtime/gas.go @@ -30,6 +30,10 @@ func (g GasService) WithBlockGasMeter(ctx context.Context, meter gas.Meter) cont return sdk.UnwrapSDKContext(ctx).WithGasMeter(SDKGasMeter{gm: meter}) } +func (g GasService) GetGasConfig(ctx context.Context) gas.GasConfig { + return gas.GasConfig(sdk.UnwrapSDKContext(ctx).KVGasConfig()) +} + // ______________________________________________________________________________________________ // Gas Meter Wrappers // ______________________________________________________________________________________________ @@ -98,3 +102,35 @@ func (cgm CoreGasmeter) Remaining() gas.Gas { func (cgm CoreGasmeter) Limit() gas.Gas { return cgm.gm.Limit() } + +type GasConfig struct { + gc gas.GasConfig +} + +func (gc GasConfig) HasCost() gas.Gas { + return gc.gc.HasCost +} + +func (gc GasConfig) DeleteCost() gas.Gas { + return gc.gc.DeleteCost +} + +func (gc GasConfig) ReadCostFlat() gas.Gas { + return gc.gc.ReadCostFlat +} + +func (gc GasConfig) ReadCostPerByte() gas.Gas { + return gc.gc.ReadCostPerByte +} + +func (gc GasConfig) WriteCostFlat() gas.Gas { + return gc.gc.WriteCostFlat +} + +func (gc GasConfig) WriteCostPerByte() gas.Gas { + return gc.gc.WriteCostPerByte +} + +func (gc GasConfig) IterNextCostFlat() gas.Gas { + return gc.gc.IterNextCostFlat +} diff --git a/server/util_test.go b/server/util_test.go index 2ec1a27bc6e7..11f5cbb208c9 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -450,7 +451,7 @@ func TestEmptyMinGasPrices(t *testing.T) { tempDir := t.TempDir() err := os.Mkdir(filepath.Join(tempDir, "config"), os.ModePerm) require.NoError(t, err) - encCfg := testutil.MakeTestEncodingConfig() + encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) // Run InitCmd to create necessary config files. clientCtx := client.Context{}.WithHomeDir(tempDir).WithCodec(encCfg.Codec) diff --git a/simapp/app.go b/simapp/app.go index dce427ef62c0..be410d5d70dc 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -207,7 +207,8 @@ func NewSimApp( }) appCodec := codec.NewProtoCodec(interfaceRegistry) legacyAmino := codec.NewLegacyAmino() - txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes) + signingCtx := interfaceRegistry.SigningContext() + txConfig := authtx.NewTxConfig(appCodec, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) std.RegisterLegacyAminoCodec(legacyAmino) std.RegisterInterfaces(interfaceRegistry) @@ -278,13 +279,11 @@ func NewSimApp( app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), logger), authtypes.NewModuleAddress(govtypes.ModuleName).String()) bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) - addressCodec := authcodec.NewBech32Codec(sdk.Bech32MainPrefix) - // add keepers accountsKeeper, err := accounts.NewKeeper( appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), logger), - addressCodec, + signingCtx.AddressCodec(), appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter(), @@ -300,7 +299,7 @@ func NewSimApp( } app.AccountsKeeper = accountsKeeper - app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, addressCodec, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) app.BankKeeper = bankkeeper.NewBaseKeeper( runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), logger), @@ -315,6 +314,10 @@ func NewSimApp( txConfigOpts := authtx.ConfigOptions{ EnabledSignModes: enabledSignModes, TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), + SigningOptions: &signing.Options{ + AddressCodec: signingCtx.AddressCodec(), + ValidatorAddressCodec: signingCtx.ValidatorAddressCodec(), + }, } txConfig, err = authtx.NewTxConfigWithOptions( appCodec, @@ -326,7 +329,7 @@ func NewSimApp( app.txConfig = txConfig app.StakingKeeper = stakingkeeper.NewKeeper( - appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), logger), app.AuthKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), + appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), logger), app.AuthKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), signingCtx.ValidatorAddressCodec(), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), ) app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger), app.StakingKeeper, app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) @@ -380,10 +383,7 @@ func NewSimApp( Example of setting gov params: govConfig.MaxMetadataLen = 10000 */ - govKeeper := govkeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AuthKeeper, app.BankKeeper, - app.StakingKeeper, app.PoolKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) + govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger, runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String()) // Set legacy router for backwards compatibility with gov v1beta1 govKeeper.SetLegacyRouter(govRouter) diff --git a/simapp/go.mod b/simapp/go.mod index c75ac8cdc017..386e1bc23717 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -202,14 +202,14 @@ require ( go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 2124be9a4581..c26abbac81e8 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -1099,8 +1099,8 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1350,16 +1350,16 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/simapp/gomod2nix.toml b/simapp/gomod2nix.toml index 8847d6510f38..d04275637515 100644 --- a/simapp/gomod2nix.toml +++ b/simapp/gomod2nix.toml @@ -505,8 +505,8 @@ schema = 3 version = "v1.11.0" hash = "sha256-Lb6rHHfR62Ozg2j2JZy3MKOMKdsfzd1IYTR57r3Mhp0=" [mod."golang.org/x/crypto"] - version = "v0.20.0" - hash = "sha256-7C0tDus5x3xRsSE08yOtZzMpOFym1Q9XP+U+CJ1sWmc=" + version = "v0.21.0" + hash = "sha256-Z4k1LvFh4Jai7HUe6TTuXSG3VnuiRpMwdARIdZZqSYk=" [mod."golang.org/x/exp"] version = "v0.0.0-20240222234643-814bf88cf225" hash = "sha256-DM6/KUjyqyuqXai7UH1vMsoKXQAlYfcHTwK1dHqjRAc=" @@ -523,11 +523,11 @@ schema = 3 version = "v0.6.0" hash = "sha256-LLims/wjDZtIqlYCVHREewcUOX4hwRwplEuZKPOJ/HI=" [mod."golang.org/x/sys"] - version = "v0.17.0" - hash = "sha256-e0qnE+SitE02IzvnJKI4Uzpq9EOZY+zvE8Wf5b2e6Kg=" + version = "v0.18.0" + hash = "sha256-bIFhfFp7Sj0E1gcE3X3l/jecCfSRLgrkb8f0Yr6tVR0=" [mod."golang.org/x/term"] - version = "v0.17.0" - hash = "sha256-lCo7WPHe8Q9q76f0D8FrfoX90MTvwa21O+Dwr1mOAcA=" + version = "v0.18.0" + hash = "sha256-lpze9arFZIhBV8Ht3VZyoiUwqPkeH2IwfXt8M3xljiM=" [mod."golang.org/x/text"] version = "v0.14.0" hash = "sha256-yh3B0tom1RfzQBf1RNmfdNWF1PtiqxV41jW1GVS6JAg=" diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index f15e3d0c4966..e2c0fec47604 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -14,6 +14,7 @@ import ( "cosmossdk.io/x/auth/tx" authtxconfig "cosmossdk.io/x/auth/tx/config" "cosmossdk.io/x/auth/types" + txsigning "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" @@ -49,7 +50,9 @@ func NewRootCmd() *cobra.Command { WithValidatorAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix())). WithConsensusAddressCodec(addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix())). WithHomeDir(simapp.DefaultNodeHome). - WithViper("") // uses by default the binary name as prefix + WithViper(""). // uses by default the binary name as prefix + WithAddressPrefix(sdk.GetConfig().GetBech32AccountAddrPrefix()). + WithValidatorPrefix(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) rootCmd := &cobra.Command{ Use: "simd", @@ -80,6 +83,10 @@ func NewRootCmd() *cobra.Command { txConfigOpts := tx.ConfigOptions{ EnabledSignModes: enabledSignModes, TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx), + SigningOptions: &txsigning.Options{ + AddressCodec: initClientCtx.InterfaceRegistry.SigningContext().AddressCodec(), + ValidatorAddressCodec: initClientCtx.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + }, } txConfig, err := tx.NewTxConfigWithOptions( initClientCtx.Codec, diff --git a/simapp/simd/cmd/root_v2.go b/simapp/simd/cmd/root_v2.go index edbf0ea2cf50..796a4ce85ff2 100644 --- a/simapp/simd/cmd/root_v2.go +++ b/simapp/simd/cmd/root_v2.go @@ -7,6 +7,8 @@ import ( "github.com/spf13/cobra" + authv1 "cosmossdk.io/api/cosmos/auth/module/v1" + stakingv1 "cosmossdk.io/api/cosmos/staking/module/v1" "cosmossdk.io/client/v2/autocli" clientv2keyring "cosmossdk.io/client/v2/autocli/keyring" "cosmossdk.io/core/address" @@ -103,6 +105,8 @@ func ProvideClientContext( addressCodec address.Codec, validatorAddressCodec runtime.ValidatorAddressCodec, consensusAddressCodec runtime.ConsensusAddressCodec, + authConfig *authv1.Module, + stakingConfig *stakingv1.Module, ) client.Context { var err error @@ -116,7 +120,9 @@ func ProvideClientContext( WithValidatorAddressCodec(validatorAddressCodec). WithConsensusAddressCodec(consensusAddressCodec). WithHomeDir(simapp.DefaultNodeHome). - WithViper("") // uses by default the binary name as prefix + WithViper(""). // uses by default the binary name as prefix + WithAddressPrefix(authConfig.Bech32Prefix). + WithValidatorPrefix(stakingConfig.Bech32PrefixValidator) // Read the config to overwrite the default values with the values from the config file customClientTemplate, customClientConfig := initClientConfig() diff --git a/simapp/simd/cmd/testnet_test.go b/simapp/simd/cmd/testnet_test.go index 60ba6126fb97..c78f3408dc9c 100644 --- a/simapp/simd/cmd/testnet_test.go +++ b/simapp/simd/cmd/testnet_test.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/testutil/configurator" "github.com/cosmos/cosmos-sdk/types/module" @@ -46,7 +47,7 @@ func Test_TestnetCmd(t *testing.T) { require.Len(t, moduleManager.Modules, 7) home := t.TempDir() - encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, staking.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, staking.AppModule{}) logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultCometConfig(home) require.NoError(t, err) diff --git a/store/go.mod b/store/go.mod index 1c7eee1772dc..02997eab33f4 100644 --- a/store/go.mod +++ b/store/go.mod @@ -58,9 +58,9 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/zerolog v1.32.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect google.golang.org/grpc v1.62.0 // indirect diff --git a/store/go.sum b/store/go.sum index 628c42dcec16..5e79baeedc11 100644 --- a/store/go.sum +++ b/store/go.sum @@ -233,8 +233,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -283,8 +283,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/tests/go.mod b/tests/go.mod index c285e300effc..431bc08d0a74 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -200,14 +200,14 @@ require ( go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect diff --git a/tests/go.sum b/tests/go.sum index c06556409153..7f2d8d180071 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -1075,8 +1075,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1317,13 +1317,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/tests/integration/auth/client/cli/suite_test.go b/tests/integration/auth/client/cli/suite_test.go index 454ff4e1b82e..963a313045c5 100644 --- a/tests/integration/auth/client/cli/suite_test.go +++ b/tests/integration/auth/client/cli/suite_test.go @@ -25,6 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -56,7 +57,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}, gov.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, gov.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/tests/integration/bank/app_test.go b/tests/integration/bank/app_test.go index e51ad0137323..eeca54284fff 100644 --- a/tests/integration/bank/app_test.go +++ b/tests/integration/bank/app_test.go @@ -26,6 +26,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + cdctestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -175,7 +176,7 @@ func TestSendNotEnoughBalance(t *testing.T) { require.NoError(t, err) sendMsg := types.NewMsgSend(addr1Str, addr2Str, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)}) header := header.Info{Height: baseApp.LastBlockHeight() + 1} - txConfig := moduletestutil.MakeTestTxConfig() + txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{}) _, _, err = simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1) require.Error(t, err) @@ -255,7 +256,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { header := header.Info{Height: baseApp.LastBlockHeight() + 1} - txConfig := moduletestutil.MakeTestTxConfig() + txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{}) _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) if tc.expPass { require.NoError(t, err) @@ -308,7 +309,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { for _, tc := range testCases { header := header.Info{Height: baseApp.LastBlockHeight() + 1} - txConfig := moduletestutil.MakeTestTxConfig() + txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{}) _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) @@ -363,7 +364,7 @@ func TestMsgMultiSendDependent(t *testing.T) { for _, tc := range testCases { header := header.Info{Height: baseApp.LastBlockHeight() + 1} - txConfig := moduletestutil.MakeTestTxConfig() + txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{}) _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) diff --git a/tests/integration/bank/bench_test.go b/tests/integration/bank/bench_test.go index 628d85a50eeb..b953a3f39ec9 100644 --- a/tests/integration/bank/bench_test.go +++ b/tests/integration/bank/bench_test.go @@ -15,6 +15,7 @@ import ( stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -82,7 +83,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { _, err = baseApp.Commit() require.NoError(b, err) - txGen := moduletestutil.MakeTestTxConfig() + txGen := moduletestutil.MakeTestTxConfig(codectestutil.CodecOptions{}) txEncoder := txGen.TxEncoder() // pre-compute all txs @@ -140,7 +141,7 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { _, err = baseApp.Commit() require.NoError(b, err) - txGen := moduletestutil.MakeTestTxConfig() + txGen := moduletestutil.MakeTestTxConfig(codectestutil.CodecOptions{}) txEncoder := txGen.TxEncoder() // pre-compute all txs diff --git a/tests/integration/bank/keeper/deterministic_test.go b/tests/integration/bank/keeper/deterministic_test.go index 566aac120d38..635e061dd915 100644 --- a/tests/integration/bank/keeper/deterministic_test.go +++ b/tests/integration/bank/keeper/deterministic_test.go @@ -23,6 +23,7 @@ import ( _ "cosmossdk.io/x/staking" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -63,7 +64,8 @@ type deterministicFixture struct { func initDeterministicFixture(t *testing.T) *deterministicFixture { t.Helper() keys := storetypes.NewKVStoreKeys(authtypes.StoreKey, banktypes.StoreKey) - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}).Codec + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}) + cdc := encodingCfg.Codec logger := log.NewTestLogger(t) cms := integration.CreateMultiStore(keys, logger) @@ -101,10 +103,13 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture { authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper) - integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - }) + integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + map[string]appmodule.AppModule{ + authtypes.ModuleName: authModule, + banktypes.ModuleName: bankModule, + }) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) diff --git a/tests/integration/distribution/cli_tx_test.go b/tests/integration/distribution/cli_tx_test.go index e45c228a032b..f7e6767558e8 100644 --- a/tests/integration/distribution/cli_tx_test.go +++ b/tests/integration/distribution/cli_tx_test.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -38,7 +39,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig() + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index 4c4ee67abc76..962d6c8779e9 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -33,6 +33,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" sdk "github.com/cosmos/cosmos-sdk/types" @@ -66,7 +67,8 @@ func initFixture(t *testing.T) *fixture { keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, distrtypes.StoreKey, pooltypes.StoreKey, stakingtypes.StoreKey, ) - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, distribution.AppModule{}, protocolpool.AppModule{}).Codec + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}) + cdc := encodingCfg.Codec logger := log.NewTestLogger(t) cms := integration.CreateMultiStore(keys, logger) @@ -138,13 +140,16 @@ func initFixture(t *testing.T) *fixture { }, }) - integrationApp := integration.NewIntegrationApp(ctx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - stakingtypes.ModuleName: stakingModule, - distrtypes.ModuleName: distrModule, - pooltypes.ModuleName: poolModule, - }) + integrationApp := integration.NewIntegrationApp(ctx, logger, keys, cdc, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + map[string]appmodule.AppModule{ + authtypes.ModuleName: authModule, + banktypes.ModuleName: bankModule, + stakingtypes.ModuleName: stakingModule, + distrtypes.ModuleName: distrModule, + pooltypes.ModuleName: poolModule, + }) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) diff --git a/tests/integration/evidence/keeper/infraction_test.go b/tests/integration/evidence/keeper/infraction_test.go index 1b0241ff87f8..5c9977d6c7c6 100644 --- a/tests/integration/evidence/keeper/infraction_test.go +++ b/tests/integration/evidence/keeper/infraction_test.go @@ -41,6 +41,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -87,7 +88,8 @@ func initFixture(tb testing.TB) *fixture { keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, consensusparamtypes.StoreKey, evidencetypes.StoreKey, stakingtypes.StoreKey, slashingtypes.StoreKey, ) - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, evidence.AppModule{}).Codec + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, evidence.AppModule{}) + cdc := encodingCfg.Codec logger := log.NewTestLogger(tb) cms := integration.CreateMultiStore(keys, logger) @@ -141,13 +143,16 @@ func initFixture(tb testing.TB) *fixture { slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry()) evidenceModule := evidence.NewAppModule(*evidenceKeeper) - integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - stakingtypes.ModuleName: stakingModule, - slashingtypes.ModuleName: slashingModule, - evidencetypes.ModuleName: evidenceModule, - }) + integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + map[string]appmodule.AppModule{ + authtypes.ModuleName: authModule, + banktypes.ModuleName: bankModule, + stakingtypes.ModuleName: stakingModule, + slashingtypes.ModuleName: slashingModule, + evidencetypes.ModuleName: evidenceModule, + }) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) diff --git a/tests/integration/example/example_test.go b/tests/integration/example/example_test.go index 71a9acb8770c..e921c175021b 100644 --- a/tests/integration/example/example_test.go +++ b/tests/integration/example/example_test.go @@ -18,6 +18,7 @@ import ( minttypes "cosmossdk.io/x/mint/types" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,7 +30,9 @@ import ( func Example() { // in this example we are testing the integration of the following modules: // - mint, which directly depends on auth, bank and staking - encodingCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, mint.AppModule{}) + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, mint.AppModule{}) + signingCtx := encodingCfg.InterfaceRegistry.SigningContext() + keys := storetypes.NewKVStoreKeys(authtypes.StoreKey, minttypes.StoreKey) authority := authtypes.NewModuleAddress("gov").String() @@ -63,6 +66,8 @@ func Example() { logger, keys, encodingCfg.Codec, + signingCtx.AddressCodec(), + signingCtx.ValidatorAddressCodec(), map[string]appmodule.AppModule{ authtypes.ModuleName: authModule, minttypes.ModuleName: mintModule, @@ -118,7 +123,7 @@ func Example() { // That module has no dependency on other modules. func Example_oneModule() { // in this example we are testing the integration of the auth module: - encodingCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) keys := storetypes.NewKVStoreKeys(authtypes.StoreKey) authority := authtypes.NewModuleAddress("gov").String() @@ -147,6 +152,8 @@ func Example_oneModule() { logger, keys, encodingCfg.Codec, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), map[string]appmodule.AppModule{ authtypes.ModuleName: authModule, }, diff --git a/tests/integration/gov/abci_test.go b/tests/integration/gov/abci_test.go index 25816e948ff0..dbe612a20496 100644 --- a/tests/integration/gov/abci_test.go +++ b/tests/integration/gov/abci_test.go @@ -10,7 +10,6 @@ import ( "cosmossdk.io/math" authtypes "cosmossdk.io/x/auth/types" banktypes "cosmossdk.io/x/bank/types" - "cosmossdk.io/x/gov" "cosmossdk.io/x/gov/keeper" "cosmossdk.io/x/gov/types" v1 "cosmossdk.io/x/gov/types/v1" @@ -41,7 +40,7 @@ func TestUnregisteredProposal_InactiveProposalFails(t *testing.T) { err = suite.GovKeeper.InactiveProposalsQueue.Set(ctx, collections.Join(endTime, proposal.Id), proposal.Id) require.NoError(t, err) - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) _, err = suite.GovKeeper.Proposals.Get(ctx, proposal.Id) @@ -69,7 +68,7 @@ func TestUnregisteredProposal_ActiveProposalFails(t *testing.T) { err = suite.GovKeeper.ActiveProposalsQueue.Set(ctx, collections.Join(endTime, proposal.Id), proposal.Id) require.NoError(t, err) - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) p, err := suite.GovKeeper.Proposals.Get(ctx, proposal.Id) @@ -109,7 +108,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) { newHeader.Time = ctx.HeaderInfo().Time.Add(*params.MaxDepositPeriod) ctx = ctx.WithHeaderInfo(newHeader) - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) } @@ -159,12 +158,12 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { newHeader.Time = ctx.HeaderInfo().Time.Add(*params.MaxDepositPeriod).Add(time.Duration(-1) * time.Second) ctx = ctx.WithHeaderInfo(newHeader) - require.NoError(t, gov.EndBlocker(ctx, suite.GovKeeper)) + require.NoError(t, suite.GovKeeper.EndBlocker(ctx)) newHeader = ctx.HeaderInfo() newHeader.Time = ctx.HeaderInfo().Time.Add(time.Duration(5) * time.Second) ctx = ctx.WithHeaderInfo(newHeader) - require.NoError(t, gov.EndBlocker(ctx, suite.GovKeeper)) + require.NoError(t, suite.GovKeeper.EndBlocker(ctx)) } func TestTickPassedDepositPeriod(t *testing.T) { @@ -246,7 +245,7 @@ func TestProposalDepositRefundFailEndBlocker(t *testing.T) { newHeader.Time = proposal.VotingEndTime.Add(time.Duration(100) * time.Second) ctx = ctx.WithHeaderInfo(newHeader) - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) // no error, means does not halt the chain events := ctx.EventManager().Events() @@ -314,7 +313,7 @@ func TestTickPassedVotingPeriod(t *testing.T) { require.NoError(t, err) require.Equal(t, v1.StatusVotingPeriod, proposal.Status) - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) if tc.proposalType != v1.ProposalType_PROPOSAL_TYPE_EXPEDITED { @@ -395,7 +394,7 @@ func TestProposalPassedEndblocker(t *testing.T) { newHeader.Time = ctx.HeaderInfo().Time.Add(*params.MaxDepositPeriod).Add(*params.VotingPeriod) ctx = ctx.WithHeaderInfo(newHeader) - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) macc = suite.GovKeeper.GetGovernanceAccount(ctx) require.NotNil(t, macc) @@ -450,7 +449,7 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { ctx = ctx.WithHeaderInfo(newHeader) // validate that the proposal fails/has been rejected - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) // check proposal events events := ctx.EventManager().Events() @@ -553,7 +552,7 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { } // Here the expedited proposal is converted to regular after expiry. - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) if tc.expeditedPasses { proposal, err = suite.GovKeeper.Proposals.Get(ctx, res.ProposalId) @@ -602,7 +601,7 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { } // Here we validate the converted regular proposal - err = gov.EndBlocker(ctx, suite.GovKeeper) + err = suite.GovKeeper.EndBlocker(ctx) require.NoError(t, err) macc = suite.GovKeeper.GetGovernanceAccount(ctx) require.NotNil(t, macc) diff --git a/tests/integration/gov/genesis_test.go b/tests/integration/gov/genesis_test.go index 77b0701953b0..265ecb66d94c 100644 --- a/tests/integration/gov/genesis_test.go +++ b/tests/integration/gov/genesis_test.go @@ -173,7 +173,7 @@ func TestImportExportQueues(t *testing.T) { assert.DeepEqual(t, sdk.Coins(params.MinDeposit), s2.BankKeeper.GetAllBalances(ctx2, macc.GetAddress())) // Run the endblocker. Check to make sure that proposal1 is removed from state, and proposal2 is finished VotingPeriod. - err = gov.EndBlocker(ctx2, s2.GovKeeper) + err = s2.GovKeeper.EndBlocker(ctx2) assert.NilError(t, err) proposal1, err = s2.GovKeeper.Proposals.Get(ctx2, proposalID1) diff --git a/tests/integration/gov/keeper/keeper_test.go b/tests/integration/gov/keeper/keeper_test.go index 68561f4a7336..1a7b2608163c 100644 --- a/tests/integration/gov/keeper/keeper_test.go +++ b/tests/integration/gov/keeper/keeper_test.go @@ -29,6 +29,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" sdk "github.com/cosmos/cosmos-sdk/types" @@ -52,7 +53,8 @@ func initFixture(tb testing.TB) *fixture { keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, pooltypes.StoreKey, types.StoreKey, ) - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}, gov.AppModule{}).Codec + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, gov.AppModule{}) + cdc := encodingCfg.Codec logger := log.NewTestLogger(tb) cms := integration.CreateMultiStore(keys, logger) @@ -103,15 +105,16 @@ func initFixture(tb testing.TB) *fixture { // keeper. router := baseapp.NewMsgServiceRouter() router.SetInterfaceRegistry(cdc.InterfaceRegistry()) + queryRouter := baseapp.NewGRPCQueryRouter() + queryRouter.SetInterfaceRegistry(cdc.InterfaceRegistry()) govKeeper := keeper.NewKeeper( cdc, - runtime.NewKVStoreService(keys[types.StoreKey]), + runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, router)), accountKeeper, bankKeeper, stakingKeeper, poolKeeper, - router, keeper.DefaultConfig(), authority.String(), ) @@ -127,12 +130,15 @@ func initFixture(tb testing.TB) *fixture { stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper) govModule := gov.NewAppModule(cdc, govKeeper, accountKeeper, bankKeeper, poolKeeper) - integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - stakingtypes.ModuleName: stakingModule, - types.ModuleName: govModule, - }) + integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + map[string]appmodule.AppModule{ + authtypes.ModuleName: authModule, + banktypes.ModuleName: bankModule, + stakingtypes.ModuleName: stakingModule, + types.ModuleName: govModule, + }) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) diff --git a/tests/integration/slashing/keeper/keeper_test.go b/tests/integration/slashing/keeper/keeper_test.go index 14936367c4a8..a74665167221 100644 --- a/tests/integration/slashing/keeper/keeper_test.go +++ b/tests/integration/slashing/keeper/keeper_test.go @@ -30,6 +30,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -56,7 +57,8 @@ func initFixture(tb testing.TB) *fixture { keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, slashingtypes.StoreKey, stakingtypes.StoreKey, ) - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}).Codec + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) + cdc := encodingCfg.Codec logger := log.NewTestLogger(tb) cms := integration.CreateMultiStore(keys, logger) @@ -100,11 +102,14 @@ func initFixture(tb testing.TB) *fixture { stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper) slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry()) - integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - banktypes.ModuleName: bankModule, - stakingtypes.ModuleName: stakingModule, - slashingtypes.ModuleName: slashingModule, - }) + integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + map[string]appmodule.AppModule{ + banktypes.ModuleName: bankModule, + stakingtypes.ModuleName: stakingModule, + slashingtypes.ModuleName: slashingModule, + }) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) diff --git a/tests/integration/staking/keeper/common_test.go b/tests/integration/staking/keeper/common_test.go index 35f617450db3..f864019603c0 100644 --- a/tests/integration/staking/keeper/common_test.go +++ b/tests/integration/staking/keeper/common_test.go @@ -26,6 +26,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -103,7 +104,8 @@ func initFixture(tb testing.TB) *fixture { keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, types.StoreKey, ) - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, staking.AppModule{}).Codec + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, staking.AppModule{}) + cdc := encodingCfg.Codec logger := log.NewTestLogger(tb) cms := integration.CreateMultiStore(keys, logger) @@ -147,11 +149,14 @@ func initFixture(tb testing.TB) *fixture { bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper) stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper) - integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - types.ModuleName: stakingModule, - }) + integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + map[string]appmodule.AppModule{ + authtypes.ModuleName: authModule, + banktypes.ModuleName: bankModule, + types.ModuleName: stakingModule, + }) sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context()) diff --git a/tests/integration/staking/keeper/deterministic_test.go b/tests/integration/staking/keeper/deterministic_test.go index 4f8b6e179a4c..cc8c2fbae654 100644 --- a/tests/integration/staking/keeper/deterministic_test.go +++ b/tests/integration/staking/keeper/deterministic_test.go @@ -27,6 +27,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/runtime" @@ -68,7 +69,8 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture { keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, ) - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, distribution.AppModule{}).Codec + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, distribution.AppModule{}) + cdc := encodingCfg.Codec logger := log.NewTestLogger(t) cms := integration.CreateMultiStore(keys, logger) @@ -111,11 +113,14 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture { bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper) stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper) - integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ - authtypes.ModuleName: authModule, - banktypes.ModuleName: bankModule, - stakingtypes.ModuleName: stakingModule, - }) + integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, + encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(), + encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), + map[string]appmodule.AppModule{ + authtypes.ModuleName: authModule, + banktypes.ModuleName: bankModule, + stakingtypes.ModuleName: stakingModule, + }) ctx := integrationApp.Context() diff --git a/tests/integration/tx/aminojson/aminojson_test.go b/tests/integration/tx/aminojson/aminojson_test.go index c66d43e7c991..c28ce9c0994f 100644 --- a/tests/integration/tx/aminojson/aminojson_test.go +++ b/tests/integration/tx/aminojson/aminojson_test.go @@ -61,6 +61,7 @@ import ( signing_testutil "cosmossdk.io/x/tx/signing/testutil" "cosmossdk.io/x/upgrade" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" ed25519types "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -92,8 +93,8 @@ import ( // by the mutation of genOpts passed to the generator. func TestAminoJSON_Equivalence(t *testing.T) { encCfg := testutil.MakeTestEncodingConfig( - auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{}, consensus.AppModule{}, - distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{}, + codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{}, + consensus.AppModule{}, distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{}, gov.AppModule{}, groupmodule.AppModule{}, mint.AppModule{}, slashing.AppModule{}, staking.AppModule{}, upgrade.AppModule{}, vesting.AppModule{}) legacytx.RegressionTestingAminoCodec = encCfg.Amino @@ -208,7 +209,7 @@ func newAny(t *testing.T, msg proto.Message) *anypb.Any { // TestAminoJSON_LegacyParity tests that the Encoder encoder produces the same output as the Encoder encoder. func TestAminoJSON_LegacyParity(t *testing.T) { - encCfg := testutil.MakeTestEncodingConfig(auth.AppModule{}, authzmodule.AppModule{}, + encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{}, distribution.AppModule{}, slashing.AppModule{}, staking.AppModule{}, vesting.AppModule{}, gov.AppModule{}) legacytx.RegressionTestingAminoCodec = encCfg.Amino @@ -512,7 +513,7 @@ func TestAminoJSON_LegacyParity(t *testing.T) { } func TestSendAuthorization(t *testing.T) { - encCfg := testutil.MakeTestEncodingConfig(auth.AppModule{}, authzmodule.AppModule{}, + encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{}, distribution.AppModule{}, bank.AppModule{}) aj := aminojson.NewEncoder(aminojson.EncoderOptions{}) @@ -562,7 +563,7 @@ func TestSendAuthorization(t *testing.T) { } func TestDecimalMutation(t *testing.T) { - encCfg := testutil.MakeTestEncodingConfig(staking.AppModule{}) + encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, staking.AppModule{}) rates := &stakingtypes.CommissionRates{} rateBz, _ := encCfg.Amino.MarshalJSON(rates) require.Equal(t, `{"rate":"0","max_rate":"0","max_change_rate":"0"}`, string(rateBz)) diff --git a/tests/integration/tx/decode_test.go b/tests/integration/tx/decode_test.go index 8e228951823f..fae669f89f61 100644 --- a/tests/integration/tx/decode_test.go +++ b/tests/integration/tx/decode_test.go @@ -30,6 +30,7 @@ import ( "cosmossdk.io/x/upgrade" "github.com/cosmos/cosmos-sdk/codec/legacy" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/tests/integration/rapidgen" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -43,8 +44,8 @@ import ( // TestDecode tests that the tx decoder can decode all the txs in the test suite. func TestDecode(t *testing.T) { encCfg := testutil.MakeTestEncodingConfig( - auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{}, consensus.AppModule{}, - distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{}, + codectestutil.CodecOptions{}, auth.AppModule{}, authzmodule.AppModule{}, bank.AppModule{}, + consensus.AppModule{}, distribution.AppModule{}, evidence.AppModule{}, feegrantmodule.AppModule{}, gov.AppModule{}, groupmodule.AppModule{}, mint.AppModule{}, slashing.AppModule{}, staking.AppModule{}, upgrade.AppModule{}, vesting.AppModule{}) legacytx.RegressionTestingAminoCodec = encCfg.Amino diff --git a/tests/starship/tests/go.mod b/tests/starship/tests/go.mod index cc47d40d264e..0587601091cf 100644 --- a/tests/starship/tests/go.mod +++ b/tests/starship/tests/go.mod @@ -230,14 +230,14 @@ require ( go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect diff --git a/tests/starship/tests/go.sum b/tests/starship/tests/go.sum index 3dc033d4f68b..f354c4c32409 100644 --- a/tests/starship/tests/go.sum +++ b/tests/starship/tests/go.sum @@ -1075,8 +1075,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1318,13 +1318,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/testutil/integration/router.go b/testutil/integration/router.go index dafaa7f9d011..45fa80dbbf44 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -8,6 +8,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" + "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/log" "cosmossdk.io/store" @@ -46,6 +47,8 @@ func NewIntegrationApp( logger log.Logger, keys map[string]*storetypes.KVStoreKey, appCodec codec.Codec, + addressCodec address.Codec, + validatorCodec address.Codec, modules map[string]appmodule.AppModule, ) *App { db := dbm.NewMemDB() @@ -54,7 +57,7 @@ func NewIntegrationApp( moduleManager := module.NewManagerFromMap(modules) moduleManager.RegisterInterfaces(interfaceRegistry) - txConfig := authtx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), authtx.DefaultSignModes) + txConfig := authtx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), addressCodec, validatorCodec, authtx.DefaultSignModes) bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseapp.SetChainID(appName)) bApp.MountKVStores(keys) diff --git a/testutil/key_test.go b/testutil/key_test.go index 26847d764752..4a44bb4a6b75 100644 --- a/testutil/key_test.go +++ b/testutil/key_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/types" @@ -13,7 +14,7 @@ import ( func TestGenerateCoinKey(t *testing.T) { t.Parallel() - cdc := testutil.MakeTestEncodingConfig().Codec + cdc := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec addr, mnemonic, err := GenerateCoinKey(hd.Secp256k1, cdc) require.NoError(t, err) @@ -28,7 +29,7 @@ func TestGenerateCoinKey(t *testing.T) { func TestGenerateSaveCoinKey(t *testing.T) { t.Parallel() - encCfg := testutil.MakeTestEncodingConfig() + encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil, encCfg.Codec) require.NoError(t, err) @@ -53,7 +54,7 @@ func TestGenerateSaveCoinKey(t *testing.T) { func TestGenerateSaveCoinKeyOverwriteFlag(t *testing.T) { t.Parallel() - encCfg := testutil.MakeTestEncodingConfig() + encCfg := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil, encCfg.Codec) require.NoError(t, err) diff --git a/testutil/mock/types_mock_appmodule.go b/testutil/mock/types_mock_appmodule.go index 144576e2bf6a..3d3f3c06442f 100644 --- a/testutil/mock/types_mock_appmodule.go +++ b/testutil/mock/types_mock_appmodule.go @@ -10,10 +10,10 @@ import ( reflect "reflect" appmodule "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" types "github.com/cometbft/cometbft/abci/types" client "github.com/cosmos/cosmos-sdk/client" codec "github.com/cosmos/cosmos-sdk/codec" - types0 "github.com/cosmos/cosmos-sdk/codec/types" types1 "github.com/cosmos/cosmos-sdk/types" module "github.com/cosmos/cosmos-sdk/types/module" gomock "github.com/golang/mock/gomock" @@ -150,7 +150,7 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) Name() *gomock.Call { } // RegisterInterfaces mocks base method. -func (m *MockAppModuleWithAllExtensions) RegisterInterfaces(arg0 types0.InterfaceRegistry) { +func (m *MockAppModuleWithAllExtensions) RegisterInterfaces(arg0 registry.LegacyRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInterfaces", arg0) } @@ -332,7 +332,7 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) Name() *gomock.Call { } // RegisterInterfaces mocks base method. -func (m *MockAppModuleWithAllExtensionsABCI) RegisterInterfaces(arg0 types0.InterfaceRegistry) { +func (m *MockAppModuleWithAllExtensionsABCI) RegisterInterfaces(arg0 registry.LegacyRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInterfaces", arg0) } diff --git a/testutil/mock/types_module_module.go b/testutil/mock/types_module_module.go index 2aac944f3138..044cca224fa5 100644 --- a/testutil/mock/types_module_module.go +++ b/testutil/mock/types_module_module.go @@ -9,10 +9,10 @@ import ( json "encoding/json" reflect "reflect" + "cosmossdk.io/core/registry" types "github.com/cometbft/cometbft/abci/types" client "github.com/cosmos/cosmos-sdk/client" codec "github.com/cosmos/cosmos-sdk/codec" - types0 "github.com/cosmos/cosmos-sdk/codec/types" types1 "github.com/cosmos/cosmos-sdk/types" module "github.com/cosmos/cosmos-sdk/types/module" gomock "github.com/golang/mock/gomock" @@ -69,7 +69,7 @@ func (mr *MockAppModuleBasicMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1 i } // RegisterInterfaces mocks base method. -func (m *MockAppModuleBasic) RegisterInterfaces(arg0 types0.InterfaceRegistry) { +func (m *MockAppModuleBasic) RegisterInterfaces(arg0 registry.LegacyRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInterfaces", arg0) } @@ -154,7 +154,7 @@ func (mr *MockAppModuleMockRecorder) Name() *gomock.Call { } // RegisterInterfaces mocks base method. -func (m *MockAppModule) RegisterInterfaces(arg0 types0.InterfaceRegistry) { +func (m *MockAppModule) RegisterInterfaces(arg0 registry.LegacyRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInterfaces", arg0) } @@ -326,7 +326,7 @@ func (m *MockHasRegisterInterfaces) EXPECT() *MockHasRegisterInterfacesMockRecor } // RegisterInterfaces mocks base method. -func (m *MockHasRegisterInterfaces) RegisterInterfaces(arg0 types0.InterfaceRegistry) { +func (m *MockHasRegisterInterfaces) RegisterInterfaces(arg0 registry.LegacyRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInterfaces", arg0) } @@ -740,7 +740,7 @@ func (mr *MockHasABCIEndBlockMockRecorder) Name() *gomock.Call { } // RegisterInterfaces mocks base method. -func (m *MockHasABCIEndBlock) RegisterInterfaces(arg0 types0.InterfaceRegistry) { +func (m *MockHasABCIEndBlock) RegisterInterfaces(arg0 registry.LegacyRegistry) { m.ctrl.T.Helper() m.ctrl.Call(m, "RegisterInterfaces", arg0) } diff --git a/testutil/sims/simulation_helpers.go b/testutil/sims/simulation_helpers.go index a1147231c64b..ac2d5b871cf7 100644 --- a/testutil/sims/simulation_helpers.go +++ b/testutil/sims/simulation_helpers.go @@ -52,10 +52,11 @@ func SetupSimulation(config simtypes.Config, dirPrefix, dbName string, verbose, // SimulationOperations retrieves the simulation params from the provided file path // and returns all the modules weighted operations func SimulationOperations(app runtime.AppSimI, cdc codec.Codec, config simtypes.Config) []simtypes.WeightedOperation { + signingCtx := cdc.InterfaceRegistry().SigningContext() simState := module.SimulationState{ AppParams: make(simtypes.AppParams), Cdc: cdc, - TxConfig: authtx.NewTxConfig(cdc, authtx.DefaultSignModes), // TODO(tip): we should extract this from app + TxConfig: authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes), // TODO(tip): we should extract this from app BondDenom: sdk.DefaultBondDenom, } diff --git a/tools/confix/go.mod b/tools/confix/go.mod index f982d683d2e1..61ddf3d35558 100644 --- a/tools/confix/go.mod +++ b/tools/confix/go.mod @@ -138,11 +138,11 @@ require ( github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.8 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect diff --git a/tools/confix/go.sum b/tools/confix/go.sum index eee7b15df3ba..2dce2f1323ea 100644 --- a/tools/confix/go.sum +++ b/tools/confix/go.sum @@ -762,8 +762,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -882,12 +882,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod index 9d3a13d476d7..b1b001d65339 100644 --- a/tools/cosmovisor/go.mod +++ b/tools/cosmovisor/go.mod @@ -159,13 +159,13 @@ require ( go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum index 671451f96d2b..50204b78722e 100644 --- a/tools/cosmovisor/go.sum +++ b/tools/cosmovisor/go.sum @@ -1051,8 +1051,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1290,13 +1290,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/tools/hubl/go.mod b/tools/hubl/go.mod index 5d4c22ce36e0..2becafd77a11 100644 --- a/tools/hubl/go.mod +++ b/tools/hubl/go.mod @@ -138,12 +138,12 @@ require ( github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.8 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect diff --git a/tools/hubl/go.sum b/tools/hubl/go.sum index 9daf81b2ef18..2ab5bdd38afa 100644 --- a/tools/hubl/go.sum +++ b/tools/hubl/go.sum @@ -761,8 +761,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -879,12 +879,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/types/address.go b/types/address.go index 3cafd383eb87..8bb0d56fc4c8 100644 --- a/types/address.go +++ b/types/address.go @@ -71,6 +71,31 @@ const ( Bech32PrefixConsPub = Bech32MainPrefix + PrefixValidator + PrefixConsensus + PrefixPublic ) +// GetBech32PrefixAccPub returns the Bech32 prefix of an account's public key. +func GetBech32PrefixAccPub(mainPrefix string) string { + return mainPrefix + PrefixPublic +} + +// GetBech32PrefixValAddr returns the Bech32 prefix of a validator's operator address. +func GetBech32PrefixValAddr(mainPrefix string) string { + return mainPrefix + PrefixValidator + PrefixOperator +} + +// GetBech32PrefixValPub returns the Bech32 prefix of a validator's operator public key. +func GetBech32PrefixValPub(mainPrefix string) string { + return mainPrefix + PrefixValidator + PrefixOperator + PrefixPublic +} + +// GetBech32PrefixConsAddr returns the Bech32 prefix of a consensus node address. +func GetBech32PrefixConsAddr(mainPrefix string) string { + return mainPrefix + PrefixValidator + PrefixConsensus +} + +// GetBech32PrefixConsPub returns the Bech32 prefix of a consensus node public key. +func GetBech32PrefixConsPub(mainPrefix string) string { + return mainPrefix + PrefixValidator + PrefixConsensus + PrefixPublic +} + // cache variables var ( // AccAddress.String() is expensive and if unoptimized dominantly showed up in profiles, diff --git a/types/config.go b/types/config.go index 7f638f255e34..7089ceaff74b 100644 --- a/types/config.go +++ b/types/config.go @@ -13,7 +13,6 @@ const DefaultKeyringServiceName = "cosmos" // Config is the structure that holds the SDK configuration parameters. // This could be used to initialize certain configuration parameters for the SDK. type Config struct { - fullFundraiserPath string bech32AddressPrefix map[string]string mtx sync.RWMutex @@ -39,7 +38,6 @@ func NewConfig() *Config { "validator_pub": Bech32PrefixValPub, "consensus_pub": Bech32PrefixConsPub, }, - fullFundraiserPath: FullFundraiserPath, } } @@ -96,14 +94,6 @@ func (config *Config) SetBech32PrefixForConsensusNode(addressPrefix, pubKeyPrefi config.bech32AddressPrefix["consensus_pub"] = pubKeyPrefix } -// Set the FullFundraiserPath (BIP44Prefix) on the config. -// -// Deprecated: This method is supported for backward compatibility only and will be removed in a future release. Use SetPurpose and SetCoinType instead. -func (config *Config) SetFullFundraiserPath(fullFundraiserPath string) { - config.assertNotSealed() - config.fullFundraiserPath = fullFundraiserPath -} - // Seal seals the config such that the config state could not be modified further func (config *Config) Seal() *Config { config.mtx.Lock() diff --git a/types/mempool/mempool_test.go b/types/mempool/mempool_test.go index bab941ae611b..3dbd5f1349b0 100644 --- a/types/mempool/mempool_test.go +++ b/types/mempool/mempool_test.go @@ -14,6 +14,7 @@ import ( "cosmossdk.io/log" "cosmossdk.io/x/auth/signing" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" @@ -236,7 +237,7 @@ func (s *MempoolTestSuite) TestSampleTxs() { } func unmarshalTx(txBytes []byte) (sdk.Tx, error) { - cfg := moduletestutil.MakeTestEncodingConfig(counter.AppModule{}) + cfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, counter.AppModule{}) return cfg.TxConfig.TxJSONDecoder()(txBytes) } diff --git a/types/module/core_module.go b/types/module/core_module.go index fa81659a16f0..ae3101043603 100644 --- a/types/module/core_module.go +++ b/types/module/core_module.go @@ -10,23 +10,23 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/registry" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" ) var ( _ appmodule.AppModule = coreAppModuleAdaptor{} - _ HasName = coreAppModuleAdaptor{} - _ HasAminoCodec = coreAppModuleAdaptor{} - _ HasGRPCGateway = coreAppModuleAdaptor{} - _ HasRegisterInterfaces = coreAppModuleAdaptor{} - _ HasABCIGenesis = coreAppModuleAdaptor{} - _ HasServices = coreAppModuleAdaptor{} + _ HasName = coreAppModuleAdaptor{} + _ HasAminoCodec = coreAppModuleAdaptor{} + _ HasGRPCGateway = coreAppModuleAdaptor{} + _ appmodule.HasRegisterInterfaces = coreAppModuleAdaptor{} + _ HasABCIGenesis = coreAppModuleAdaptor{} + _ HasServices = coreAppModuleAdaptor{} ) // CoreAppModuleAdaptor wraps the core API module as an AppModule that this version of the SDK can use. @@ -171,11 +171,11 @@ func (c coreAppModuleAdaptor) RegisterGRPCGatewayRoutes(ctx client.Context, mux } // RegisterInterfaces implements HasRegisterInterfaces -func (c coreAppModuleAdaptor) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (c coreAppModuleAdaptor) RegisterInterfaces(reg registry.LegacyRegistry) { if mod, ok := c.module.(interface { - RegisterInterfaces(registry codectypes.InterfaceRegistry) + RegisterInterfaces(registry.LegacyRegistry) }); ok { - mod.RegisterInterfaces(registry) + mod.RegisterInterfaces(reg) } } diff --git a/types/module/module.go b/types/module/module.go index 7afba9f1211d..4aa36f435c6f 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -33,12 +33,12 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/registry" errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -83,9 +83,7 @@ type HasAminoCodec interface { } // HasRegisterInterfaces is the interface for modules to register their msg types. -type HasRegisterInterfaces interface { - RegisterInterfaces(types.InterfaceRegistry) -} +type HasRegisterInterfaces appmodule.HasRegisterInterfaces // HasGRPCGateway is the interface for modules to register their gRPC gateway routes. type HasGRPCGateway interface { @@ -317,9 +315,9 @@ func (m *Manager) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers all module interface types -func (m *Manager) RegisterInterfaces(registry types.InterfaceRegistry) { +func (m *Manager) RegisterInterfaces(registry registry.LegacyRegistry) { for _, b := range m.Modules { - if mod, ok := b.(HasRegisterInterfaces); ok { + if mod, ok := b.(appmodule.HasRegisterInterfaces); ok { mod.RegisterInterfaces(registry) } } diff --git a/types/module/testutil/codec.go b/types/module/testutil/codec.go index 12bc63d9bacf..c6753e6b271e 100644 --- a/types/module/testutil/codec.go +++ b/types/module/testutil/codec.go @@ -22,15 +22,16 @@ type TestEncodingConfig struct { Amino *codec.LegacyAmino } -func MakeTestEncodingConfig(modules ...module.AppModule) TestEncodingConfig { +func MakeTestEncodingConfig(codecOpt testutil.CodecOptions, modules ...module.AppModule) TestEncodingConfig { aminoCodec := codec.NewLegacyAmino() - interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry() - codec := codec.NewProtoCodec(interfaceRegistry) + interfaceRegistry := codecOpt.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + signingCtx := cdc.InterfaceRegistry().SigningContext() encCfg := TestEncodingConfig{ InterfaceRegistry: interfaceRegistry, - Codec: codec, - TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), + Codec: cdc, + TxConfig: tx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes), Amino: aminoCodec, } @@ -43,10 +44,11 @@ func MakeTestEncodingConfig(modules ...module.AppModule) TestEncodingConfig { return encCfg } -func MakeTestTxConfig() client.TxConfig { - interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry() +func MakeTestTxConfig(codecOpt testutil.CodecOptions) client.TxConfig { + interfaceRegistry := codecOpt.NewInterfaceRegistry() cdc := codec.NewProtoCodec(interfaceRegistry) - return tx.NewTxConfig(cdc, tx.DefaultSignModes) + signingCtx := interfaceRegistry.SigningContext() + return tx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes) } type TestBuilderTxConfig struct { @@ -54,9 +56,9 @@ type TestBuilderTxConfig struct { TxBuilder *TestTxBuilder } -func MakeBuilderTestTxConfig() TestBuilderTxConfig { +func MakeBuilderTestTxConfig(codecOpt testutil.CodecOptions) TestBuilderTxConfig { return TestBuilderTxConfig{ - TxConfig: MakeTestTxConfig(), + TxConfig: MakeTestTxConfig(codecOpt), } } diff --git a/types/msgservice/msg_service.go b/types/msgservice/msg_service.go index 46de830f0014..e8c08f98a617 100644 --- a/types/msgservice/msg_service.go +++ b/types/msgservice/msg_service.go @@ -14,14 +14,15 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/descriptorpb" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "cosmossdk.io/core/registry" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" ) // RegisterMsgServiceDesc registers all type_urls from Msg services described // in `sd` into the registry. -func RegisterMsgServiceDesc(registry codectypes.InterfaceRegistry, sd *grpc.ServiceDesc) { +func RegisterMsgServiceDesc(registry registry.LegacyRegistry, sd *grpc.ServiceDesc) { fdBytesUnzipped := unzip(proto.FileDescriptor(sd.Metadata.(string))) if fdBytesUnzipped == nil { panic(fmt.Errorf("error unzipping file description for MsgService %s", sd.ServiceName)) diff --git a/x/accounts/defaults/base/account.go b/x/accounts/defaults/base/account.go index 36f858e85d1e..76f76124996f 100644 --- a/x/accounts/defaults/base/account.go +++ b/x/accounts/defaults/base/account.go @@ -37,7 +37,6 @@ func NewAccount(name string, handlerMap *signing.HandlerMap) accountstd.AccountC PubKey: collections.NewItem(deps.SchemaBuilder, PubKeyPrefix, "pub_key", codec.CollValue[secp256k1.PubKey](deps.LegacyStateCodec)), Sequence: collections.NewSequence(deps.SchemaBuilder, SequencePrefix, "sequence"), addrCodec: deps.AddressCodec, - hs: deps.HeaderService, signingHandlers: handlerMap, }, nil } diff --git a/x/accounts/go.mod b/x/accounts/go.mod index cdd1d509601e..4efa374c2578 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -143,13 +143,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/accounts/go.sum b/x/accounts/go.sum index 221c87b2767c..ee0266fe8b11 100644 --- a/x/accounts/go.sum +++ b/x/accounts/go.sum @@ -746,8 +746,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -863,12 +863,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/accounts/internal/implementation/api_builder_test.go b/x/accounts/internal/implementation/api_builder_test.go index acad2af651db..ab41ede89983 100644 --- a/x/accounts/internal/implementation/api_builder_test.go +++ b/x/accounts/internal/implementation/api_builder_test.go @@ -10,8 +10,12 @@ import ( func TestRouterDoubleRegistration(t *testing.T) { router := NewExecuteBuilder() - RegisterExecuteHandler(router, func(_ context.Context, req *types.StringValue) (*types.StringValue, error) { return nil, nil }) - RegisterExecuteHandler(router, func(_ context.Context, req *types.StringValue) (*types.StringValue, error) { return nil, nil }) + RegisterExecuteHandler(router, func(_ context.Context, req *types.StringValue) (*types.StringValue, error) { + return nil, nil + }) + RegisterExecuteHandler(router, func(_ context.Context, req *types.StringValue) (*types.StringValue, error) { + return nil, nil + }) _, err := router.makeHandler() require.ErrorContains(t, err, "already registered") diff --git a/x/accounts/internal/implementation/context.go b/x/accounts/internal/implementation/context.go index b47b7843a7c7..4ab8d2d7cc1c 100644 --- a/x/accounts/internal/implementation/context.go +++ b/x/accounts/internal/implementation/context.go @@ -5,8 +5,6 @@ import ( "encoding/binary" "cosmossdk.io/collections" - "cosmossdk.io/core/gas" - "cosmossdk.io/core/header" "cosmossdk.io/core/store" "cosmossdk.io/x/accounts/internal/prefixstore" @@ -137,35 +135,3 @@ func Whoami(ctx context.Context) []byte { // Funds returns the funds associated with the execution context. func Funds(ctx context.Context) sdk.Coins { return getCtx(ctx).funds } - -type headerService struct{ hs header.Service } - -func (h headerService) GetHeaderInfo(ctx context.Context) header.Info { - return h.hs.GetHeaderInfo(getParentContext(ctx)) -} - -var _ gas.Service = (*gasService)(nil) - -type gasService struct{ gs gas.Service } - -func (g gasService) GetGasMeter(ctx context.Context) gas.Meter { - return g.gs.GetGasMeter(getParentContext(ctx)) -} - -func (g gasService) GetBlockGasMeter(ctx context.Context) gas.Meter { - return g.gs.GetBlockGasMeter(getParentContext(ctx)) -} - -func (g gasService) WithGasMeter(ctx context.Context, meter gas.Meter) context.Context { - v := getCtx(ctx) - v.parentContext = g.gs.WithGasMeter(v.parentContext, meter) - return context.WithValue(v.parentContext, contextKey{}, v) -} - -func (g gasService) WithBlockGasMeter(ctx context.Context, meter gas.Meter) context.Context { - v := getCtx(ctx) - v.parentContext = g.gs.WithBlockGasMeter(v.parentContext, meter) - return addCtx(v.parentContext, v) -} - -func getParentContext(ctx context.Context) context.Context { return getCtx(ctx).parentContext } diff --git a/x/accounts/internal/implementation/implementation.go b/x/accounts/internal/implementation/implementation.go index 57bf0f144b1c..cb55359d04a7 100644 --- a/x/accounts/internal/implementation/implementation.go +++ b/x/accounts/internal/implementation/implementation.go @@ -8,8 +8,7 @@ import ( "cosmossdk.io/collections" "cosmossdk.io/core/address" - "cosmossdk.io/core/gas" - "cosmossdk.io/core/header" + "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/codec" ) @@ -18,8 +17,7 @@ import ( type Dependencies struct { SchemaBuilder *collections.SchemaBuilder AddressCodec address.Codec - HeaderService header.Service - GasService gas.Service + Environment appmodule.Environment LegacyStateCodec interface { Marshal(gogoproto.Message) ([]byte, error) Unmarshal([]byte, gogoproto.Message) error @@ -34,8 +32,7 @@ type AccountCreatorFunc = func(deps Dependencies) (string, Account, error) func MakeAccountsMap( cdc codec.BinaryCodec, addressCodec address.Codec, - hs header.Service, - gs gas.Service, + env appmodule.Environment, accounts []AccountCreatorFunc, ) (map[string]Implementation, error) { accountsMap := make(map[string]Implementation, len(accounts)) @@ -44,8 +41,7 @@ func MakeAccountsMap( deps := Dependencies{ SchemaBuilder: stateSchemaBuilder, AddressCodec: addressCodec, - HeaderService: headerService{hs}, - GasService: gasService{gs}, + Environment: env, LegacyStateCodec: cdc, } name, accountInterface, err := makeAccount(deps) diff --git a/x/accounts/keeper.go b/x/accounts/keeper.go index 870bce8760ce..6a4779499819 100644 --- a/x/accounts/keeper.go +++ b/x/accounts/keeper.go @@ -10,6 +10,7 @@ import ( gogoproto "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/runtime/protoiface" "cosmossdk.io/collections" "cosmossdk.io/core/address" @@ -56,8 +57,8 @@ type SignerProvider interface { } type InterfaceRegistry interface { - RegisterInterface(name string, iface any, impls ...gogoproto.Message) - RegisterImplementations(iface any, impls ...gogoproto.Message) + RegisterInterface(name string, iface any, impls ...protoiface.MessageV1) + RegisterImplementations(iface any, impls ...protoiface.MessageV1) } func NewKeeper( @@ -90,7 +91,7 @@ func NewKeeper( return Keeper{}, err } keeper.Schema = schema - keeper.accounts, err = implementation.MakeAccountsMap(cdc, keeper.addressCodec, env.HeaderService, env.GasService, accounts) + keeper.accounts, err = implementation.MakeAccountsMap(cdc, keeper.addressCodec, env, accounts) if err != nil { return Keeper{}, err } diff --git a/x/accounts/module.go b/x/accounts/module.go index 9d5288cf31ea..b60ebafb57fa 100644 --- a/x/accounts/module.go +++ b/x/accounts/module.go @@ -8,12 +8,12 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/accounts/cli" v1 "cosmossdk.io/x/accounts/v1" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -52,7 +52,7 @@ func (m AppModule) IsAppModule() {} func (AppModule) Name() string { return ModuleName } -func (m AppModule) RegisterInterfaces(registry types.InterfaceRegistry) { +func (m AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { msgservice.RegisterMsgServiceDesc(registry, v1.MsgServiceDesc()) } diff --git a/x/accounts/testing/account_abstraction/minimal.go b/x/accounts/testing/account_abstraction/minimal.go index 3f0e69a43ede..30775e984261 100644 --- a/x/accounts/testing/account_abstraction/minimal.go +++ b/x/accounts/testing/account_abstraction/minimal.go @@ -6,6 +6,8 @@ import ( "cosmossdk.io/api/cosmos/crypto/secp256k1" "cosmossdk.io/collections" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/event" "cosmossdk.io/x/accounts/accountstd" account_abstractionv1 "cosmossdk.io/x/accounts/interfaces/account_abstraction/v1" rotationv1 "cosmossdk.io/x/accounts/testing/rotation/v1" @@ -24,6 +26,7 @@ func NewMinimalAbstractedAccount(d accountstd.Dependencies) (MinimalAbstractedAc return MinimalAbstractedAccount{ PubKey: collections.NewItem(d.SchemaBuilder, PubKeyPrefix, "pubkey", codec.CollValueV2[secp256k1.PubKey]()), Sequence: collections.NewSequence(d.SchemaBuilder, SequencePrefix, "sequence"), + Env: d.Environment, }, nil } @@ -32,6 +35,7 @@ func NewMinimalAbstractedAccount(d accountstd.Dependencies) (MinimalAbstractedAc type MinimalAbstractedAccount struct { PubKey collections.Item[*secp256k1.PubKey] Sequence collections.Sequence + Env appmodule.Environment } func (a MinimalAbstractedAccount) Init(ctx context.Context, msg *rotationv1.MsgInit) (*rotationv1.MsgInitResponse, error) { @@ -45,6 +49,11 @@ func (a MinimalAbstractedAccount) RotatePubKey(ctx context.Context, msg *rotatio // Authenticate authenticates the account, auth always passess. func (a MinimalAbstractedAccount) Authenticate(ctx context.Context, msg *account_abstractionv1.MsgAuthenticate) (*account_abstractionv1.MsgAuthenticateResponse, error) { _, err := a.Sequence.Next(ctx) + if err != nil { + return nil, err + } + err = a.Env.EventService.EventManager(ctx).EmitKV("account_bundler_authentication", event.NewAttribute("address", msg.Bundler)) + return &account_abstractionv1.MsgAuthenticateResponse{}, err } diff --git a/x/accounts/testing/counter/counter.go b/x/accounts/testing/counter/counter.go index 8bcdf38262c6..0e1ab9d78334 100644 --- a/x/accounts/testing/counter/counter.go +++ b/x/accounts/testing/counter/counter.go @@ -29,9 +29,7 @@ func NewAccount(d accountstd.Dependencies) (Account, error) { Owner: collections.NewItem(d.SchemaBuilder, OwnerPrefix, "owner", collections.BytesValue), Counter: collections.NewItem(d.SchemaBuilder, CounterPrefix, "counter", collections.Uint64Value), TestStateCodec: collections.NewItem(d.SchemaBuilder, TestStateCodecPrefix, "test_state_codec", codec.CollValue[counterv1.MsgTestDependencies](d.LegacyStateCodec)), - hs: d.HeaderService, addressCodec: d.AddressCodec, - gs: d.GasService, }, nil } diff --git a/x/accounts/utils_test.go b/x/accounts/utils_test.go index 5ee67365b6ec..97ee8828614f 100644 --- a/x/accounts/utils_test.go +++ b/x/accounts/utils_test.go @@ -43,9 +43,9 @@ var _ InterfaceRegistry = (*interfaceRegistry)(nil) type interfaceRegistry struct{} -func (i interfaceRegistry) RegisterInterface(string, any, ...gogoproto.Message) {} +func (i interfaceRegistry) RegisterInterface(string, any, ...protoiface.MessageV1) {} -func (i interfaceRegistry) RegisterImplementations(any, ...gogoproto.Message) {} +func (i interfaceRegistry) RegisterImplementations(any, ...protoiface.MessageV1) {} func newKeeper(t *testing.T, accounts ...implementation.AccountCreatorFunc) (Keeper, context.Context) { t.Helper() diff --git a/x/auth/CHANGELOG.md b/x/auth/CHANGELOG.md index 33c4017bf38e..585075a9d39e 100644 --- a/x/auth/CHANGELOG.md +++ b/x/auth/CHANGELOG.md @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* [#19447](https://github.com/cosmos/cosmos-sdk/pull/19447) Address and validator address codecs are now arguments of `NewTxConfig`. `NewDefaultSigningOptions` has been replaced with `NewSigningOptions` which takes address and validator address codecs as arguments. * [#17985](https://github.com/cosmos/cosmos-sdk/pull/17985) Remove `StdTxConfig` * [#19161](https://github.com/cosmos/cosmos-sdk/pull/19161) Remove `simulate` from `SetGasMeter` * [#19363](https://github.com/cosmos/cosmos-sdk/pull/19363) Remove `IterateAccounts` and `GetAllAccounts` methods from the AccountKeeper interface and Keeper. diff --git a/x/auth/ante/feegrant_test.go b/x/auth/ante/feegrant_test.go index 3a0f60c1f690..80f858b042f6 100644 --- a/x/auth/ante/feegrant_test.go +++ b/x/auth/ante/feegrant_test.go @@ -145,7 +145,9 @@ func TestDeductFeesNoDelegation(t *testing.T) { tc := stc // to make scopelint happy t.Run(name, func(t *testing.T) { suite := SetupTestSuite(t, false) - protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(suite.encCfg.InterfaceRegistry), tx.DefaultSignModes) + cdc := codec.NewProtoCodec(suite.encCfg.InterfaceRegistry) + signingCtx := suite.encCfg.InterfaceRegistry.SigningContext() + protoTxCfg := tx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes) // this just tests our handler dfd := ante.NewDeductFeeDecorator(suite.accountKeeper, suite.bankKeeper, suite.feeGrantKeeper, nil) feeAnteHandler := sdk.ChainAnteDecorators(dfd) diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index d157866e0d10..ab21482b48c8 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -15,6 +15,7 @@ import ( authtx "cosmossdk.io/x/auth/tx" txmodule "cosmossdk.io/x/auth/tx/config" "cosmossdk.io/x/auth/types" + txsigning "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -99,13 +100,18 @@ func TestSigVerification(t *testing.T) { enabledSignModes := []signing.SignMode{signing.SignMode_SIGN_MODE_DIRECT, signing.SignMode_SIGN_MODE_TEXTUAL, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON} // Since TEXTUAL is not enabled by default, we create a custom TxConfig // here which includes it. + cdc := codec.NewProtoCodec(suite.encCfg.InterfaceRegistry) txConfigOpts := authtx.ConfigOptions{ TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(suite.clientCtx), EnabledSignModes: enabledSignModes, + SigningOptions: &txsigning.Options{ + AddressCodec: cdc.InterfaceRegistry().SigningContext().AddressCodec(), + ValidatorAddressCodec: cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(), + }, } var err error suite.clientCtx.TxConfig, err = authtx.NewTxConfigWithOptions( - codec.NewProtoCodec(suite.encCfg.InterfaceRegistry), + cdc, txConfigOpts, ) require.NoError(t, err) @@ -138,6 +144,10 @@ func TestSigVerification(t *testing.T) { txConfigOpts = authtx.ConfigOptions{ TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(suite.txBankKeeper), EnabledSignModes: enabledSignModes, + SigningOptions: &txsigning.Options{ + AddressCodec: cdc.InterfaceRegistry().SigningContext().AddressCodec(), + ValidatorAddressCodec: cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(), + }, } anteTxConfig, err := authtx.NewTxConfigWithOptions( codec.NewProtoCodec(suite.encCfg.InterfaceRegistry), @@ -303,13 +313,18 @@ func TestAnteHandlerChecks(t *testing.T) { enabledSignModes := []signing.SignMode{signing.SignMode_SIGN_MODE_DIRECT, signing.SignMode_SIGN_MODE_TEXTUAL, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON} // Since TEXTUAL is not enabled by default, we create a custom TxConfig // here which includes it. + cdc := codec.NewProtoCodec(suite.encCfg.InterfaceRegistry) txConfigOpts := authtx.ConfigOptions{ TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(suite.clientCtx), EnabledSignModes: enabledSignModes, + SigningOptions: &txsigning.Options{ + AddressCodec: cdc.InterfaceRegistry().SigningContext().AddressCodec(), + ValidatorAddressCodec: cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(), + }, } anteTxConfig, err := authtx.NewTxConfigWithOptions( - codec.NewProtoCodec(suite.encCfg.InterfaceRegistry), + cdc, txConfigOpts, ) require.NoError(t, err) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index c49cebdcdf5e..1814e94f2b29 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -25,6 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -67,7 +68,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { key := storetypes.NewKVStoreKey(types.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1) - suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) maccPerms := map[string][]string{ "fee_collector": nil, diff --git a/x/auth/client/cli/encode_test.go b/x/auth/client/cli/encode_test.go index d5b116ca733c..1234de797ac9 100644 --- a/x/auth/client/cli/encode_test.go +++ b/x/auth/client/cli/encode_test.go @@ -11,13 +11,14 @@ import ( "cosmossdk.io/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/client" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func TestGetCommandEncode(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) txConfig := encodingConfig.TxConfig cdc := encodingConfig.Codec @@ -47,7 +48,7 @@ func TestGetCommandEncode(t *testing.T) { } func TestGetCommandDecode(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) txConfig := encodingConfig.TxConfig cdc := encodingConfig.Codec diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index 130e8af7e564..61ab3349a094 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -38,7 +39,7 @@ func TestParseQueryResponse(t *testing.T) { func TestReadTxFromFile(t *testing.T) { t.Parallel() - encodingConfig := moduletestutil.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) interfaceRegistry := encodingConfig.InterfaceRegistry txConfig := encodingConfig.TxConfig @@ -74,7 +75,7 @@ func TestReadTxFromFile(t *testing.T) { func TestReadTxsFromFile(t *testing.T) { t.Parallel() - encodingConfig := moduletestutil.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) interfaceRegistry := encodingConfig.InterfaceRegistry txConfig := encodingConfig.TxConfig @@ -138,7 +139,7 @@ func TestReadTxsFromFile(t *testing.T) { func TestBatchScanner_Scan(t *testing.T) { t.Parallel() - encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) txConfig := encodingConfig.TxConfig clientCtx := client.Context{} diff --git a/x/auth/go.mod b/x/auth/go.mod index 333c2616d5e4..4a61bbc152a5 100644 --- a/x/auth/go.mod +++ b/x/auth/go.mod @@ -149,12 +149,12 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/auth/go.sum b/x/auth/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/auth/go.sum +++ b/x/auth/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/auth/keeper/deterministic_test.go b/x/auth/keeper/deterministic_test.go index 95bbef98b4ee..61baa01c2835 100644 --- a/x/auth/keeper/deterministic_test.go +++ b/x/auth/keeper/deterministic_test.go @@ -19,6 +19,7 @@ import ( "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/baseapp" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -52,7 +53,7 @@ func TestDeterministicTestSuite(t *testing.T) { } func (suite *DeterministicTestSuite) SetupTest() { - suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) suite.Require() key := storetypes.NewKVStoreKey(types.StoreKey) diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 8ed4c8d00de2..02a25bb6ec83 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -15,6 +15,7 @@ import ( "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/baseapp" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/runtime" @@ -46,7 +47,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) diff --git a/x/auth/module.go b/x/auth/module.go index a0fb08b42b19..2a94ab4bad53 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -9,13 +9,13 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/simulation" "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -71,7 +71,7 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } // RegisterInterfaces registers interfaces and implementations of the auth module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/auth/signing/adapter.go b/x/auth/signing/adapter.go index bb0def2f230f..42b1b82fdc48 100644 --- a/x/auth/signing/adapter.go +++ b/x/auth/signing/adapter.go @@ -41,20 +41,24 @@ func GetSignBytesAdapter( return nil, err } - anyPk, err := codectypes.NewAnyWithValue(signerData.PubKey) - if err != nil { - return nil, err - } + var pubKey *anypb.Any + if signerData.PubKey != nil { + anyPk, err := codectypes.NewAnyWithValue(signerData.PubKey) + if err != nil { + return nil, err + } + pubKey = &anypb.Any{ + TypeUrl: anyPk.TypeUrl, + Value: anyPk.Value, + } + } txSignerData := txsigning.SignerData{ ChainID: signerData.ChainID, AccountNumber: signerData.AccountNumber, Sequence: signerData.Sequence, Address: signerData.Address, - PubKey: &anypb.Any{ - TypeUrl: anyPk.TypeUrl, - Value: anyPk.Value, - }, + PubKey: pubKey, } // Generate the bytes to be signed. return handlerMap.GetSignBytes(ctx, txSignMode, txSignerData, txData) diff --git a/x/auth/signing/adapter_test.go b/x/auth/signing/adapter_test.go new file mode 100644 index 000000000000..432a0194ba77 --- /dev/null +++ b/x/auth/signing/adapter_test.go @@ -0,0 +1,35 @@ +package signing_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + authsign "cosmossdk.io/x/auth/signing" + + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/types/tx/signing" +) + +func TestGetSignBytesAdapterNoPublicKey(t *testing.T) { + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) + txConfig := encodingConfig.TxConfig + _, _, addr := testdata.KeyTestPubAddr() + signerData := authsign.SignerData{ + Address: addr.String(), + ChainID: "test-chain", + AccountNumber: 11, + Sequence: 15, + } + w := txConfig.NewTxBuilder() + _, err := authsign.GetSignBytesAdapter( + context.Background(), + txConfig.SignModeHandler(), + signing.SignMode_SIGN_MODE_DIRECT, + signerData, + w.GetTx()) + require.NoError(t, err) +} diff --git a/x/auth/tx/aux_test.go b/x/auth/tx/aux_test.go index 7321464f054c..4d1ae10b3271 100644 --- a/x/auth/tx/aux_test.go +++ b/x/auth/tx/aux_test.go @@ -9,6 +9,7 @@ import ( authsigning "cosmossdk.io/x/auth/signing" clienttx "github.com/cosmos/cosmos-sdk/client/tx" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" _ "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" @@ -39,7 +40,7 @@ var ( // client.TxBuilder created by the fee payer. func TestBuilderWithAux(t *testing.T) { t.Skip("restore when we re-enable aux on the TX builder") - encodingConfig := moduletestutil.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) interfaceRegistry := encodingConfig.InterfaceRegistry txConfig := encodingConfig.TxConfig diff --git a/x/auth/tx/config.go b/x/auth/tx/config.go index e796902ee910..90fbb8e39f27 100644 --- a/x/auth/tx/config.go +++ b/x/auth/tx/config.go @@ -1,10 +1,10 @@ package tx import ( + "errors" "fmt" "cosmossdk.io/core/address" - authcodec "cosmossdk.io/x/auth/codec" txdecode "cosmossdk.io/x/tx/decode" txsigning "cosmossdk.io/x/tx/signing" "cosmossdk.io/x/tx/signing/aminojson" @@ -76,12 +76,15 @@ var DefaultSignModes = []signingtypes.SignMode{ // We prefer to use depinject to provide client.TxConfig, but we permit this constructor usage. Within the SDK, // this constructor is primarily used in tests, but also sees usage in app chains like: // https://github.com/evmos/evmos/blob/719363fbb92ff3ea9649694bd088e4c6fe9c195f/encoding/config.go#L37 -func NewTxConfig(protoCodec codec.Codec, enabledSignModes []signingtypes.SignMode, - customSignModes ...txsigning.SignModeHandler, +func NewTxConfig(protoCodec codec.Codec, addressCodec, validatorAddressCodec address.Codec, enabledSignModes []signingtypes.SignMode, customSignModes ...txsigning.SignModeHandler, ) client.TxConfig { txConfig, err := NewTxConfigWithOptions(protoCodec, ConfigOptions{ EnabledSignModes: enabledSignModes, CustomSignModes: customSignModes, + SigningOptions: &txsigning.Options{ + AddressCodec: addressCodec, + ValidatorAddressCodec: validatorAddressCodec, + }, }) if err != nil { panic(err) @@ -89,13 +92,12 @@ func NewTxConfig(protoCodec codec.Codec, enabledSignModes []signingtypes.SignMod return txConfig } -// NewDefaultSigningOptions returns the sdk default signing options used by x/tx. This includes account and +// NewSigningOptions returns signing options used by x/tx. This includes account and // validator address prefix enabled codecs. -func NewDefaultSigningOptions() (*txsigning.Options, error) { - sdkConfig := sdk.GetConfig() +func NewSigningOptions(addressCodec, validatorAddressCodec address.Codec) (*txsigning.Options, error) { return &txsigning.Options{ - AddressCodec: authcodec.NewBech32Codec(sdkConfig.GetBech32AccountAddrPrefix()), - ValidatorAddressCodec: authcodec.NewBech32Codec(sdkConfig.GetBech32ValidatorAddrPrefix()), + AddressCodec: addressCodec, + ValidatorAddressCodec: validatorAddressCodec, }, nil } @@ -105,10 +107,7 @@ func NewDefaultSigningOptions() (*txsigning.Options, error) { func NewSigningHandlerMap(configOpts ConfigOptions) (*txsigning.HandlerMap, error) { var err error if configOpts.SigningOptions == nil { - configOpts.SigningOptions, err = NewDefaultSigningOptions() - if err != nil { - return nil, err - } + return nil, errors.New("signing options not provided") } if configOpts.SigningContext == nil { configOpts.SigningContext, err = txsigning.NewContext(*configOpts.SigningOptions) @@ -179,10 +178,7 @@ func NewTxConfigWithOptions(protoCodec codec.Codec, configOptions ConfigOptions) var err error if configOptions.SigningContext == nil { if configOptions.SigningOptions == nil { - configOptions.SigningOptions, err = NewDefaultSigningOptions() - if err != nil { - return nil, err - } + return nil, errors.New("signing options not provided") } if configOptions.SigningOptions.FileResolver == nil { configOptions.SigningOptions.FileResolver = protoCodec.InterfaceRegistry() diff --git a/x/auth/tx/config_test.go b/x/auth/tx/config_test.go index 10cc68e94515..888bf0eda5d0 100644 --- a/x/auth/tx/config_test.go +++ b/x/auth/tx/config_test.go @@ -9,10 +9,10 @@ import ( _ "cosmossdk.io/api/cosmos/crypto/secp256k1" "cosmossdk.io/x/auth/tx" txtestutil "cosmossdk.io/x/auth/tx/testutil" + "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/testutil" - "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -23,13 +23,17 @@ func TestGenerator(t *testing.T) { std.RegisterInterfaces(interfaceRegistry) interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &testdata.TestMsg{}) protoCodec := codec.NewProtoCodec(interfaceRegistry) - suite.Run(t, txtestutil.NewTxConfigTestSuite(tx.NewTxConfig(protoCodec, tx.DefaultSignModes))) + signingCtx := protoCodec.InterfaceRegistry().SigningContext() + suite.Run(t, txtestutil.NewTxConfigTestSuite(tx.NewTxConfig(protoCodec, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), tx.DefaultSignModes))) } func TestConfigOptions(t *testing.T) { - interfaceRegistry := types.NewInterfaceRegistry() + interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry() protoCodec := codec.NewProtoCodec(interfaceRegistry) - configOptions := tx.ConfigOptions{} + configOptions := tx.ConfigOptions{SigningOptions: &signing.Options{ + AddressCodec: interfaceRegistry.SigningContext().AddressCodec(), + ValidatorAddressCodec: interfaceRegistry.SigningContext().ValidatorAddressCodec(), + }} txConfig, err := tx.NewTxConfigWithOptions(protoCodec, configOptions) require.NoError(t, err) require.NotNil(t, txConfig) diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 146ef5d2bff2..5e6a29986a97 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -1,11 +1,11 @@ package types import ( + "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -28,7 +28,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterfaces associates protoName with AccountI interface // and creates a registry of it's concrete implementations -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterInterface( "cosmos.auth.v1beta1.AccountI", (*AccountI)(nil), diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 8a3bf204bad2..c8be155e8ffa 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/x/auth" "cosmossdk.io/x/auth/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" @@ -54,7 +55,7 @@ func TestValidateGenesisDuplicateAccounts(t *testing.T) { } func TestGenesisAccountIterator(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) cdc := encodingConfig.Codec acc1 := types.NewBaseAccountWithAddress(sdk.AccAddress(addr1)) diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 23066ae58787..128f1a36ae81 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -2,11 +2,11 @@ package vesting import ( "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -45,7 +45,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterfaces registers the module's interfaces and implementations with // the given interface registry. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 3db83da05211..431b511931c9 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -1,12 +1,12 @@ package types import ( + "cosmossdk.io/core/registry" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/auth/vesting/exported" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -27,7 +27,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterface associates protoName with AccountI and VestingAccount // Interfaces and creates a registry of it's concrete implementations -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterInterface( "cosmos.vesting.v1beta1.VestingAccount", (*exported.VestingAccount)(nil), diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index ba1b289f2474..83273f32bbad 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/x/auth/vesting" "cosmossdk.io/x/auth/vesting/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -38,7 +39,7 @@ type VestingAccountTestSuite struct { } func (s *VestingAccountTestSuite) SetupTest() { - encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, vesting.AppModule{}) key := storetypes.NewKVStoreKey(authtypes.StoreKey) env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) diff --git a/x/authz/client/cli/tx_test.go b/x/authz/client/cli/tx_test.go index 2b7df03f8052..d4b2b5f0aa9f 100644 --- a/x/authz/client/cli/tx_test.go +++ b/x/authz/client/cli/tx_test.go @@ -23,6 +23,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -51,7 +52,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig(bank.AppModule{}, authz.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, bank.AppModule{}, authz.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. diff --git a/x/authz/codec.go b/x/authz/codec.go index 2a6432512957..2d1d095f4e7e 100644 --- a/x/authz/codec.go +++ b/x/authz/codec.go @@ -1,12 +1,12 @@ package authz import ( + "cosmossdk.io/core/registry" bank "cosmossdk.io/x/bank/types" staking "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - types "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -23,7 +23,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the interface registry -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgGrant{}, &MsgRevoke{}, diff --git a/x/authz/go.mod b/x/authz/go.mod index 399282648ac1..a42315213789 100644 --- a/x/authz/go.mod +++ b/x/authz/go.mod @@ -146,13 +146,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/authz/go.sum b/x/authz/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/authz/go.sum +++ b/x/authz/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 8ae9811c019c..78c15797d297 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -48,7 +49,7 @@ func (suite *GenesisTestSuite) SetupTest() { testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) - suite.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{}) // gomock initializations ctrl := gomock.NewController(suite.T()) diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 444787fcdf7d..b0c77f497dae 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -51,7 +52,7 @@ func (s *TestSuite) SetupTest() { storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now().Round(0).UTC()}) - s.encCfg = moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) + s.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{}) s.baseApp = baseapp.NewBaseApp( "authz", diff --git a/x/authz/migrations/v2/store_test.go b/x/authz/migrations/v2/store_test.go index 00cdc53071ea..4440ae5b4fbe 100644 --- a/x/authz/migrations/v2/store_test.go +++ b/x/authz/migrations/v2/store_test.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/x/bank" banktypes "cosmossdk.io/x/bank/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/runtime" @@ -25,7 +26,7 @@ import ( ) func TestMigration(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}, bank.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{}, bank.AppModule{}) cdc := encodingConfig.Codec authzKey := storetypes.NewKVStoreKey("authz") diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index f45f7e004974..ba2ae1914a85 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -30,7 +31,7 @@ func TestExpiredGrantsQueue(t *testing.T) { key := storetypes.NewKVStoreKey(keeper.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{}) ctx := testCtx.Ctx baseApp := baseapp.NewBaseApp( diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 31b7a35a1382..d11db1bcad8f 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/errors" "cosmossdk.io/x/authz" "cosmossdk.io/x/authz/client/cli" @@ -26,12 +27,12 @@ import ( const ConsensusVersion = 2 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -91,7 +92,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the authz module's interface types -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { authz.RegisterInterfaces(registry) } diff --git a/x/authz/simulation/decoder_test.go b/x/authz/simulation/decoder_test.go index 5e9697443908..dbeee176732a 100644 --- a/x/authz/simulation/decoder_test.go +++ b/x/authz/simulation/decoder_test.go @@ -13,13 +13,14 @@ import ( "cosmossdk.io/x/authz/simulation" banktypes "cosmossdk.io/x/bank/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func TestDecodeStore(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{}) banktypes.RegisterInterfaces(encCfg.InterfaceRegistry) dec := simulation.NewDecodeStore(encCfg.Codec) diff --git a/x/authz/simulation/genesis_test.go b/x/authz/simulation/genesis_test.go index 19c0508de678..6578c21644f3 100644 --- a/x/authz/simulation/genesis_test.go +++ b/x/authz/simulation/genesis_test.go @@ -13,13 +13,14 @@ import ( "cosmossdk.io/x/authz/simulation" banktypes "cosmossdk.io/x/bank/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/types/module" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) func TestRandomizedGenState(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, authzmodule.AppModule{}) banktypes.RegisterInterfaces(encCfg.InterfaceRegistry) s := rand.NewSource(1) diff --git a/x/bank/client/cli/tx_test.go b/x/bank/client/cli/tx_test.go index 17a73e5f6725..e73d59bb32f2 100644 --- a/x/bank/client/cli/tx_test.go +++ b/x/bank/client/cli/tx_test.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keyring" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/cosmos/cosmos-sdk/testutil" @@ -37,7 +38,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig(bank.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, bank.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/x/bank/go.mod b/x/bank/go.mod index e95cc944132f..66b28c4aa40e 100644 --- a/x/bank/go.mod +++ b/x/bank/go.mod @@ -145,13 +145,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/bank/go.sum b/x/bank/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/bank/go.sum +++ b/x/bank/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/bank/keeper/collections_test.go b/x/bank/keeper/collections_test.go index b372f4edc84b..8e77b664f395 100644 --- a/x/bank/keeper/collections_test.go +++ b/x/bank/keeper/collections_test.go @@ -18,6 +18,7 @@ import ( banktypes "cosmossdk.io/x/bank/types" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -28,7 +29,7 @@ func TestBankStateCompatibility(t *testing.T) { key := storetypes.NewKVStoreKey(banktypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) - encCfg := moduletestutil.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 7d5e90ccac4b..e44423e352ff 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -27,6 +27,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -129,7 +130,7 @@ func (suite *KeeperTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(banktypes.StoreKey) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) - encCfg := moduletestutil.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) @@ -303,7 +304,7 @@ func (suite *KeeperTestSuite) TestGetAuthority() { NewKeeperWithAuthority := func(authority string) keeper.BaseKeeper { return keeper.NewBaseKeeper( env, - moduletestutil.MakeTestEncodingConfig().Codec, + moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec, suite.authKeeper, nil, authority, diff --git a/x/bank/module.go b/x/bank/module.go index f233d0115b4c..184996dd82e4 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -11,6 +11,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/bank/client/cli" "cosmossdk.io/x/bank/keeper" "cosmossdk.io/x/bank/simulation" @@ -18,7 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -29,13 +29,13 @@ import ( const ConsensusVersion = 4 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} - _ module.HasInvariants = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasInvariants = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasServices = AppModule{} @@ -82,7 +82,7 @@ func (AppModule) GetTxCmd() *cobra.Command { } // RegisterInterfaces registers interfaces and implementations of the bank module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index 24730aa8a4ef..978d7d1baae7 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -1,9 +1,10 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -20,7 +21,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params", nil) } -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, &MsgMultiSend{}, diff --git a/x/circuit/ante/circuit_test.go b/x/circuit/ante/circuit_test.go index 6c1e8693f135..9bf328a3466c 100644 --- a/x/circuit/ante/circuit_test.go +++ b/x/circuit/ante/circuit_test.go @@ -12,6 +12,7 @@ import ( cbtypes "cosmossdk.io/x/circuit/types" "github.com/cosmos/cosmos-sdk/client" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -37,7 +38,7 @@ func (m MockCircuitBreaker) IsAllowed(ctx context.Context, typeURL string) (bool func initFixture(t *testing.T) *fixture { t.Helper() mockStoreKey := storetypes.NewKVStoreKey("test") - encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}) mockclientCtx := client.Context{}. WithTxConfig(encCfg.TxConfig) diff --git a/x/circuit/go.mod b/x/circuit/go.mod index b504ba0fc3c2..87558974b1df 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -145,13 +145,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/circuit/go.sum b/x/circuit/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/circuit/go.sum +++ b/x/circuit/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/circuit/keeper/genesis_test.go b/x/circuit/keeper/genesis_test.go index 16f8362ba239..cc4e3b6cbaad 100644 --- a/x/circuit/keeper/genesis_test.go +++ b/x/circuit/keeper/genesis_test.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -37,7 +38,7 @@ func TestGenesisTestSuite(t *testing.T) { func (s *GenesisTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(types.ModuleName) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(circuit.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, circuit.AppModule{}) sdkCtx := testCtx.Ctx s.ctx = sdkCtx diff --git a/x/circuit/keeper/keeper_test.go b/x/circuit/keeper/keeper_test.go index 29464b66b72f..38ce34b1e14a 100644 --- a/x/circuit/keeper/keeper_test.go +++ b/x/circuit/keeper/keeper_test.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/x/circuit/types" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -40,7 +41,7 @@ type fixture struct { func initFixture(t *testing.T) *fixture { t.Helper() - encCfg := moduletestutil.MakeTestEncodingConfig(circuit.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, circuit.AppModule{}) ac := addresscodec.NewBech32Codec("cosmos") mockStoreKey := storetypes.NewKVStoreKey("test") diff --git a/x/circuit/module.go b/x/circuit/module.go index b52c1443cbb5..9468ce0c9f68 100644 --- a/x/circuit/module.go +++ b/x/circuit/module.go @@ -10,12 +10,12 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/circuit/keeper" "cosmossdk.io/x/circuit/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/telemetry" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -24,10 +24,10 @@ import ( const ConsensusVersion = 1 var ( - _ module.HasName = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasServices = AppModule{} @@ -53,7 +53,7 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } // RegisterInterfaces registers interfaces and implementations of the circuit module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/circuit/types/codec.go b/x/circuit/types/codec.go index 775eb1aee1c5..41bab1a4d89d 100644 --- a/x/circuit/types/codec.go +++ b/x/circuit/types/codec.go @@ -1,13 +1,14 @@ package types import ( - types "github.com/cosmos/cosmos-sdk/codec/types" + "cosmossdk.io/core/registry" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgAuthorizeCircuitBreaker{}, &MsgResetCircuitBreaker{}, diff --git a/x/consensus/keeper/keeper_test.go b/x/consensus/keeper/keeper_test.go index 3ab63dc3cf61..64edfe1018f4 100644 --- a/x/consensus/keeper/keeper_test.go +++ b/x/consensus/keeper/keeper_test.go @@ -12,6 +12,7 @@ import ( authtypes "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/baseapp" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,7 +33,7 @@ func (s *KeeperTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(consensusparamkeeper.StoreKey) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx - encCfg := moduletestutil.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) keeper := consensusparamkeeper.NewKeeper(encCfg.Codec, env, authtypes.NewModuleAddress("gov").String()) diff --git a/x/consensus/module.go b/x/consensus/module.go index 6ca759424673..107ac6431b3c 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -7,10 +7,10 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/consensus/keeper" "github.com/cosmos/cosmos-sdk/x/consensus/types" @@ -20,10 +20,10 @@ import ( const ConsensusVersion = 1 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -61,7 +61,7 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } // RegisterInterfaces registers interfaces and implementations of the bank module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/consensus/types/codec.go b/x/consensus/types/codec.go index 048d9a427760..f9fa0a8f2a31 100644 --- a/x/consensus/types/codec.go +++ b/x/consensus/types/codec.go @@ -1,14 +1,15 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgUpdateParams{}, diff --git a/x/counter/module.go b/x/counter/module.go index 89a4dda11f21..5f4ea4312498 100644 --- a/x/counter/module.go +++ b/x/counter/module.go @@ -4,16 +4,16 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/counter/keeper" "github.com/cosmos/cosmos-sdk/x/counter/types" ) var ( - _ module.HasName = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} + _ module.HasName = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -47,6 +47,6 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } func (AppModule) Name() string { return types.ModuleName } // RegisterInterfaces registers interfaces and implementations of the bank module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/counter/types/codec.go b/x/counter/types/codec.go index 36f13df3b9da..8776f0ff0dc3 100644 --- a/x/counter/types/codec.go +++ b/x/counter/types/codec.go @@ -1,12 +1,13 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/types" + "cosmossdk.io/core/registry" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgIncreaseCounter{}, diff --git a/x/crisis/keeper/genesis_test.go b/x/crisis/keeper/genesis_test.go index d111beebafe0..a2b392c3a6a0 100644 --- a/x/crisis/keeper/genesis_test.go +++ b/x/crisis/keeper/genesis_test.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -37,7 +38,7 @@ func (s *GenesisTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{}) // gomock initializations ctrl := gomock.NewController(s.T()) diff --git a/x/crisis/keeper/keeper_test.go b/x/crisis/keeper/keeper_test.go index 4a9237d3e92f..84910f934568 100644 --- a/x/crisis/keeper/keeper_test.go +++ b/x/crisis/keeper/keeper_test.go @@ -9,6 +9,7 @@ import ( storetypes "cosmossdk.io/store/types" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,7 +27,7 @@ func TestLogger(t *testing.T) { key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{}) keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", "", addresscodec.NewBech32Codec("cosmos")) require.Equal(t, @@ -40,7 +41,7 @@ func TestInvariants(t *testing.T) { key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) - encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{}) keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", "", addresscodec.NewBech32Codec("cosmos")) require.Equal(t, keeper.InvCheckPeriod(), uint(5)) @@ -57,7 +58,7 @@ func TestAssertInvariants(t *testing.T) { key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{}) keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", "", addresscodec.NewBech32Codec("cosmos")) keeper.RegisterRoute("testModule", "testRoute1", func(sdk.Context) (string, bool) { return "", false }) diff --git a/x/crisis/keeper/msg_server_test.go b/x/crisis/keeper/msg_server_test.go index b86fbf724528..ea60b9ac9fe8 100644 --- a/x/crisis/keeper/msg_server_test.go +++ b/x/crisis/keeper/msg_server_test.go @@ -10,6 +10,7 @@ import ( storetypes "cosmossdk.io/store/types" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -37,7 +38,7 @@ func (s *KeeperTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{}) keeper := keeper.NewKeeper(encCfg.Codec, storeService, 5, supplyKeeper, "", sdk.AccAddress([]byte("addr1_______________")).String(), addresscodec.NewBech32Codec("cosmos")) s.ctx = testCtx.Ctx @@ -51,7 +52,7 @@ func (s *KeeperTestSuite) TestMsgVerifyInvariant() { err := s.keeper.ConstantFee.Set(s.ctx, constantFee) s.Require().NoError(err) - encCfg := moduletestutil.MakeTestEncodingConfig(crisis.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, crisis.AppModule{}) kr := keyring.NewInMemory(encCfg.Codec) testutil.CreateKeyringAccounts(s.T(), kr, 1) diff --git a/x/crisis/module.go b/x/crisis/module.go index 0d6864a0d353..1707baf033d7 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -10,10 +10,10 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/telemetry" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/crisis/keeper" @@ -24,10 +24,10 @@ import ( const ConsensusVersion = 2 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -74,7 +74,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterfaces registers interfaces and implementations of the crisis // module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index 934b0b78b1d7..10f9fa317995 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -1,9 +1,10 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -16,7 +17,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the Interface Registry. -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgVerifyInvariant{}, &MsgUpdateParams{}, diff --git a/x/distribution/go.mod b/x/distribution/go.mod index f813a9090a77..871b95e4c8b1 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -147,13 +147,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/distribution/go.sum b/x/distribution/go.sum index 65b95dc785bc..dfe3daf70777 100644 --- a/x/distribution/go.sum +++ b/x/distribution/go.sum @@ -749,8 +749,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -868,12 +868,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index fbc79d8f514a..d0286dd64131 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -21,6 +21,7 @@ import ( stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -31,7 +32,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -91,7 +92,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -223,7 +224,7 @@ func TestAllocateTokensTruncation(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 09970ed39a55..fc11b8b27d7f 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -19,6 +19,7 @@ import ( stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,7 +30,7 @@ func TestCalculateRewardsBasic(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -132,7 +133,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -238,7 +239,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -365,7 +366,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -465,7 +466,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -543,7 +544,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -662,7 +663,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -804,7 +805,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) @@ -1006,7 +1007,7 @@ func Test100PercentCommissionReward(t *testing.T) { ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(disttypes.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 0a1a64eb53e2..3456466401f9 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -18,6 +18,7 @@ import ( "cosmossdk.io/x/distribution/types" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -38,7 +39,7 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de ctrl := gomock.NewController(t) key := storetypes.NewKVStoreKey(types.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) addrs := simtestutil.CreateIncrementalAccounts(2) diff --git a/x/distribution/migrations/v4/migrate_funds_test.go b/x/distribution/migrations/v4/migrate_funds_test.go index 9ccf4f81ad4f..b8994061cbd8 100644 --- a/x/distribution/migrations/v4/migrate_funds_test.go +++ b/x/distribution/migrations/v4/migrate_funds_test.go @@ -22,6 +22,7 @@ import ( pooltypes "cosmossdk.io/x/protocolpool/types" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,7 +35,7 @@ func TestFundsMigration(t *testing.T) { ) logger := log.NewTestLogger(t) cms := integration.CreateMultiStore(keys, logger) - encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, bank.AppModule{}, distribution.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, distribution.AppModule{}) ctx := sdk.NewContext(cms, true, logger) maccPerms := map[string][]string{ diff --git a/x/distribution/migrations/v4/migrate_test.go b/x/distribution/migrations/v4/migrate_test.go index ed4cc8f79868..6f00fea79e00 100644 --- a/x/distribution/migrations/v4/migrate_test.go +++ b/x/distribution/migrations/v4/migrate_test.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/x/distribution" v4 "cosmossdk.io/x/distribution/migrations/v4" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -20,7 +21,7 @@ import ( ) func TestMigration(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}).Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}).Codec storeKey := storetypes.NewKVStoreKey("distribution") storeService := runtime.NewKVStoreService(storeKey) tKey := storetypes.NewTransientStoreKey("transient_test") diff --git a/x/distribution/module.go b/x/distribution/module.go index c9e351eb93e4..3591b448b9bc 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/distribution/client/cli" "cosmossdk.io/x/distribution/keeper" "cosmossdk.io/x/distribution/simulation" @@ -17,7 +18,6 @@ import ( sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -27,13 +27,13 @@ import ( const ConsensusVersion = 4 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} - _ module.HasInvariants = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasInvariants = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -92,7 +92,7 @@ func (AppModule) GetTxCmd() *cobra.Command { } // RegisterInterfaces implements InterfaceModule -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 71eb414442cb..98a5c91fe317 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/x/distribution/simulation" "cosmossdk.io/x/distribution/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" @@ -24,7 +25,7 @@ var ( ) func TestDecodeDistributionStore(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(distribution.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}) cdc := encodingConfig.Codec dec := simulation.NewDecodeStore(cdc) diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 14181500aae2..3d05793aad8e 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -1,9 +1,10 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -21,7 +22,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/distribution/Params", nil) } -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgWithdrawDelegatorReward{}, diff --git a/x/evidence/go.mod b/x/evidence/go.mod index f7f9b31ad892..bc02677eff8a 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -146,13 +146,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/evidence/go.sum b/x/evidence/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/evidence/go.sum +++ b/x/evidence/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 6513aa581a11..61f9eb0ef4a2 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -84,7 +85,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - encCfg := moduletestutil.MakeTestEncodingConfig(evidence.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, evidence.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) tkey := storetypes.NewTransientStoreKey("evidence_transient_store") @@ -115,7 +116,7 @@ func (suite *KeeperTestSuite) SetupTest() { evidenceKeeper.SetRouter(router) suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1}) - suite.encCfg = moduletestutil.MakeTestEncodingConfig(evidence.AppModule{}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, evidence.AppModule{}) suite.accountKeeper = accountKeeper diff --git a/x/evidence/module.go b/x/evidence/module.go index b09183dbb50b..854ada04705a 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" eviclient "cosmossdk.io/x/evidence/client" "cosmossdk.io/x/evidence/client/cli" "cosmossdk.io/x/evidence/keeper" @@ -18,18 +19,17 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -82,7 +82,7 @@ func (am AppModule) GetTxCmd() *cobra.Command { } // RegisterInterfaces registers the evidence module's interface types -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index 62ffa37cfde4..15bb55568b3e 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -1,11 +1,11 @@ package types import ( + "cosmossdk.io/core/registry" "cosmossdk.io/x/evidence/exported" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -19,7 +19,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitEvidence{}) registry.RegisterInterface( "cosmos.evidence.v1beta1.Evidence", diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index d691821f26ec..ffdbcbb584f2 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -25,6 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" @@ -61,7 +62,7 @@ func TestCLITestSuite(t *testing.T) { func (s *CLITestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - s.encCfg = testutilmod.MakeTestEncodingConfig(module.AppModule{}, gov.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}, gov.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/x/feegrant/codec.go b/x/feegrant/codec.go index 19c2d46f756d..a840e9eaf738 100644 --- a/x/feegrant/codec.go +++ b/x/feegrant/codec.go @@ -1,9 +1,10 @@ package feegrant import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -21,7 +22,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the interface registry -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgGrantAllowance{}, &MsgRevokeAllowance{}, diff --git a/x/feegrant/filtered_fee_test.go b/x/feegrant/filtered_fee_test.go index f5deee9e3d96..d8e3fe81684a 100644 --- a/x/feegrant/filtered_fee_test.go +++ b/x/feegrant/filtered_fee_test.go @@ -14,6 +14,7 @@ import ( "cosmossdk.io/x/feegrant/module" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -22,7 +23,7 @@ import ( func TestFilteredFeeValidAllow(t *testing.T) { key := storetypes.NewKVStoreKey(feegrant.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index 8d5d1158fb68..39b2fc7d7faa 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -151,13 +151,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index b83119ac3074..d7d2e2650014 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -757,8 +757,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -877,12 +877,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/feegrant/grant_test.go b/x/feegrant/grant_test.go index 0dcad40a7379..a333a51e7756 100644 --- a/x/feegrant/grant_test.go +++ b/x/feegrant/grant_test.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/x/feegrant/module" codecaddress "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -21,7 +22,7 @@ func TestGrant(t *testing.T) { addressCodec := codecaddress.NewBech32Codec("cosmos") key := storetypes.NewKVStoreKey(feegrant.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) diff --git a/x/feegrant/keeper/genesis_test.go b/x/feegrant/keeper/genesis_test.go index eb2eff20d467..9d321fe11518 100644 --- a/x/feegrant/keeper/genesis_test.go +++ b/x/feegrant/keeper/genesis_test.go @@ -17,6 +17,7 @@ import ( feegranttestutil "cosmossdk.io/x/feegrant/testutil" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" @@ -43,7 +44,7 @@ func initFixture(t *testing.T) *genesisFixture { t.Helper() key := storetypes.NewKVStoreKey(feegrant.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) ctrl := gomock.NewController(t) accountKeeper := feegranttestutil.NewMockAccountKeeper(ctrl) diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index e68f798d94d2..64e3dd711a54 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -17,6 +17,7 @@ import ( feegranttestutil "cosmossdk.io/x/feegrant/testutil" codecaddress "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -44,7 +45,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.addrs = simtestutil.CreateIncrementalAccounts(20) key := storetypes.NewKVStoreKey(feegrant.StoreKey) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) // setup gomock and initialize some globally expected executions ctrl := gomock.NewController(suite.T()) diff --git a/x/feegrant/migrations/v2/store_test.go b/x/feegrant/migrations/v2/store_test.go index 747e6f74fb6f..2d8bca9b8c9c 100644 --- a/x/feegrant/migrations/v2/store_test.go +++ b/x/feegrant/migrations/v2/store_test.go @@ -15,6 +15,7 @@ import ( "cosmossdk.io/x/feegrant/module" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -23,7 +24,7 @@ import ( ) func TestMigration(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) cdc := encodingConfig.Codec ac := addresscodec.NewBech32Codec("cosmos") diff --git a/x/feegrant/module/abci_test.go b/x/feegrant/module/abci_test.go index 1fb1685aa3c9..9676ae4ffd83 100644 --- a/x/feegrant/module/abci_test.go +++ b/x/feegrant/module/abci_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -28,7 +29,7 @@ import ( func TestFeegrantPruning(t *testing.T) { key := storetypes.NewKVStoreKey(feegrant.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) addrs := simtestutil.CreateIncrementalAccounts(4) granter1 := addrs[0] diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 73ca979403fc..d950ae6a285d 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/errors" "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/client/cli" @@ -22,12 +23,12 @@ import ( ) var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -70,7 +71,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the feegrant module's interface types -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { feegrant.RegisterInterfaces(registry) } diff --git a/x/feegrant/simulation/decoder_test.go b/x/feegrant/simulation/decoder_test.go index 37526f596526..f29fa98977ad 100644 --- a/x/feegrant/simulation/decoder_test.go +++ b/x/feegrant/simulation/decoder_test.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/x/feegrant/simulation" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" @@ -25,7 +26,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) cdc := encodingConfig.Codec dec := simulation.NewDecodeStore(cdc) ac := addresscodec.NewBech32Codec("cosmos") diff --git a/x/feegrant/simulation/genesis_test.go b/x/feegrant/simulation/genesis_test.go index 1271cd5bb001..7bdd29c2e38f 100644 --- a/x/feegrant/simulation/genesis_test.go +++ b/x/feegrant/simulation/genesis_test.go @@ -12,13 +12,14 @@ import ( "cosmossdk.io/x/feegrant/module" "cosmossdk.io/x/feegrant/simulation" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" moduletypes "github.com/cosmos/cosmos-sdk/types/module" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) func TestRandomizedGenState(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) s := rand.NewSource(1) r := rand.New(s) diff --git a/x/genutil/client/cli/genaccount_test.go b/x/genutil/client/cli/genaccount_test.go index 2c5b8a923b33..f269ca7d6537 100644 --- a/x/genutil/client/cli/genaccount_test.go +++ b/x/genutil/client/cli/genaccount_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" @@ -69,7 +70,7 @@ func TestAddGenesisAccountCmd(t *testing.T) { cfg, err := genutiltest.CreateDefaultCometConfig(home) require.NoError(t, err) - appCodec := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}).Codec + appCodec := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}).Codec err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/x/genutil/client/cli/gentx_test.go b/x/genutil/client/cli/gentx_test.go index 76ea4856d592..a4c698398805 100644 --- a/x/genutil/client/cli/gentx_test.go +++ b/x/genutil/client/cli/gentx_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keyring" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -42,7 +43,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig(genutil.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, genutil.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/x/genutil/client/cli/migrate_test.go b/x/genutil/client/cli/migrate_test.go index 55a97fa079d5..7e84b491b132 100644 --- a/x/genutil/client/cli/migrate_test.go +++ b/x/genutil/client/cli/migrate_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -54,7 +55,7 @@ func TestMigrateGenesis(t *testing.T) { genesisFile := testutil.WriteToNewTempFile(t, tc.genesis) jsonOutput, err := clitestutil.ExecTestCLICmd( // the codec does not contain any modules so that genutil does not bring unnecessary dependencies in the test - client.Context{Codec: moduletestutil.MakeTestEncodingConfig().Codec}, + client.Context{Codec: moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec}, cli.MigrateGenesisCmd(cli.MigrationMap), []string{tc.target, genesisFile.Name()}, ) diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index 4ce47e3a3dfd..862e19042364 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -19,6 +19,7 @@ import ( stakingtypes "cosmossdk.io/x/staking/types" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -52,7 +53,7 @@ type GenTxTestSuite struct { } func (suite *GenTxTestSuite) SetupTest() { - suite.encodingConfig = moduletestutil.MakeTestEncodingConfig(genutil.AppModule{}) + suite.encodingConfig = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, genutil.AppModule{}) key := storetypes.NewKVStoreKey("a_Store_Key") tkey := storetypes.NewTransientStoreKey("a_transient_store") suite.ctx = testutil.DefaultContext(key, tkey) diff --git a/x/genutil/module.go b/x/genutil/module.go index bc0472da4d97..118cd2ea3d49 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -9,10 +9,10 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/registry" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -98,4 +98,4 @@ func (am AppModule) GenTxValidator() types.MessageValidator { func (AppModule) ConsensusVersion() uint64 { return 1 } // RegisterInterfaces implements module.AppModule. -func (AppModule) RegisterInterfaces(codectypes.InterfaceRegistry) {} +func (AppModule) RegisterInterfaces(registry.LegacyRegistry) {} diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index 95a6aef6d2d4..bb97c2f00c85 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -13,6 +13,7 @@ import ( stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -48,7 +49,7 @@ func TestValidateGenesisMultipleMessages(t *testing.T) { sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, math.OneInt()) require.NoError(t, err) - txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModule{}, genutil.AppModule{}).TxConfig + txConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, staking.AppModule{}, genutil.AppModule{}).TxConfig txBuilder := txConfig.NewTxBuilder() require.NoError(t, txBuilder.SetMsgs(msg1, msg2)) @@ -64,7 +65,7 @@ func TestValidateGenesisBadMessage(t *testing.T) { msg1 := stakingtypes.NewMsgEditValidator(sdk.ValAddress(pk1.Address()).String(), desc, nil, nil) - txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModule{}, genutil.AppModule{}).TxConfig + txConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, staking.AppModule{}, genutil.AppModule{}).TxConfig txBuilder := txConfig.NewTxBuilder() err := txBuilder.SetMsgs(msg1) require.NoError(t, err) diff --git a/x/gov/CHANGELOG.md b/x/gov/CHANGELOG.md index 0524fd23ff8b..116e87afc38c 100644 --- a/x/gov/CHANGELOG.md +++ b/x/gov/CHANGELOG.md @@ -60,6 +60,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* [#19481](https://github.com/cosmos/cosmos-sdk/pull/19481) Migrate module to use `appmodule.Environment`; `NewKeeper` now takes `appmodule.Environment` instead of a store service and no `baseapp.MessageRouter` anymore. +* [#19481](https://github.com/cosmos/cosmos-sdk/pull/19481) v1beta1 proposal handlers now take a `context.Context` instead of an `sdk.Context`. * [#19592](https://github.com/cosmos/cosmos-sdk/pull/19592) `types.Config` and `types.DefaultConfig` have been moved to the keeper package in order to support the custom tallying function. * [#19349](https://github.com/cosmos/cosmos-sdk/pull/19349) Simplify state management in `x/gov`. Note `k.VotingPeriodProposals` and `k.SetProposal` are no longer needed and have been removed. * [#18532](https://github.com/cosmos/cosmos-sdk/pull/18532) All functions that were taking an expedited bool parameter now take a `ProposalType` parameter instead. diff --git a/x/gov/abci_internal_test.go b/x/gov/abci_internal_test.go deleted file mode 100644 index 1421a81b5cb6..000000000000 --- a/x/gov/abci_internal_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package gov - -import ( - "testing" - - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func failingHandler(_ sdk.Context, _ sdk.Msg) (*sdk.Result, error) { - panic("test-fail") -} - -func okHandler(_ sdk.Context, _ sdk.Msg) (*sdk.Result, error) { - return new(sdk.Result), nil -} - -func TestSafeExecuteHandler(t *testing.T) { - t.Parallel() - - require := require.New(t) - var ctx sdk.Context - - r, err := safeExecuteHandler(ctx, nil, failingHandler) - require.ErrorContains(err, "test-fail") - require.Nil(r) - - r, err = safeExecuteHandler(ctx, nil, okHandler) - require.Nil(err) - require.NotNil(r) -} diff --git a/x/gov/client/cli/tx_test.go b/x/gov/client/cli/tx_test.go index 05ffcb92d806..4cbaf6972d96 100644 --- a/x/gov/client/cli/tx_test.go +++ b/x/gov/client/cli/tx_test.go @@ -22,6 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -43,7 +44,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig(gov.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, gov.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index 3e539f71b4c5..5c0aed3ac7fa 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -15,6 +15,7 @@ import ( v1 "cosmossdk.io/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/client" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) @@ -54,7 +55,7 @@ func (mock TxSearchMock) Block(ctx context.Context, height *int64) (*coretypes.R } func TestGetPaginatedVotes(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(gov.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, gov.AppModule{}) type testCase struct { description string diff --git a/x/gov/depinject.go b/x/gov/depinject.go index 3776ddf46025..0a24603c421c 100644 --- a/x/gov/depinject.go +++ b/x/gov/depinject.go @@ -10,7 +10,6 @@ import ( modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" "cosmossdk.io/core/appmodule" - store "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" authtypes "cosmossdk.io/x/auth/types" @@ -19,7 +18,6 @@ import ( govtypes "cosmossdk.io/x/gov/types" "cosmossdk.io/x/gov/types/v1beta1" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" ) @@ -40,9 +38,8 @@ type ModuleInputs struct { Config *modulev1.Module Cdc codec.Codec - StoreService store.KVStoreService + Environment appmodule.Environment ModuleKey depinject.OwnModuleKey - MsgServiceRouter baseapp.MessageRouter LegacyProposalHandler []govclient.ProposalHandler `optional:"true"` AccountKeeper govtypes.AccountKeeper @@ -82,12 +79,11 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { k := keeper.NewKeeper( in.Cdc, - in.StoreService, + in.Environment, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.PoolKeeper, - in.MsgServiceRouter, defaultConfig, authority.String(), ) diff --git a/x/gov/go.mod b/x/gov/go.mod index df879c528788..faa9f700e79c 100644 --- a/x/gov/go.mod +++ b/x/gov/go.mod @@ -151,12 +151,12 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/gov/go.sum b/x/gov/go.sum index b83119ac3074..d7d2e2650014 100644 --- a/x/gov/go.sum +++ b/x/gov/go.sum @@ -757,8 +757,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -877,12 +877,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/gov/abci.go b/x/gov/keeper/abci.go similarity index 55% rename from x/gov/abci.go rename to x/gov/keeper/abci.go index 6f8c44f61d8f..9234377be88e 100644 --- a/x/gov/abci.go +++ b/x/gov/keeper/abci.go @@ -1,42 +1,45 @@ -package gov +package keeper import ( + "context" "errors" "fmt" "time" + "google.golang.org/protobuf/runtime/protoiface" + "cosmossdk.io/collections" + "cosmossdk.io/core/event" + "cosmossdk.io/core/router" "cosmossdk.io/log" - "cosmossdk.io/x/gov/keeper" "cosmossdk.io/x/gov/types" v1 "cosmossdk.io/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" ) // EndBlocker is called every block. -func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { +func (k Keeper) EndBlocker(ctx context.Context) error { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - logger := keeper.Logger(ctx) + logger := k.Logger() // delete dead proposals from store and returns theirs deposits. // A proposal is dead when it's inactive and didn't get enough deposit on time to get into voting phase. - rng := collections.NewPrefixUntilPairRange[time.Time, uint64](ctx.HeaderInfo().Time) - err := keeper.InactiveProposalsQueue.Walk(ctx, rng, func(key collections.Pair[time.Time, uint64], _ uint64) (bool, error) { - proposal, err := keeper.Proposals.Get(ctx, key.K2()) + rng := collections.NewPrefixUntilPairRange[time.Time, uint64](k.environment.HeaderService.GetHeaderInfo(ctx).Time) + err := k.InactiveProposalsQueue.Walk(ctx, rng, func(key collections.Pair[time.Time, uint64], _ uint64) (bool, error) { + proposal, err := k.Proposals.Get(ctx, key.K2()) if err != nil { // if the proposal has an encoding error, this means it cannot be processed by x/gov // this could be due to some types missing their registration // instead of returning an error (i.e, halting the chain), we fail the proposal if errors.Is(err, collections.ErrEncoding) { proposal.Id = key.K2() - if err := failUnsupportedProposal(logger, ctx, keeper, proposal, err.Error(), false); err != nil { + if err := failUnsupportedProposal(logger, ctx, k, proposal, err.Error(), false); err != nil { return false, err } - if err = keeper.DeleteProposal(ctx, proposal.Id); err != nil { + if err = k.DeleteProposal(ctx, proposal.Id); err != nil { return false, err } @@ -46,18 +49,18 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { return false, err } - if err = keeper.DeleteProposal(ctx, proposal.Id); err != nil { + if err = k.DeleteProposal(ctx, proposal.Id); err != nil { return false, err } - params, err := keeper.Params.Get(ctx) + params, err := k.Params.Get(ctx) if err != nil { return false, err } if !params.BurnProposalDepositPrevote { - err = keeper.RefundAndDeleteDeposits(ctx, proposal.Id) // refund deposit if proposal got removed without getting 100% of the proposal + err = k.RefundAndDeleteDeposits(ctx, proposal.Id) // refund deposit if proposal got removed without getting 100% of the proposal } else { - err = keeper.DeleteAndBurnDeposits(ctx, proposal.Id) // burn the deposit if proposal got removed without getting 100% of the proposal + err = k.DeleteAndBurnDeposits(ctx, proposal.Id) // burn the deposit if proposal got removed without getting 100% of the proposal } if err != nil { @@ -65,21 +68,20 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { } // called when proposal become inactive - cacheCtx, writeCache := ctx.CacheContext() - err = keeper.Hooks().AfterProposalFailedMinDeposit(cacheCtx, proposal.Id) - if err == nil { // purposely ignoring the error here not to halt the chain if the hook fails - writeCache() - } else { + // call hook when proposal become inactive + if err := k.environment.BranchService.Execute(ctx, func(ctx context.Context) error { + return k.Hooks().AfterProposalFailedMinDeposit(ctx, proposal.Id) + }); err != nil { + // purposely ignoring the error here not to halt the chain if the hook fails logger.Error("failed to execute AfterProposalFailedMinDeposit hook", "error", err) } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeInactiveProposal, - sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), - sdk.NewAttribute(types.AttributeKeyProposalResult, types.AttributeValueProposalDropped), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV(types.EventTypeInactiveProposal, + event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), + event.NewAttribute(types.AttributeKeyProposalResult, types.AttributeValueProposalDropped), + ); err != nil { + logger.Error("failed to emit event", "error", err) + } logger.Info( "proposal did not meet minimum deposit; deleted", @@ -97,20 +99,20 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { } // fetch active proposals whose voting periods have ended (are passed the block time) - rng = collections.NewPrefixUntilPairRange[time.Time, uint64](ctx.HeaderInfo().Time) - err = keeper.ActiveProposalsQueue.Walk(ctx, rng, func(key collections.Pair[time.Time, uint64], _ uint64) (bool, error) { - proposal, err := keeper.Proposals.Get(ctx, key.K2()) + rng = collections.NewPrefixUntilPairRange[time.Time, uint64](k.environment.HeaderService.GetHeaderInfo(ctx).Time) + err = k.ActiveProposalsQueue.Walk(ctx, rng, func(key collections.Pair[time.Time, uint64], _ uint64) (bool, error) { + proposal, err := k.Proposals.Get(ctx, key.K2()) if err != nil { // if the proposal has an encoding error, this means it cannot be processed by x/gov // this could be due to some types missing their registration // instead of returning an error (i.e, halting the chain), we fail the proposal if errors.Is(err, collections.ErrEncoding) { proposal.Id = key.K2() - if err := failUnsupportedProposal(logger, ctx, keeper, proposal, err.Error(), true); err != nil { + if err := failUnsupportedProposal(logger, ctx, k, proposal, err.Error(), true); err != nil { return false, err } - if err = keeper.ActiveProposalsQueue.Remove(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id)); err != nil { + if err = k.ActiveProposalsQueue.Remove(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id)); err != nil { return false, err } @@ -122,7 +124,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { var tagValue, logMsg string - passes, burnDeposits, tallyResults, err := keeper.Tally(ctx, proposal) + passes, burnDeposits, tallyResults, err := k.Tally(ctx, proposal) if err != nil { return false, err } @@ -132,43 +134,36 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { // If a proposal fails, and isn't spammy, deposits are refunded, unless the proposal is expedited or optimistic. // An expedited or optimistic proposal that fails and isn't spammy is converted to a regular proposal. if burnDeposits { - err = keeper.DeleteAndBurnDeposits(ctx, proposal.Id) + err = k.DeleteAndBurnDeposits(ctx, proposal.Id) } else if passes || !(proposal.ProposalType == v1.ProposalType_PROPOSAL_TYPE_EXPEDITED || proposal.ProposalType == v1.ProposalType_PROPOSAL_TYPE_OPTIMISTIC) { - err = keeper.RefundAndDeleteDeposits(ctx, proposal.Id) + err = k.RefundAndDeleteDeposits(ctx, proposal.Id) } if err != nil { // in case of an error, log it and emit an event // we do not want to halt the chain if the refund/burn fails // as it could happen due to a governance mistake (governance has let a proposal pass that sends gov funds that were from proposal deposits) - - keeper.Logger(ctx).Error("failed to refund or burn deposits", "error", err) - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeProposalDeposit, - sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), - sdk.NewAttribute(types.AttributeKeyProposalDepositError, "failed to refund or burn deposits"), - sdk.NewAttribute("error", err.Error()), - ), - ) + k.Logger().Error("failed to refund or burn deposits", "error", err) + + if err := k.environment.EventService.EventManager(ctx).EmitKV(types.EventTypeProposalDeposit, + event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), + event.NewAttribute(types.AttributeKeyProposalDepositError, "failed to refund or burn deposits"), + event.NewAttribute("error", err.Error()), + ); err != nil { + k.Logger().Error("failed to emit event", "error", err) + } } - if err = keeper.ActiveProposalsQueue.Remove(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id)); err != nil { + if err = k.ActiveProposalsQueue.Remove(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id)); err != nil { return false, err } switch { case passes: var ( - idx int - events sdk.Events - msg sdk.Msg + idx int + msg sdk.Msg ) - // attempt to execute all messages within the passed proposal - // Messages may mutate state thus we use a cached context. If one of - // the handlers fails, no state mutation is written and the error - // message is logged. - cacheCtx, writeCache := ctx.CacheContext() messages, err := proposal.GetMsgs() if err != nil { proposal.Status = v1.StatusFailed @@ -179,35 +174,31 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { break } - // execute all messages - for idx, msg = range messages { - handler := keeper.Router().Handler(msg) - var res *sdk.Result - res, err = safeExecuteHandler(cacheCtx, msg, handler) - if err != nil { - break + // attempt to execute all messages within the passed proposal + // Messages may mutate state thus we use a cached context. If one of + // the handlers fails, no state mutation is written and the error + // message is logged. + if err := k.environment.BranchService.Execute(ctx, func(ctx context.Context) error { + // execute all messages + for idx, msg = range messages { + if _, err := safeExecuteHandler(ctx, msg, k.environment.RouterService.MessageRouterService()); err != nil { + // `idx` and `err` are populated with the msg index and error. + proposal.Status = v1.StatusFailed + proposal.FailedReason = err.Error() + tagValue = types.AttributeValueProposalFailed + logMsg = fmt.Sprintf("passed, but msg %d (%s) failed on execution: %s", idx, sdk.MsgTypeURL(msg), err) + + return err + } } - events = append(events, res.GetEvents()...) - } - - // `err == nil` when all handlers passed. - // Or else, `idx` and `err` are populated with the msg index and error. - if err == nil { proposal.Status = v1.StatusPassed tagValue = types.AttributeValueProposalPassed logMsg = "passed" - // write state to the underlying multi-store - writeCache() - - // propagate the msg events to the current context - ctx.EventManager().EmitEvents(events) - } else { - proposal.Status = v1.StatusFailed - proposal.FailedReason = err.Error() - tagValue = types.AttributeValueProposalFailed - logMsg = fmt.Sprintf("passed, but msg %d (%s) failed on execution: %s", idx, sdk.MsgTypeURL(msg), err) + return nil + }); err != nil { + break // We do not anything with the error. Returning an error halts the chain, and proposal struct is already updated. } case !burnDeposits && (proposal.ProposalType == v1.ProposalType_PROPOSAL_TYPE_EXPEDITED || proposal.ProposalType == v1.ProposalType_PROPOSAL_TYPE_OPTIMISTIC): @@ -217,14 +208,14 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { // according to the regular proposal rules. proposal.ProposalType = v1.ProposalType_PROPOSAL_TYPE_STANDARD proposal.Expedited = false // can be removed as never read but kept for state coherence - params, err := keeper.Params.Get(ctx) + params, err := k.Params.Get(ctx) if err != nil { return false, err } endTime := proposal.VotingStartTime.Add(*params.VotingPeriod) proposal.VotingEndTime = &endTime - err = keeper.ActiveProposalsQueue.Set(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id), proposal.Id) + err = k.ActiveProposalsQueue.Set(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id), proposal.Id) if err != nil { return false, err } @@ -245,16 +236,15 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { proposal.FinalTallyResult = &tallyResults - if err = keeper.Proposals.Set(ctx, proposal.Id, proposal); err != nil { + if err = k.Proposals.Set(ctx, proposal.Id, proposal); err != nil { return false, err } - // when proposal become active - cacheCtx, writeCache := ctx.CacheContext() - err = keeper.Hooks().AfterProposalVotingPeriodEnded(cacheCtx, proposal.Id) - if err == nil { // purposely ignoring the error here not to halt the chain if the hook fails - writeCache() - } else { + // call hook when proposal become active + if err := k.environment.BranchService.Execute(ctx, func(ctx context.Context) error { + return k.Hooks().AfterProposalVotingPeriodEnded(ctx, proposal.Id) + }); err != nil { + // purposely ignoring the error here not to halt the chain if the hook fails logger.Error("failed to execute AfterProposalVotingPeriodEnded hook", "error", err) } @@ -267,37 +257,36 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error { "results", logMsg, ) - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeActiveProposal, - sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), - sdk.NewAttribute(types.AttributeKeyProposalResult, tagValue), - sdk.NewAttribute(types.AttributeKeyProposalLog, logMsg), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV(types.EventTypeActiveProposal, + event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), + event.NewAttribute(types.AttributeKeyProposalResult, tagValue), + event.NewAttribute(types.AttributeKeyProposalLog, logMsg), + ); err != nil { + logger.Error("failed to emit event", "error", err) + } return false, nil }) return err } -// executes handle(msg) and recovers from panic. -func safeExecuteHandler(ctx sdk.Context, msg sdk.Msg, handler baseapp.MsgServiceHandler, -) (res *sdk.Result, err error) { +// executes route(msg) and recovers from panic. +func safeExecuteHandler(ctx context.Context, msg sdk.Msg, router router.Router) (res protoiface.MessageV1, err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("handling x/gov proposal msg [%s] PANICKED: %v", msg, r) } }() - res, err = handler(ctx, msg) + + res, err = router.InvokeUntyped(ctx, msg) return } // failUnsupportedProposal fails a proposal that cannot be processed by gov func failUnsupportedProposal( logger log.Logger, - ctx sdk.Context, - keeper *keeper.Keeper, + ctx context.Context, + k Keeper, proposal v1.Proposal, errMsg string, active bool, @@ -306,11 +295,11 @@ func failUnsupportedProposal( proposal.FailedReason = fmt.Sprintf("proposal failed because it cannot be processed by gov: %s", errMsg) proposal.Messages = nil // clear out the messages - if err := keeper.Proposals.Set(ctx, proposal.Id, proposal); err != nil { + if err := k.Proposals.Set(ctx, proposal.Id, proposal); err != nil { return err } - if err := keeper.RefundAndDeleteDeposits(ctx, proposal.Id); err != nil { + if err := k.RefundAndDeleteDeposits(ctx, proposal.Id); err != nil { return err } @@ -319,13 +308,12 @@ func failUnsupportedProposal( eventType = types.EventTypeActiveProposal } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - eventType, - sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), - sdk.NewAttribute(types.AttributeKeyProposalResult, types.AttributeValueProposalFailed), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV(eventType, + event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)), + event.NewAttribute(types.AttributeKeyProposalResult, types.AttributeValueProposalFailed), + ); err != nil { + logger.Error("failed to emit event", "error", err) + } logger.Info( "proposal failed to decode; deleted", diff --git a/x/gov/keeper/abci_internal_test.go b/x/gov/keeper/abci_internal_test.go new file mode 100644 index 000000000000..62c2c3403af8 --- /dev/null +++ b/x/gov/keeper/abci_internal_test.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/runtime/protoiface" + + "cosmossdk.io/core/router" +) + +type mockRouter struct { + router.Router + + panic bool +} + +func (m *mockRouter) InvokeUntyped(ctx context.Context, req protoiface.MessageV1) (res protoiface.MessageV1, err error) { + if m.panic { + panic("test-fail") + } + + return nil, nil +} + +func TestSafeExecuteHandler(t *testing.T) { + t.Parallel() + + require := require.New(t) + ctx := context.Background() + + r, err := safeExecuteHandler(ctx, nil, &mockRouter{panic: true}) + require.ErrorContains(err, "test-fail") + require.Nil(r) + + _, err = safeExecuteHandler(ctx, nil, &mockRouter{panic: false}) + require.Nil(err) +} diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index fb78f6fca0ca..1ab164143397 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -22,6 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -98,7 +99,7 @@ func setupGovKeeper(t *testing.T, expectations ...func(sdk.Context, mocks)) ( storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) - encCfg := moduletestutil.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) v1.RegisterInterfaces(encCfg.InterfaceRegistry) v1beta1.RegisterInterfaces(encCfg.InterfaceRegistry) banktypes.RegisterInterfaces(encCfg.InterfaceRegistry) @@ -112,6 +113,8 @@ func setupGovKeeper(t *testing.T, expectations ...func(sdk.Context, mocks)) ( baseApp.SetCMS(testCtx.CMS) baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry) + environment := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(baseApp.GRPCQueryRouter(), baseApp.MsgServiceRouter())) + // gomock initializations ctrl := gomock.NewController(t) m := mocks{ @@ -130,7 +133,7 @@ func setupGovKeeper(t *testing.T, expectations ...func(sdk.Context, mocks)) ( // Gov keeper initializations - govKeeper := keeper.NewKeeper(encCfg.Codec, storeService, m.acctKeeper, m.bankKeeper, m.stakingKeeper, m.poolKeeper, baseApp.MsgServiceRouter(), keeper.DefaultConfig(), govAcct.String()) + govKeeper := keeper.NewKeeper(encCfg.Codec, environment, m.acctKeeper, m.bankKeeper, m.stakingKeeper, m.poolKeeper, keeper.DefaultConfig(), govAcct.String()) require.NoError(t, govKeeper.ProposalID.Set(ctx, 1)) govRouter := v1beta1.NewRouter() // Also register legacy gov handlers to test them too. govRouter.AddRoute(types.RouterKey, v1beta1.ProposalHandler) diff --git a/x/gov/keeper/deposit.go b/x/gov/keeper/deposit.go index ece9eac79059..fc05386ce8e2 100644 --- a/x/gov/keeper/deposit.go +++ b/x/gov/keeper/deposit.go @@ -6,6 +6,7 @@ import ( "strings" "cosmossdk.io/collections" + "cosmossdk.io/core/event" "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "cosmossdk.io/x/gov/types" @@ -176,14 +177,13 @@ func (k Keeper) AddDeposit(ctx context.Context, proposalID uint64, depositorAddr return false, err } - sdkCtx := sdk.UnwrapSDKContext(ctx) - sdkCtx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeProposalDeposit, - sdk.NewAttribute(sdk.AttributeKeyAmount, depositAmount.String()), - sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV( + types.EventTypeProposalDeposit, + event.NewAttribute(sdk.AttributeKeyAmount, depositAmount.String()), + event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), + ); err != nil { + return false, err + } err = k.SetDeposit(ctx, deposit) if err != nil { diff --git a/x/gov/keeper/hooks_test.go b/x/gov/keeper/hooks_test.go index 85d187294c7a..c6861a488f57 100644 --- a/x/gov/keeper/hooks_test.go +++ b/x/gov/keeper/hooks_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" - "cosmossdk.io/x/gov" "cosmossdk.io/x/gov/keeper" "cosmossdk.io/x/gov/types" v1 "cosmossdk.io/x/gov/types/v1" @@ -83,7 +82,7 @@ func TestHooks(t *testing.T) { newHeader := ctx.HeaderInfo() newHeader.Time = ctx.HeaderInfo().Time.Add(*params.MaxDepositPeriod).Add(time.Duration(1) * time.Second) ctx = ctx.WithHeaderInfo(newHeader) - err = gov.EndBlocker(ctx, govKeeper) + err = govKeeper.EndBlocker(ctx) require.NoError(t, err) require.True(t, govHooksReceiver.AfterProposalFailedMinDepositValid) @@ -103,7 +102,7 @@ func TestHooks(t *testing.T) { newHeader = ctx.HeaderInfo() newHeader.Time = ctx.HeaderInfo().Time.Add(*params.VotingPeriod).Add(time.Duration(1) * time.Second) ctx = ctx.WithHeaderInfo(newHeader) - err = gov.EndBlocker(ctx, govKeeper) + err = govKeeper.EndBlocker(ctx) require.NoError(t, err) require.True(t, govHooksReceiver.AfterProposalVotingPeriodEndedValid) } diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 6ffa959c71c1..0610da71e1d5 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -7,13 +7,12 @@ import ( "time" "cosmossdk.io/collections" - corestoretypes "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" "cosmossdk.io/log" "cosmossdk.io/x/gov/types" v1 "cosmossdk.io/x/gov/types/v1" "cosmossdk.io/x/gov/types/v1beta1" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -23,25 +22,21 @@ type Keeper struct { authKeeper types.AccountKeeper bankKeeper types.BankKeeper poolKeeper types.PoolKeeper - // The reference to the DelegationSet and ValidatorSet to get information about validators and delegators sk types.StakingKeeper // GovHooks hooks types.GovHooks - // The (unexposed) keys used to access the stores from the Context. - storeService corestoretypes.KVStoreService - // The codec for binary encoding/decoding. cdc codec.Codec + // Module environment + environment appmodule.Environment + // Legacy Proposal router legacyRouter v1beta1.Router - // Msg server router - router baseapp.MessageRouter - // Config represent extra module configuration config Config @@ -87,9 +82,9 @@ func (k Keeper) GetAuthority() string { // // CONTRACT: the parameter Subspace must have the param key table already initialized func NewKeeper( - cdc codec.Codec, storeService corestoretypes.KVStoreService, authKeeper types.AccountKeeper, + cdc codec.Codec, env appmodule.Environment, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, pk types.PoolKeeper, - router baseapp.MessageRouter, config Config, authority string, + config Config, authority string, ) *Keeper { // ensure governance module account is set if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil { @@ -114,15 +109,14 @@ func NewKeeper( config.MaxSummaryLen = defaultConfig.MaxSummaryLen } - sb := collections.NewSchemaBuilder(storeService) + sb := collections.NewSchemaBuilder(env.KVStoreService) k := &Keeper{ - storeService: storeService, + environment: env, authKeeper: authKeeper, bankKeeper: bankKeeper, sk: sk, poolKeeper: pk, cdc: cdc, - router: router, config: config, authority: authority, Constitution: collections.NewItem(sb, types.ConstitutionKey, "constitution", collections.StringValue), @@ -175,14 +169,8 @@ func (k *Keeper) SetLegacyRouter(router v1beta1.Router) { } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx context.Context) log.Logger { - sdkCtx := sdk.UnwrapSDKContext(ctx) - return sdkCtx.Logger().With("module", "x/"+types.ModuleName) -} - -// Router returns the gov keeper's router -func (k Keeper) Router() baseapp.MessageRouter { - return k.router +func (k Keeper) Logger() log.Logger { + return k.environment.Logger.With("module", "x/"+types.ModuleName) } // LegacyRouter returns the gov keeper's legacy router diff --git a/x/gov/keeper/migrations.go b/x/gov/keeper/migrations.go index d8e02e0d3f8e..d6278326f7a0 100644 --- a/x/gov/keeper/migrations.go +++ b/x/gov/keeper/migrations.go @@ -36,10 +36,10 @@ func (m Migrator) Migrate3to4(ctx context.Context) error { // Migrate4to5 migrates from version 4 to 5. func (m Migrator) Migrate4to5(ctx context.Context) error { - return v5.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc, m.keeper.Constitution) + return v5.MigrateStore(ctx, m.keeper.environment.KVStoreService, m.keeper.cdc, m.keeper.Constitution) } // Migrate4to5 migrates from version 5 to 6. func (m Migrator) Migrate5to6(ctx context.Context) error { - return v6.MigrateStore(ctx, m.keeper.storeService, m.keeper.Params, m.keeper.Proposals) + return v6.MigrateStore(ctx, m.keeper.environment.KVStoreService, m.keeper.Params, m.keeper.Proposals) } diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index e6cc63a2b8f6..1799cbefcd87 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -5,6 +5,9 @@ import ( "encoding/json" "fmt" + "google.golang.org/protobuf/runtime/protoiface" + + "cosmossdk.io/core/event" "cosmossdk.io/errors" "cosmossdk.io/math" govtypes "cosmossdk.io/x/gov/types" @@ -28,7 +31,7 @@ func NewMsgServerImpl(keeper *Keeper) v1.MsgServer { var _ v1.MsgServer = msgServer{} // SubmitProposal implements the MsgServer.SubmitProposal method. -func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitProposal) (*v1.MsgSubmitProposalResponse, error) { +func (k msgServer) SubmitProposal(ctx context.Context, msg *v1.MsgSubmitProposal) (*v1.MsgSubmitProposalResponse, error) { proposer, err := k.authKeeper.AddressCodec().StringToBytes(msg.GetProposer()) if err != nil { return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err) @@ -67,7 +70,6 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) params, err := k.Params.Get(ctx) if err != nil { return nil, fmt.Errorf("failed to get governance parameters: %w", err) @@ -95,8 +97,8 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos } // ref: https://github.com/cosmos/cosmos-sdk/issues/9683 - ctx.GasMeter().ConsumeGas( - 3*ctx.KVGasConfig().WriteCostPerByte*uint64(len(bytes)), + k.environment.GasService.GetGasMeter(ctx).Consume( + 3*k.environment.GasService.GetGasConfig(ctx).WriteCostPerByte*uint64(len(bytes)), "submit proposal", ) @@ -106,11 +108,12 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos } if votingStarted { - ctx.EventManager().EmitEvent( - sdk.NewEvent(govtypes.EventTypeSubmitProposal, - sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV( + govtypes.EventTypeSubmitProposal, + event.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)), + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", govtypes.EventTypeSubmitProposal) + } } return &v1.MsgSubmitProposalResponse{ @@ -158,36 +161,33 @@ func (k msgServer) SubmitMultipleChoiceProposal(ctx context.Context, msg *v1.Msg } // CancelProposal implements the MsgServer.CancelProposal method. -func (k msgServer) CancelProposal(goCtx context.Context, msg *v1.MsgCancelProposal) (*v1.MsgCancelProposalResponse, error) { +func (k msgServer) CancelProposal(ctx context.Context, msg *v1.MsgCancelProposal) (*v1.MsgCancelProposalResponse, error) { _, err := k.authKeeper.AddressCodec().StringToBytes(msg.Proposer) if err != nil { return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err) } - ctx := sdk.UnwrapSDKContext(goCtx) if err := k.Keeper.CancelProposal(ctx, msg.ProposalId, msg.Proposer); err != nil { return nil, err } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - govtypes.EventTypeCancelProposal, - sdk.NewAttribute(sdk.AttributeKeySender, msg.Proposer), - sdk.NewAttribute(govtypes.AttributeKeyProposalID, fmt.Sprint(msg.ProposalId)), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV( + govtypes.EventTypeCancelProposal, + event.NewAttribute(sdk.AttributeKeySender, msg.Proposer), + event.NewAttribute(govtypes.AttributeKeyProposalID, fmt.Sprint(msg.ProposalId)), + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", govtypes.EventTypeCancelProposal) + } return &v1.MsgCancelProposalResponse{ ProposalId: msg.ProposalId, - CanceledTime: ctx.HeaderInfo().Time, - CanceledHeight: uint64(ctx.BlockHeight()), + CanceledTime: k.environment.HeaderService.GetHeaderInfo(ctx).Time, + CanceledHeight: uint64(k.environment.HeaderService.GetHeaderInfo(ctx).Height), }, nil } // ExecLegacyContent implements the MsgServer.ExecLegacyContent method. -func (k msgServer) ExecLegacyContent(goCtx context.Context, msg *v1.MsgExecLegacyContent) (*v1.MsgExecLegacyContentResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k msgServer) ExecLegacyContent(ctx context.Context, msg *v1.MsgExecLegacyContent) (*v1.MsgExecLegacyContentResponse, error) { govAcct, err := k.authKeeper.AddressCodec().BytesToString(k.GetGovernanceAccount(ctx).GetAddress()) if err != nil { return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid governance account address: %s", err) @@ -277,7 +277,7 @@ func (k msgServer) VoteWeighted(ctx context.Context, msg *v1.MsgVoteWeighted) (* } // Deposit implements the MsgServer.Deposit method. -func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDepositResponse, error) { +func (k msgServer) Deposit(ctx context.Context, msg *v1.MsgDeposit) (*v1.MsgDepositResponse, error) { accAddr, err := k.authKeeper.AddressCodec().StringToBytes(msg.Depositor) if err != nil { return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid depositor address: %s", err) @@ -287,19 +287,18 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe return nil, err } - ctx := sdk.UnwrapSDKContext(goCtx) votingStarted, err := k.Keeper.AddDeposit(ctx, msg.ProposalId, accAddr, msg.Amount) if err != nil { return nil, err } if votingStarted { - ctx.EventManager().EmitEvent( - sdk.NewEvent( - govtypes.EventTypeProposalDeposit, - sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV( + govtypes.EventTypeProposalDeposit, + event.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)), + ); err != nil { + return nil, errors.Wrapf(err, "failed to emit event: %s", govtypes.EventTypeProposalDeposit) + } } return &v1.MsgDepositResponse{}, nil @@ -374,27 +373,32 @@ func (k msgServer) SudoExec(ctx context.Context, msg *v1.MsgSudoExec) (*v1.MsgSu } } - handler := k.router.Handler(sudoedMsg) - if handler == nil { - return nil, errors.Wrapf(govtypes.ErrInvalidProposal, "unrecognized message route: %s", sdk.MsgTypeURL(sudoedMsg)) - } + var msgResp protoiface.MessageV1 + if err := k.environment.BranchService.Execute(ctx, func(ctx context.Context) error { + // TODO add route check here + if err := k.environment.RouterService.MessageRouterService().CanInvoke(ctx, sdk.MsgTypeURL(sudoedMsg)); err != nil { + return errors.Wrapf(govtypes.ErrInvalidProposal, err.Error()) + } - sdkCtx := sdk.UnwrapSDKContext(ctx) - msgResp, err := handler(sdkCtx, sudoedMsg) - if err != nil { - return nil, errors.Wrapf(err, "failed to execute sudo-ed message; message %v", sudoedMsg) + msgResp, err = k.environment.RouterService.MessageRouterService().InvokeUntyped(ctx, sudoedMsg) + if err != nil { + return errors.Wrapf(err, "failed to execute sudo-ed message; message %v", sudoedMsg) + } + + return nil + }); err != nil { + return nil, err } - // emit the events from the executed message - events := msgResp.Events - sdkEvents := make([]sdk.Event, 0, len(events)) - for _, event := range events { - sdkEvents = append(sdkEvents, sdk.Event(event)) + // TODO(@julienrbrt): check if events are properly emitted + + msgRespBytes, err := k.cdc.MarshalJSON(msgResp) + if err != nil { + return nil, errors.Wrapf(err, "failed to marshal sudo-ed message response; message %v", msgResp) } - sdkCtx.EventManager().EmitEvents(sdkEvents) return &v1.MsgSudoExecResponse{ - Result: msgResp.Data, + Result: msgRespBytes, }, nil } diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go index 5163353a069d..3f0632d06fc0 100644 --- a/x/gov/keeper/msg_server_test.go +++ b/x/gov/keeper/msg_server_test.go @@ -2131,7 +2131,7 @@ func (suite *KeeperTestSuite) TestMsgSudoExec() { { name: "invalid msg (not registered)", input: invalidMsg, - expErrMsg: "unrecognized message route", + expErrMsg: "unknown message", }, { name: "valid", diff --git a/x/gov/keeper/proposal.go b/x/gov/keeper/proposal.go index 8e7801f8f520..de732b8760f3 100644 --- a/x/gov/keeper/proposal.go +++ b/x/gov/keeper/proposal.go @@ -10,6 +10,7 @@ import ( "time" "cosmossdk.io/collections" + "cosmossdk.io/core/event" errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "cosmossdk.io/x/gov/types" @@ -38,7 +39,6 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata } } - sdkCtx := sdk.UnwrapSDKContext(ctx) msgs := []string{} // will hold a string slice of all Msg type URLs. // Loop through all messages and confirm that each has a handler and the gov module account as the only signer @@ -83,10 +83,8 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata return v1.Proposal{}, errorsmod.Wrapf(types.ErrInvalidSigner, sdk.AccAddress(signers[0]).String()) } - // use the msg service router to see that there is a valid route for that message. - handler := k.router.Handler(msg) - if handler == nil { - return v1.Proposal{}, errorsmod.Wrap(types.ErrUnroutableProposalMsg, sdk.MsgTypeURL(msg)) + if err := k.environment.RouterService.MessageRouterService().CanInvoke(ctx, sdk.MsgTypeURL(msg)); err != nil { + return v1.Proposal{}, errorsmod.Wrap(types.ErrUnroutableProposalMsg, err.Error()) } // Only if it's a MsgExecLegacyContent we try to execute the @@ -98,14 +96,27 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata if !ok { continue } - cacheCtx, _ := sdkCtx.CacheContext() - if _, err := handler(cacheCtx, msg); err != nil { - if errors.Is(types.ErrNoProposalHandlerExists, err) { - return v1.Proposal{}, err - } - return v1.Proposal{}, errorsmod.Wrap(types.ErrInvalidProposalContent, err.Error()) + + content, err := v1.LegacyContentFromMessage(msg) + if err != nil { + return v1.Proposal{}, errorsmod.Wrapf(types.ErrInvalidProposalContent, "%+v", err) } + // Ensure that the content has a respective handler + if !k.legacyRouter.HasRoute(content.ProposalRoute()) { + return v1.Proposal{}, errorsmod.Wrap(types.ErrNoProposalHandlerExists, content.ProposalRoute()) + } + + if err = k.environment.BranchService.Execute(ctx, func(ctx context.Context) error { + handler := k.legacyRouter.GetRoute(content.ProposalRoute()) + if err := handler(ctx, content); err != nil { + return types.ErrInvalidProposalContent.Wrapf("failed to run legacy handler %s, %+v", content.ProposalRoute(), err) + } + + return errors.New("we don't want to execute the proposal, we just want to check if it can be executed") + }); errors.Is(err, types.ErrInvalidProposalContent) { + return v1.Proposal{}, err + } } proposalID, err := k.ProposalID.Next(ctx) @@ -113,7 +124,7 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata return v1.Proposal{}, err } - submitTime := sdkCtx.HeaderInfo().Time + submitTime := k.environment.HeaderService.GetHeaderInfo(ctx).Time proposal, err := v1.NewProposal(messages, proposalID, submitTime, submitTime.Add(*params.MaxDepositPeriod), metadata, title, summary, proposer, proposalType) if err != nil { return v1.Proposal{}, err @@ -133,20 +144,19 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata return v1.Proposal{}, err } - sdkCtx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeSubmitProposal, - sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), - sdk.NewAttribute(types.AttributeKeyProposalMessages, strings.Join(msgs, ",")), - ), - ) + if err := k.environment.EventService.EventManager(ctx).EmitKV( + types.EventTypeSubmitProposal, + event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), + event.NewAttribute(types.AttributeKeyProposalMessages, strings.Join(msgs, ",")), + ); err != nil { + return v1.Proposal{}, fmt.Errorf("failed to emit event: %w", err) + } return proposal, nil } // CancelProposal will cancel proposal before the voting period ends func (k Keeper) CancelProposal(ctx context.Context, proposalID uint64, proposer string) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) proposal, err := k.Proposals.Get(ctx, proposalID) if err != nil { if errors.Is(err, collections.ErrNotFound) { @@ -178,7 +188,7 @@ func (k Keeper) CancelProposal(ctx context.Context, proposalID uint64, proposer // Check proposal is not too far in voting period to be canceled if proposal.VotingEndTime != nil { - currentTime := sdkCtx.HeaderInfo().Time + currentTime := k.environment.HeaderService.GetHeaderInfo(ctx).Time maxCancelPeriodRate := sdkmath.LegacyMustNewDecFromStr(params.ProposalCancelMaxPeriod) maxCancelPeriod := time.Duration(float64(proposal.VotingEndTime.Sub(*proposal.VotingStartTime)) * maxCancelPeriodRate.MustFloat64()).Round(time.Second) @@ -209,7 +219,7 @@ func (k Keeper) CancelProposal(ctx context.Context, proposalID uint64, proposer return err } - k.Logger(ctx).Info( + k.Logger().Info( "proposal is canceled by proposer", "proposal", proposal.Id, "proposer", proposal.Proposer, @@ -243,8 +253,7 @@ func (k Keeper) DeleteProposal(ctx context.Context, proposalID uint64) error { // ActivateVotingPeriod activates the voting period of a proposal func (k Keeper) ActivateVotingPeriod(ctx context.Context, proposal v1.Proposal) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - startTime := sdkCtx.HeaderInfo().Time + startTime := k.environment.HeaderService.GetHeaderInfo(ctx).Time proposal.VotingStartTime = &startTime params, err := k.Params.Get(ctx) diff --git a/x/gov/keeper/vote.go b/x/gov/keeper/vote.go index a8dcf8340ab2..41805fe0b891 100644 --- a/x/gov/keeper/vote.go +++ b/x/gov/keeper/vote.go @@ -6,6 +6,7 @@ import ( "fmt" "cosmossdk.io/collections" + "cosmossdk.io/core/event" "cosmossdk.io/errors" "cosmossdk.io/x/gov/types" v1 "cosmossdk.io/x/gov/types/v1" @@ -74,22 +75,15 @@ func (k Keeper) AddVote(ctx context.Context, proposalID uint64, voterAddr sdk.Ac } // called after a vote on a proposal is cast - err = k.Hooks().AfterProposalVote(ctx, proposalID, voterAddr) - if err != nil { + if err = k.Hooks().AfterProposalVote(ctx, proposalID, voterAddr); err != nil { return err } - sdkCtx := sdk.UnwrapSDKContext(ctx) - sdkCtx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeProposalVote, - sdk.NewAttribute(types.AttributeKeyVoter, voterAddr.String()), - sdk.NewAttribute(types.AttributeKeyOption, options.String()), - sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), - ), + return k.environment.EventService.EventManager(ctx).EmitKV(types.EventTypeProposalVote, + event.NewAttribute(types.AttributeKeyVoter, voterAddr.String()), + event.NewAttribute(types.AttributeKeyOption, options.String()), + event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), ) - - return nil } // deleteVotes deletes all the votes from a given proposalID. diff --git a/x/gov/migrations/v5/store_test.go b/x/gov/migrations/v5/store_test.go index c84ee38e0a34..b790aaf971ae 100644 --- a/x/gov/migrations/v5/store_test.go +++ b/x/gov/migrations/v5/store_test.go @@ -13,13 +13,14 @@ import ( v5 "cosmossdk.io/x/gov/migrations/v5" v1 "cosmossdk.io/x/gov/types/v1" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func TestMigrateStore(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig(gov.AppModule{}, bank.AppModule{}).Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, gov.AppModule{}, bank.AppModule{}).Codec govKey := storetypes.NewKVStoreKey("gov") ctx := testutil.DefaultContext(govKey, storetypes.NewTransientStoreKey("transient_test")) store := ctx.KVStore(govKey) diff --git a/x/gov/migrations/v6/store_test.go b/x/gov/migrations/v6/store_test.go index f356f59cca43..76a6aa654e6a 100644 --- a/x/gov/migrations/v6/store_test.go +++ b/x/gov/migrations/v6/store_test.go @@ -13,13 +13,14 @@ import ( v1 "cosmossdk.io/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func TestMigrateStore(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig(gov.AppModule{}).Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, gov.AppModule{}).Codec govKey := storetypes.NewKVStoreKey("gov") ctx := testutil.DefaultContext(govKey, storetypes.NewTransientStoreKey("transient_test")) storeService := runtime.NewKVStoreService(govKey) diff --git a/x/gov/module.go b/x/gov/module.go index 85c95353513a..f169e4b8c754 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" govclient "cosmossdk.io/x/gov/client" "cosmossdk.io/x/gov/client/cli" "cosmossdk.io/x/gov/keeper" @@ -20,7 +21,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -29,13 +29,13 @@ import ( const ConsensusVersion = 6 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} - _ module.HasInvariants = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasInvariants = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -110,7 +110,7 @@ func getProposalCLIHandlers(handlers []govclient.ProposalHandler) []*cobra.Comma } // RegisterInterfaces implements InterfaceModule.RegisterInterfaces -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { v1.RegisterInterfaces(registry) v1beta1.RegisterInterfaces(registry) } @@ -194,8 +194,7 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // EndBlock returns the end blocker for the gov module. func (am AppModule) EndBlock(ctx context.Context) error { - c := sdk.UnwrapSDKContext(ctx) - return EndBlocker(c, am.keeper) + return am.keeper.EndBlocker(ctx) } // AppModuleSimulation functions diff --git a/x/gov/types/v1/codec.go b/x/gov/types/v1/codec.go index bd8f7e042e24..6a3b96cc97a7 100644 --- a/x/gov/types/v1/codec.go +++ b/x/gov/types/v1/codec.go @@ -1,9 +1,10 @@ package v1 import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -23,7 +24,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the Interface Registry. -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitProposal{}, &MsgSubmitMultipleChoiceProposal{}, diff --git a/x/gov/types/v1beta1/codec.go b/x/gov/types/v1beta1/codec.go index d5b8b90880e2..9c6c4064c68f 100644 --- a/x/gov/types/v1beta1/codec.go +++ b/x/gov/types/v1beta1/codec.go @@ -1,9 +1,10 @@ package v1beta1 import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -20,7 +21,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the Interface Registry. -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitProposal{}, &MsgVote{}, diff --git a/x/gov/types/v1beta1/content.go b/x/gov/types/v1beta1/content.go index 64d4ef4f19ae..15120c829cd5 100644 --- a/x/gov/types/v1beta1/content.go +++ b/x/gov/types/v1beta1/content.go @@ -1,6 +1,6 @@ package v1beta1 -import sdk "github.com/cosmos/cosmos-sdk/types" +import context "context" // Content defines an interface that a proposal must implement. It contains // information such as the title and description along with the type and routing @@ -17,7 +17,7 @@ type Content interface { // Handler defines a function that handles a proposal after it has passed the // governance process. -type Handler func(ctx sdk.Context, content Content) error +type Handler func(ctx context.Context, content Content) error type HandlerRoute struct { Handler Handler diff --git a/x/gov/types/v1beta1/proposal.go b/x/gov/types/v1beta1/proposal.go index ec7d4ed8c460..fdc7821ee957 100644 --- a/x/gov/types/v1beta1/proposal.go +++ b/x/gov/types/v1beta1/proposal.go @@ -1,6 +1,7 @@ package v1beta1 import ( + context "context" "fmt" "strings" "time" @@ -249,7 +250,7 @@ func IsValidProposalType(ty string) bool { // proposals (ie. TextProposal ). Since these are // merely signaling mechanisms at the moment and do not affect state, it // performs a no-op. -func ProposalHandler(_ sdk.Context, c Content) error { +func ProposalHandler(_ context.Context, c Content) error { switch c.ProposalType() { case ProposalTypeText: // both proposal types do not change state so this performs a no-op diff --git a/x/group/client/cli/tx_test.go b/x/group/client/cli/tx_test.go index d46599c17634..dbc768f2d4e7 100644 --- a/x/group/client/cli/tx_test.go +++ b/x/group/client/cli/tx_test.go @@ -22,6 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" @@ -49,7 +50,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig(groupmodule.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, groupmodule.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/x/group/codec.go b/x/group/codec.go index 937fea2a6c78..5c816ebebcc9 100644 --- a/x/group/codec.go +++ b/x/group/codec.go @@ -1,9 +1,10 @@ package group import ( + "cosmossdk.io/core/registry" + codectypes "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -33,7 +34,7 @@ func RegisterLegacyAminoCodec(cdc *codectypes.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateGroup{}, &MsgUpdateGroupMembers{}, diff --git a/x/group/go.mod b/x/group/go.mod index 033bc332babf..29da9d5d8311 100644 --- a/x/group/go.mod +++ b/x/group/go.mod @@ -154,12 +154,12 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/group/go.sum b/x/group/go.sum index 8820e64701dd..b7ec93bae2bd 100644 --- a/x/group/go.sum +++ b/x/group/go.sum @@ -757,8 +757,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -877,12 +877,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/group/keeper/genesis_test.go b/x/group/keeper/genesis_test.go index 00e66b436069..0af3c8678d86 100644 --- a/x/group/keeper/genesis_test.go +++ b/x/group/keeper/genesis_test.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -52,7 +53,7 @@ func (s *GenesisTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(group.StoreKey) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) ctrl := gomock.NewController(s.T()) accountKeeper := grouptestutil.NewMockAccountKeeper(ctrl) diff --git a/x/group/keeper/grpc_query_test.go b/x/group/keeper/grpc_query_test.go index 95ddd1e200ea..dccc77656925 100644 --- a/x/group/keeper/grpc_query_test.go +++ b/x/group/keeper/grpc_query_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -44,7 +45,7 @@ func initKeeper(t *testing.T) *fixture { key := storetypes.NewKVStoreKey(group.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) ctx := testCtx.Ctx diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 1c19479bcf43..4188ccd91299 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -54,7 +55,7 @@ func (s *TestSuite) SetupTest() { key := storetypes.NewKVStoreKey(group.StoreKey) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}, bank.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}, bank.AppModule{}) s.addrs = simtestutil.CreateIncrementalAccounts(6) // setup gomock and initialize some globally expected executions diff --git a/x/group/migrations/v2/migrate_test.go b/x/group/migrations/v2/migrate_test.go index 098586580620..c06b975c826c 100644 --- a/x/group/migrations/v2/migrate_test.go +++ b/x/group/migrations/v2/migrate_test.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,7 +35,7 @@ var ( ) func TestMigrate(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModule{}, groupmodule.AppModule{}).Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, groupmodule.AppModule{}).Codec storeKey := storetypes.NewKVStoreKey(v2.ModuleName) storeService := runtime.NewKVStoreService(storeKey) tKey := storetypes.NewTransientStoreKey("transient_test") diff --git a/x/group/module/module.go b/x/group/module/module.go index 176ef28cf00a..4a232b9c142f 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/group" "cosmossdk.io/x/group/client/cli" "cosmossdk.io/x/group/keeper" @@ -27,13 +28,13 @@ import ( const ConsensusVersion = 2 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} - _ module.HasInvariants = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasInvariants = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -82,7 +83,7 @@ func (am AppModule) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux * } // RegisterInterfaces registers the group module's interface types -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { group.RegisterInterfaces(registry) } diff --git a/x/group/proposal_test.go b/x/group/proposal_test.go index d7a5748d5f53..eff18529ff7d 100644 --- a/x/group/proposal_test.go +++ b/x/group/proposal_test.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/x/group" "cosmossdk.io/x/group/module" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) @@ -16,7 +17,7 @@ import ( // This test serves as a showcase that we need to be careful when unmarshalling // multiple times into the same reference. func TestGogoUnmarshalProposal(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) cdc := encodingConfig.Codec p1 := group.Proposal{Proposers: []string{"foo"}} diff --git a/x/group/simulation/decoder_test.go b/x/group/simulation/decoder_test.go index 303490e02b8a..6eee5a2fbd63 100644 --- a/x/group/simulation/decoder_test.go +++ b/x/group/simulation/decoder_test.go @@ -12,13 +12,14 @@ import ( "cosmossdk.io/x/group/module" "cosmossdk.io/x/group/simulation" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/cosmos/cosmos-sdk/types/kv" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func TestDecodeStore(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) cdc := encodingConfig.Codec dec := simulation.NewDecodeStore(cdc) diff --git a/x/group/simulation/genesis_test.go b/x/group/simulation/genesis_test.go index 7bc06aa2ccc7..9d129fca7af7 100644 --- a/x/group/simulation/genesis_test.go +++ b/x/group/simulation/genesis_test.go @@ -13,13 +13,14 @@ import ( groupmodule "cosmossdk.io/x/group/module" "cosmossdk.io/x/group/simulation" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/types/module" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) func TestRandomizedGenState(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(groupmodule.AppModule{}, bank.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, groupmodule.AppModule{}, bank.AppModule{}) cdc := encodingConfig.Codec s := rand.NewSource(1) diff --git a/x/mint/go.mod b/x/mint/go.mod index 124544a7abe3..0ca1057bbb55 100644 --- a/x/mint/go.mod +++ b/x/mint/go.mod @@ -146,13 +146,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/mint/go.sum b/x/mint/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/mint/go.sum +++ b/x/mint/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/mint/keeper/genesis_test.go b/x/mint/keeper/genesis_test.go index c21dbc4fc421..5fc6e9e03678 100644 --- a/x/mint/keeper/genesis_test.go +++ b/x/mint/keeper/genesis_test.go @@ -17,6 +17,7 @@ import ( "cosmossdk.io/x/mint/types" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -42,7 +43,7 @@ func TestGenesisTestSuite(t *testing.T) { func (s *GenesisTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(types.StoreKey) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, mint.AppModule{}) // gomock initializations ctrl := gomock.NewController(s.T()) diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index 5b190ae5d444..f2f80689b759 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/x/mint/types" "github.com/cosmos/cosmos-sdk/baseapp" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -31,7 +32,7 @@ type MintTestSuite struct { } func (suite *MintTestSuite) SetupTest() { - encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, mint.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test")) diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index 0f22cb763ae1..fb4fa58c1827 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -15,6 +15,7 @@ import ( minttestutil "cosmossdk.io/x/mint/testutil" "cosmossdk.io/x/mint/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -38,7 +39,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (s *IntegrationTestSuite) SetupTest() { - encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, mint.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) env := runtime.NewEnvironment(storeService, log.NewNopLogger()) diff --git a/x/mint/module.go b/x/mint/module.go index 3f8e9fbabfb8..8f228900c8d8 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -9,13 +9,13 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/mint/keeper" "cosmossdk.io/x/mint/simulation" "cosmossdk.io/x/mint/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -24,12 +24,12 @@ import ( const ConsensusVersion = 2 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -82,7 +82,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the module's interface types -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index a4a79ef3f31b..8a3858e3d293 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/x/mint/simulation" "cosmossdk.io/x/mint/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -21,7 +22,7 @@ import ( // TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. // Abonormal scenarios are not tested here. func TestRandomizedGenState(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, mint.AppModule{}) s := rand.NewSource(1) r := rand.New(s) @@ -60,7 +61,7 @@ func TestRandomizedGenState(t *testing.T) { // TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. func TestRandomizedGenState1(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, mint.AppModule{}) s := rand.NewSource(1) r := rand.New(s) diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index bdbe4b9f50bb..0f35aead639b 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -1,9 +1,10 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -15,7 +16,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgUpdateParams{}, diff --git a/x/nft/codec.go b/x/nft/codec.go index 12a4250cb308..c02cf391372c 100644 --- a/x/nft/codec.go +++ b/x/nft/codec.go @@ -1,13 +1,14 @@ package nft import ( - types "github.com/cosmos/cosmos-sdk/codec/types" + "cosmossdk.io/core/registry" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterInterfaces registers the interfaces types with the interface registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, ) diff --git a/x/nft/go.mod b/x/nft/go.mod index 394d05a7be95..4242c952404e 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -145,13 +145,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/nft/go.sum b/x/nft/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/nft/keeper/keeper_test.go b/x/nft/keeper/keeper_test.go index 2332a68b38e1..823553727bd5 100644 --- a/x/nft/keeper/keeper_test.go +++ b/x/nft/keeper/keeper_test.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -52,7 +53,7 @@ type TestSuite struct { func (s *TestSuite) SetupTest() { // suite setup s.addrs = simtestutil.CreateIncrementalAccounts(3) - s.encCfg = moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + s.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) key := storetypes.NewKVStoreKey(nft.StoreKey) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 8f213b1305c9..b782d14c39fb 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -8,6 +8,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/errors" "cosmossdk.io/x/nft" "cosmossdk.io/x/nft/keeper" @@ -21,11 +22,11 @@ import ( ) var ( - _ module.HasName = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -70,7 +71,7 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error { } // RegisterInterfaces registers the nft module's interface types -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { nft.RegisterInterfaces(registry) } diff --git a/x/nft/simulation/decoder_test.go b/x/nft/simulation/decoder_test.go index 4c4b4a9941ec..7498ee7e8f58 100644 --- a/x/nft/simulation/decoder_test.go +++ b/x/nft/simulation/decoder_test.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/x/nft/module" "cosmossdk.io/x/nft/simulation" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" @@ -23,7 +24,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{}) dec := simulation.NewDecodeStore(encCfg.Codec) class := nft.Class{ diff --git a/x/nft/simulation/genesis_test.go b/x/nft/simulation/genesis_test.go index cd82052df323..3aa6928943c0 100644 --- a/x/nft/simulation/genesis_test.go +++ b/x/nft/simulation/genesis_test.go @@ -13,13 +13,14 @@ import ( "cosmossdk.io/x/nft/simulation" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/types/module" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) func TestRandomizedGenState(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(nftmodule.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, nftmodule.AppModule{}) s := rand.NewSource(1) r := rand.New(s) diff --git a/x/params/go.mod b/x/params/go.mod index 386be5f463d5..4458b3a04543 100644 --- a/x/params/go.mod +++ b/x/params/go.mod @@ -146,13 +146,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/params/go.sum b/x/params/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/params/go.sum +++ b/x/params/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index 2511b1e77eb3..5a577e51b649 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -6,13 +6,14 @@ import ( paramskeeper "cosmossdk.io/x/params/keeper" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" sdktestutil "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func testComponents() (*codec.LegacyAmino, sdk.Context, storetypes.StoreKey, storetypes.StoreKey, paramskeeper.Keeper) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(params.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, params.AppModule{}) cdc := encodingConfig.Codec legacyAmino := createTestCodec() diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index 382b5ed9e8f0..d82db839dd35 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/baseapp" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -30,7 +31,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - encodingCfg := moduletestutil.MakeTestEncodingConfig(params.AppModule{}) + encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, params.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) tkey := storetypes.NewTransientStoreKey("params_transient_test") diff --git a/x/params/module.go b/x/params/module.go index f919fc1ec16c..5cd796cc867c 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -7,22 +7,22 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/params/keeper" "cosmossdk.io/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasServices = AppModule{} @@ -64,7 +64,7 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } // RegisterInterfaces registers the module's interface types -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { proposal.RegisterInterfaces(registry) } diff --git a/x/params/proposal_handler.go b/x/params/proposal_handler.go index 7483603a7ea8..25ec53162ebd 100644 --- a/x/params/proposal_handler.go +++ b/x/params/proposal_handler.go @@ -1,6 +1,7 @@ package params import ( + "context" "fmt" errorsmod "cosmossdk.io/errors" @@ -14,10 +15,14 @@ import ( // NewParamChangeProposalHandler creates a new governance Handler for a ParamChangeProposal func NewParamChangeProposalHandler(k keeper.Keeper) govtypes.Handler { - return func(ctx sdk.Context, content govtypes.Content) error { + return func(ctx context.Context, content govtypes.Content) error { + // UnwrapSDKContext makes x/params baseapp compatible only and not server/v2 + // We should investigate if we want to make x/params server/v2 compatible + sdkCtx := sdk.UnwrapSDKContext(ctx) + switch c := content.(type) { case *proposal.ParameterChangeProposal: - return handleParameterChangeProposal(ctx, k, c) + return handleParameterChangeProposal(sdkCtx, k, c) default: return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized param proposal content type: %T", c) diff --git a/x/params/types/proposal/codec.go b/x/params/types/proposal/codec.go index f9eda3bea5ba..9b6c448349ec 100644 --- a/x/params/types/proposal/codec.go +++ b/x/params/types/proposal/codec.go @@ -1,10 +1,10 @@ package proposal import ( + "cosmossdk.io/core/registry" govtypes "cosmossdk.io/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" ) // RegisterLegacyAminoCodec registers all necessary param module types with a given LegacyAmino codec. @@ -12,7 +12,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) } -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations( (*govtypes.Content)(nil), &ParameterChangeProposal{}, diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index f7aeeca28ca6..34f384922924 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -17,6 +17,7 @@ import ( "cosmossdk.io/x/params/types" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) @@ -38,7 +39,7 @@ func (suite *SubspaceTestSuite) SetupTest() { ms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db) suite.NoError(ms.LoadLatestVersion()) - encodingConfig := moduletestutil.MakeTestEncodingConfig(paramsmodule.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, paramsmodule.AppModule{}) suite.cdc = encodingConfig.Codec suite.amino = encodingConfig.Amino diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index 2401090e1a1e..25300183f94d 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -147,13 +147,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/protocolpool/go.sum b/x/protocolpool/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/protocolpool/go.sum +++ b/x/protocolpool/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/protocolpool/keeper/keeper_test.go b/x/protocolpool/keeper/keeper_test.go index 30df28d01a3c..fec0abd80cbc 100644 --- a/x/protocolpool/keeper/keeper_test.go +++ b/x/protocolpool/keeper/keeper_test.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -50,7 +51,7 @@ func (s *KeeperTestSuite) SetupTest() { environment := runtime.NewEnvironment(storeService, log.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) - encCfg := moduletestutil.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) // gomock initializations ctrl := gomock.NewController(s.T()) diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index 0257e69960eb..03c56baed7ac 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -9,12 +9,12 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -22,13 +22,13 @@ import ( const ConsensusVersion = 1 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModule = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModule = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasServices = AppModule{} @@ -71,7 +71,7 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } // RegisterInterfaces registers interfaces and implementations of the bank module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/protocolpool/types/codec.go b/x/protocolpool/types/codec.go index 30bef81c2f8d..71baad73ec06 100644 --- a/x/protocolpool/types/codec.go +++ b/x/protocolpool/types/codec.go @@ -1,12 +1,13 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/types" + "cosmossdk.io/core/registry" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgFundCommunityPool{}, diff --git a/x/slashing/go.mod b/x/slashing/go.mod index 793d3e43b6f1..7f3bd71aa9a0 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -148,13 +148,13 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/slashing/go.sum b/x/slashing/go.sum index ffa9d4eee03a..815ad1a6e3e7 100644 --- a/x/slashing/go.sum +++ b/x/slashing/go.sum @@ -749,8 +749,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -868,12 +868,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/slashing/keeper/keeper_test.go b/x/slashing/keeper/keeper_test.go index 9e22a710e5e0..b78f42b8dc96 100644 --- a/x/slashing/keeper/keeper_test.go +++ b/x/slashing/keeper/keeper_test.go @@ -20,6 +20,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" sdktestutil "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -48,7 +49,7 @@ func (s *KeeperTestSuite) SetupTest() { env := runtime.NewEnvironment(storeService, log.NewNopLogger()) testCtx := sdktestutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now().Round(0).UTC()}) - encCfg := moduletestutil.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) // gomock initializations ctrl := gomock.NewController(s.T()) diff --git a/x/slashing/migrations/v4/migrate_test.go b/x/slashing/migrations/v4/migrate_test.go index de31d92e3e5e..41d8995af6e4 100644 --- a/x/slashing/migrations/v4/migrate_test.go +++ b/x/slashing/migrations/v4/migrate_test.go @@ -12,6 +12,7 @@ import ( v4 "cosmossdk.io/x/slashing/migrations/v4" slashingtypes "cosmossdk.io/x/slashing/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" @@ -20,7 +21,7 @@ import ( var consAddr = sdk.ConsAddress(sdk.AccAddress([]byte("addr1_______________"))) func TestMigrate(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig(slashing.AppModule{}).Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, slashing.AppModule{}).Codec storeKey := storetypes.NewKVStoreKey(slashingtypes.ModuleName) tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) diff --git a/x/slashing/module.go b/x/slashing/module.go index cdadc1b03202..6c78a386166d 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/simulation" "cosmossdk.io/x/slashing/types" @@ -24,12 +25,12 @@ import ( const ConsensusVersion = 4 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.AppModuleSimulation = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -81,7 +82,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the module's interface types -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index d786b64de306..50d9887a491d 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/x/slashing/types" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" @@ -24,7 +25,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - encodingConfig := moduletestutil.MakeTestEncodingConfig(slashing.AppModule{}) + encodingConfig := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, slashing.AppModule{}) cdc := encodingConfig.Codec dec := simulation.NewDecodeStore(cdc) diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 4b494a79eba9..ed8838609b09 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -1,9 +1,10 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -16,7 +17,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the Interface Registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUnjail{}, &MsgUpdateParams{}, diff --git a/x/staking/client/cli/tx_test.go b/x/staking/client/cli/tx_test.go index 10edb4c1344c..39d8957bc640 100644 --- a/x/staking/client/cli/tx_test.go +++ b/x/staking/client/cli/tx_test.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -44,7 +45,7 @@ func TestCLITestSuite(t *testing.T) { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = testutilmod.MakeTestEncodingConfig(staking.AppModule{}) + s.encCfg = testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, staking.AppModule{}) s.kr = keyring.NewInMemory(s.encCfg.Codec) s.baseCtx = client.Context{}. WithKeyring(s.kr). diff --git a/x/staking/go.mod b/x/staking/go.mod index 0ed29e490e8e..c9b4fed66756 100644 --- a/x/staking/go.mod +++ b/x/staking/go.mod @@ -147,12 +147,12 @@ require ( gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/x/staking/go.sum b/x/staking/go.sum index a82e64689883..3fd57a0055b6 100644 --- a/x/staking/go.sum +++ b/x/staking/go.sum @@ -747,8 +747,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= @@ -866,12 +866,12 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index 16b87cbbeec1..de6cfe138b5f 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" @@ -58,7 +59,7 @@ func (s *KeeperTestSuite) SetupTest() { testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.key = key ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) - encCfg := moduletestutil.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) s.cdc = encCfg.Codec ctrl := gomock.NewController(s.T()) diff --git a/x/staking/migrations/v5/migrations_test.go b/x/staking/migrations/v5/migrations_test.go index 1f731415f342..07e19b3fcb8e 100644 --- a/x/staking/migrations/v5/migrations_test.go +++ b/x/staking/migrations/v5/migrations_test.go @@ -18,6 +18,7 @@ import ( stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/codec" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -50,7 +51,7 @@ func TestHistoricalKeysMigration(t *testing.T) { testCases[int64(height)] = testCase{} } - cdc := moduletestutil.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec for height := range testCases { testCases[height] = testCase{ oldKey: v5.GetLegacyHistoricalInfoKey(height), @@ -80,7 +81,7 @@ func createHistoricalInfo(height int64, chainID string) *stakingtypes.Historical } func TestDelegationsByValidatorMigrations(t *testing.T) { - cdc := moduletestutil.MakeTestEncodingConfig(staking.AppModule{}).Codec + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, staking.AppModule{}).Codec storeKey := storetypes.NewKVStoreKey(v5.ModuleName) tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) diff --git a/x/staking/module.go b/x/staking/module.go index 46d3875dd3f8..d3d28ce25043 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -11,6 +11,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/depinject" "cosmossdk.io/x/staking/client/cli" "cosmossdk.io/x/staking/keeper" @@ -18,7 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -28,14 +28,14 @@ const ( ) var ( - _ module.AppModuleSimulation = AppModule{} - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.HasInvariants = AppModule{} - _ module.HasABCIGenesis = AppModule{} - _ module.HasABCIEndBlock = AppModule{} + _ module.AppModuleSimulation = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.HasInvariants = AppModule{} + _ module.HasABCIGenesis = AppModule{} + _ module.HasABCIEndBlock = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -82,7 +82,7 @@ func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the module's interface types -func (AppModule) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index 308d054220bb..897219b86cce 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/x/staking/simulation" "cosmossdk.io/x/staking/types" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" @@ -22,7 +23,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := testutil.MakeTestEncodingConfig().Codec + cdc := testutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec dec := simulation.NewDecodeStore(cdc) oneIntBz, err := math.OneInt().Marshal() diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 9f3bec47a742..7c019f3b5c3e 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -1,9 +1,10 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -28,7 +29,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the x/staking interfaces types with the interface registry -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateValidator{}, &MsgEditValidator{}, diff --git a/x/tx/CHANGELOG.md b/x/tx/CHANGELOG.md index bb5705875b16..4d475d2c64d0 100644 --- a/x/tx/CHANGELOG.md +++ b/x/tx/CHANGELOG.md @@ -31,14 +31,20 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] -### Bug Fixes +## v0.13.1 -* [#19265](https://github.com/cosmos/cosmos-sdk/pull/19265) Reject denoms that contain a comma. +### Features + +* [#19618](https://github.com/cosmos/cosmos-sdk/pull/19618) Add enum as string option to encoder. ### Improvements * [#18857](https://github.com/cosmos/cosmos-sdk/pull/18857) Moved `FormatCoins` from `core/coins` to this package under `signing/textual`. +### Bug Fixes + +* [#19265](https://github.com/cosmos/cosmos-sdk/pull/19265) Reject denoms that contain a comma. + ## v0.13.0 ### Improvements @@ -107,18 +113,18 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * [#15871](https://github.com/cosmos/cosmos-sdk/pull/15871) - * `HandlerMap` now has a `DefaultMode()` getter method - * Textual types use `signing.ProtoFileResolver` instead of `protoregistry.Files` + * `HandlerMap` now has a `DefaultMode()` getter method + * Textual types use `signing.ProtoFileResolver` instead of `protoregistry.Files` ## v0.6.0 ### API Breaking * [#15709](https://github.com/cosmos/cosmos-sdk/pull/15709): - * `GetSignersContext` has been renamed to `signing.Context` - * `GetSigners` now returns `[][]byte` instead of `[]string` - * `GetSignersOptions` has been renamed to `signing.Options` and requires `address.Codec`s for account and validator addresses - * `GetSignersOptions.ProtoFiles` has been renamed to `signing.Options.FileResolver` + * `GetSignersContext` has been renamed to `signing.Context` + * `GetSigners` now returns `[][]byte` instead of `[]string` + * `GetSignersOptions` has been renamed to `signing.Options` and requires `address.Codec`s for account and validator addresses + * `GetSignersOptions.ProtoFiles` has been renamed to `signing.Options.FileResolver` ### Bug Fixes diff --git a/x/tx/go.mod b/x/tx/go.mod index 969b7b360261..b6841dc64c4c 100644 --- a/x/tx/go.mod +++ b/x/tx/go.mod @@ -21,8 +21,6 @@ require ( ) require ( - buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20230509103710-5e5b9fdd0180.1 // indirect - buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -37,4 +35,6 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace cosmossdk.io/api => ../../api +// NOTE: we do not want to replace to the development version of cosmossdk.io/api yet +// Until https://github.com/cosmos/cosmos-sdk/issues/19228 is resolved +// We are tagging x/tx from main and must keep using released versions of x/tx dependencies diff --git a/x/tx/go.sum b/x/tx/go.sum index 5065aad27c35..68c6a1e7ee63 100644 --- a/x/tx/go.sum +++ b/x/tx/go.sum @@ -1,7 +1,5 @@ -buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20230509103710-5e5b9fdd0180.1 h1:7LKjxs607BNfGhtKLf+bi3SDJgpiGuTgOvemojsH8Hc= -buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20230509103710-5e5b9fdd0180.1/go.mod h1:5GqIYthcy/ASmnKcaT26APpxMhZirnIHXHKki69zjWI= -buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 h1:VooqQ3rklp3PwMTAE890M76w/8Z01OPa7RdgU9posFE= -buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1/go.mod h1:9KmeMJUsSG3IiIwK63Lh1ipZJrwd7KHrWZseJeHukcs= +cosmossdk.io/api v0.7.3 h1:V815i8YOwOAQa1rLCsSMjVG5Gnzs02JLq+l7ks8s1jk= +cosmossdk.io/api v0.7.3/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= diff --git a/x/tx/signing/aminojson/aminojson.go b/x/tx/signing/aminojson/aminojson.go index 331087ed548e..5b0d9e4d0547 100644 --- a/x/tx/signing/aminojson/aminojson.go +++ b/x/tx/signing/aminojson/aminojson.go @@ -44,6 +44,7 @@ func NewSignModeHandler(options SignModeHandlerOptions) *SignModeHandler { h.encoder = NewEncoder(EncoderOptions{ FileResolver: options.FileResolver, TypeResolver: options.TypeResolver, + EnumAsString: false, // ensure enum as string is disabled }) } else { h.encoder = *options.Encoder diff --git a/x/tx/signing/aminojson/encoder.go b/x/tx/signing/aminojson/encoder.go index ddde5373b883..07a7c8ea0792 100644 --- a/x/tx/signing/aminojson/encoder.go +++ b/x/tx/signing/aminojson/encoder.go @@ -75,7 +75,7 @@ func nullSliceAsEmptyEncoder(enc *Encoder, v protoreflect.Value, w io.Writer) er _, err := io.WriteString(w, "[]") return err } - return enc.marshalList(list, w) + return enc.marshalList(list, nil /* no field descriptor available here */, w) default: return fmt.Errorf("unsupported type %T", list) } @@ -161,7 +161,7 @@ func thresholdStringEncoder(enc *Encoder, msg protoreflect.Message, w io.Writer) pubkeysField := fields.ByName("public_keys") pubkeys := msg.Get(pubkeysField).List() - err = enc.marshalList(pubkeys, w) + err = enc.marshalList(pubkeys, pubkeysField, w) if err != nil { return err } diff --git a/x/tx/signing/aminojson/json_marshal.go b/x/tx/signing/aminojson/json_marshal.go index aa8aa76b945e..800dfc7fd320 100644 --- a/x/tx/signing/aminojson/json_marshal.go +++ b/x/tx/signing/aminojson/json_marshal.go @@ -28,6 +28,9 @@ type EncoderOptions struct { Indent string // DoNotSortFields when set turns off sorting of field names. DoNotSortFields bool + // EnumAsString when set will encode enums as strings instead of integers. + // Caution: Enabling this option produce different sign bytes. + EnumAsString bool // TypeResolver is used to resolve protobuf message types by TypeURL when marshaling any packed messages. TypeResolver signing.TypeResolver // FileResolver is used to resolve protobuf file descriptors TypeURL when TypeResolver fails. @@ -45,6 +48,7 @@ type Encoder struct { typeResolver protoregistry.MessageTypeResolver doNotSortFields bool indent string + enumsAsString bool } // NewEncoder returns a new Encoder capable of serializing protobuf messages to JSON using the Amino JSON encoding @@ -78,6 +82,7 @@ func NewEncoder(options EncoderOptions) Encoder { typeResolver: options.TypeResolver, doNotSortFields: options.DoNotSortFields, indent: options.Indent, + enumsAsString: options.EnumAsString, } return enc } @@ -189,7 +194,7 @@ func (enc Encoder) beginMarshal(msg protoreflect.Message, writer io.Writer, isAn } } - err := enc.marshal(protoreflect.ValueOfMessage(msg), writer) + err := enc.marshal(protoreflect.ValueOfMessage(msg), nil /* no field descriptor needed here */, writer) if err != nil { return err } @@ -204,7 +209,7 @@ func (enc Encoder) beginMarshal(msg protoreflect.Message, writer io.Writer, isAn return nil } -func (enc Encoder) marshal(value protoreflect.Value, writer io.Writer) error { +func (enc Encoder) marshal(value protoreflect.Value, fd protoreflect.FieldDescriptor, writer io.Writer) error { switch val := value.Interface().(type) { case protoreflect.Message: err := enc.marshalMessage(val, writer) @@ -218,9 +223,20 @@ func (enc Encoder) marshal(value protoreflect.Value, writer io.Writer) error { _, err := io.WriteString(writer, "null") return err } - return enc.marshalList(val, writer) + return enc.marshalList(val, fd, writer) + + case string, bool, int32, uint32, []byte: + return jsonMarshal(writer, val) + + case protoreflect.EnumNumber: + if enc.enumsAsString && fd != nil { + desc := fd.Enum().Values().ByNumber(val) + if desc != nil { + _, err := io.WriteString(writer, fmt.Sprintf(`"%s"`, desc.Name())) + return err + } + } - case string, bool, int32, uint32, []byte, protoreflect.EnumNumber: return jsonMarshal(writer, val) case uint64, int64: @@ -342,7 +358,7 @@ func (enc Encoder) marshalMessage(msg protoreflect.Message, writer io.Writer) er return err } } else { - err = enc.marshal(v, writer) + err = enc.marshal(v, f, writer) if err != nil { return err } @@ -371,7 +387,7 @@ func jsonMarshal(w io.Writer, v interface{}) error { return err } -func (enc Encoder) marshalList(list protoreflect.List, writer io.Writer) error { +func (enc Encoder) marshalList(list protoreflect.List, fd protoreflect.FieldDescriptor, writer io.Writer) error { n := list.Len() _, err := io.WriteString(writer, "[") @@ -389,7 +405,7 @@ func (enc Encoder) marshalList(list protoreflect.List, writer io.Writer) error { } first = false - err = enc.marshal(list.Get(i), writer) + err = enc.marshal(list.Get(i), fd, writer) if err != nil { return err } diff --git a/x/tx/signing/aminojson/json_marshal_test.go b/x/tx/signing/aminojson/json_marshal_test.go index 7a2ff37c5c38..be8caf8c7364 100644 --- a/x/tx/signing/aminojson/json_marshal_test.go +++ b/x/tx/signing/aminojson/json_marshal_test.go @@ -268,3 +268,62 @@ func TestIndent(t *testing.T) { } }`, string(bz)) } + +func TestEnumAsString(t *testing.T) { + encoder := aminojson.NewEncoder(aminojson.EncoderOptions{Indent: " ", EnumAsString: true}) + + msg := &testpb.ABitOfEverything{ + Message: &testpb.NestedMessage{ + Foo: "test", + Bar: 0, // this is the default value and should be omitted from output + }, + Enum: testpb.AnEnum_ONE, + Repeated: []int32{3, -7, 2, 6, 4}, + Str: `abcxyz"foo"def`, + Bool: true, + Bytes: []byte{0, 1, 2, 3}, + I32: -15, + F32: 1001, + U32: 1200, + Si32: -376, + Sf32: -1000, + I64: 14578294827584932, + F64: 9572348124213523654, + U64: 4759492485, + Si64: -59268425823934, + Sf64: -659101379604211154, + } + + bz, err := encoder.Marshal(msg) + require.NoError(t, err) + fmt.Println(string(bz)) + require.Equal(t, `{ + "type": "ABitOfEverything", + "value": { + "bool": true, + "bytes": "AAECAw==", + "enum": "ONE", + "f32": 1001, + "f64": "9572348124213523654", + "i32": -15, + "i64": "14578294827584932", + "message": { + "foo": "test" + }, + "repeated": [ + 3, + -7, + 2, + 6, + 4 + ], + "sf32": -1000, + "sf64": "-659101379604211154", + "si32": -376, + "si64": "-59268425823934", + "str": "abcxyz\"foo\"def", + "u32": 1200, + "u64": "4759492485" + } +}`, string(bz)) +} diff --git a/x/tx/signing/textual/any.go b/x/tx/signing/textual/any.go index 5f187f303380..3770969dc580 100644 --- a/x/tx/signing/textual/any.go +++ b/x/tx/signing/textual/any.go @@ -83,7 +83,7 @@ func (ar anyValueRenderer) Parse(ctx context.Context, screens []Screen) (protore typeURL := screens[0].Content msgType, err := ar.tr.typeResolver.FindMessageByURL(typeURL) - if err == protoregistry.NotFound { + if errors.Is(err, protoregistry.NotFound) { // If the proto v2 registry doesn't have this message, then we use // protoFiles (which can e.g. be initialized to gogo's MergedRegistry) // to retrieve the message descriptor, and then use dynamicpb on that diff --git a/x/tx/signing/textual/internal/testdata/e2e.json b/x/tx/signing/textual/internal/testdata/e2e.json index aaf11f9428b8..2ab0e30f5b96 100644 --- a/x/tx/signing/textual/internal/testdata/e2e.json +++ b/x/tx/signing/textual/internal/testdata/e2e.json @@ -213,7 +213,7 @@ "@type": "/cosmos.gov.v1.MsgVote", "proposal_id": 1, "voter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", - "option": "VOTE_OPTION_ONE", + "option": "VOTE_OPTION_YES", "metadata": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @" } ], @@ -326,7 +326,7 @@ { "title": "Message (2/2)", "content": "/cosmos.gov.v1.MsgVote", "indent": 1 }, { "title": "Proposal id", "content": "1", "indent": 2 }, { "title": "Voter", "content": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 2 }, - { "title": "Option", "content": "VOTE_OPTION_ONE", "indent": 2 }, + { "title": "Option", "content": "VOTE_OPTION_YES", "indent": 2 }, { "title": "Metadata", "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @", @@ -374,6 +374,6 @@ { "content": "End of Non critical extension options", "expert": true }, { "title": "Hash of raw bytes", "content": "e7be7808de4985bd609811d2a32805cb233c168c7d247d61d37f4a6dd4cf3a2a", "expert": true } ], - "cbor": "a101983da20168436861696e20696402686d792d636861696ea2016e4163636f756e74206e756d626572026131a2016853657175656e6365026132a301674164647265737302782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e767161386579687304f5a3016a5075626c6963206b657902781f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657904f5a401634b657902785230324542204444374620453446442045423736204443384120323035452046363544203739304320443330452038413337203541354320323532382045423341203932334120463146422034443739203444030104f5a102781f54686973207472616e73616374696f6e206861732032204d65737361676573a3016d4d6573736167652028312f322902781d2f636f736d6f732e617574687a2e763162657461312e4d7367457865630301a301674772616e74656502782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730302a301644d73677302653120416e790302a3016a4d7367732028312f312902781c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e640303a3016c46726f6d206164647265737302782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730304a3016a546f206164647265737302782d636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b6835740304a30166416d6f756e74026731302041544f4d0304a2026b456e64206f66204d7367730302a3016d4d6573736167652028322f322902762f636f736d6f732e676f762e76312e4d7367566f74650301a3016b50726f706f73616c2069640261310302a30165566f74657202782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730302a301664f7074696f6e026f564f54455f4f5054494f4e5f4f4e450302a301684d65746164617461027901e34c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f726520657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c2071756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e69736920757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e2044756973206175746520697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c697420657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e204578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c2073756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e20416c736f20697420656e647320696e2020612073696e676c6520616d70657273616e6420400302a1026e456e64206f66204d657373616765a201644d656d6f0278193e20e29a9befb88f5c7532363942e29a9befb88f2020202020a2016446656573026a302e3030322041544f4da3016946656520706179657202782d636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b68357404f5a3016b466565206772616e74657202782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e767161386579687304f5a30169476173206c696d697402673130302730303004f5a3016e54696d656f7574206865696768740262323004f5a3016c4f74686572207369676e6572026c31205369676e6572496e666f04f5a401724f74686572207369676e65722028312f312902715369676e6572496e666f206f626a656374030104f5a4016a5075626c6963206b65790278292f636f736d6f732e63727970746f2e6d756c74697369672e4c6567616379416d696e6f5075624b6579030204f5a401695468726573686f6c64026132030304f5a4016b5075626c6963206b65797302653220416e79030304f5a401715075626c6963206b6579732028312f322902781f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b6579030404f5a401634b657902785230323537203445424520304246432037353446203539363720334241312031423237203530304620393135382041444532204531374520314130312038324230204341384220433635322034444230203933030504f5a401715075626c6963206b6579732028322f322902781d2f636f736d6f732e63727970746f2e656432353531392e5075624b6579030404f5a401634b657902785230333135203043343720463138412041333237203136413620353437452044413842203733363920303637442043453131204431343120363234352042373738203735364320463833352039363738203737030504f5a30272456e64206f66205075626c6963206b657973030304f5a401694d6f646520696e666f026f4d6f6465496e666f206f626a656374030204f5a401654d756c7469026c4d756c7469206f626a656374030304f5a4016842697461727261790276436f6d706163744269744172726179206f626a656374030404f5a40171457874726120626974732073746f726564026135030504f5a40165456c656d7302623438030504f5a4016a4d6f646520696e666f73026a32204d6f6465496e666f030404f5a401704d6f646520696e666f732028312f3229026f4d6f6465496e666f206f626a656374030504f5a4016653696e676c65026d53696e676c65206f626a656374030604f5a401644d6f646502781b5349474e5f4d4f44455f4c45474143595f414d494e4f5f4a534f4e030704f5a401704d6f646520696e666f732028322f3229026f4d6f6465496e666f206f626a656374030504f5a4016653696e676c65026d53696e676c65206f626a656374030604f5a401644d6f646502781b5349474e5f4d4f44455f4c45474143595f414d494e4f5f4a534f4e030704f5a30271456e64206f66204d6f646520696e666f73030404f5a4016853657175656e6365026135030204f5a20273456e64206f66204f74686572207369676e657204f5a30171457874656e73696f6e206f7074696f6e7302653120416e7904f5a40177457874656e73696f6e206f7074696f6e732028312f31290278192f636f736d6f732e626173652e763162657461312e436f696e030104f5a30266352041544f4d030204f5a2027818456e64206f6620457874656e73696f6e206f7074696f6e7304f5a301781e4e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e7302653120416e7904f5a40178244e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e732028312f312902781b2f636f736d6f732e617574682e763162657461312e506172616d73030104f5a401734d6178206d656d6f206368617261637465727302623130030204f5a2027825456e64206f66204e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e7304f5a3017148617368206f66207261772062797465730278406537626537383038646534393835626436303938313164326133323830356362323333633136386337643234376436316433376634613664643463663361326104f5" + "cbor": "a101983da20168436861696e20696402686d792d636861696ea2016e4163636f756e74206e756d626572026131a2016853657175656e6365026132a301674164647265737302782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e767161386579687304f5a3016a5075626c6963206b657902781f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657904f5a401634b657902785230324542204444374620453446442045423736204443384120323035452046363544203739304320443330452038413337203541354320323532382045423341203932334120463146422034443739203444030104f5a102781f54686973207472616e73616374696f6e206861732032204d65737361676573a3016d4d6573736167652028312f322902781d2f636f736d6f732e617574687a2e763162657461312e4d7367457865630301a301674772616e74656502782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730302a301644d73677302653120416e790302a3016a4d7367732028312f312902781c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e640303a3016c46726f6d206164647265737302782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730304a3016a546f206164647265737302782d636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b6835740304a30166416d6f756e74026731302041544f4d0304a2026b456e64206f66204d7367730302a3016d4d6573736167652028322f322902762f636f736d6f732e676f762e76312e4d7367566f74650301a3016b50726f706f73616c2069640261310302a30165566f74657202782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730302a301664f7074696f6e026f564f54455f4f5054494f4e5f5945530302a301684d65746164617461027901e34c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f726520657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c2071756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e69736920757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e2044756973206175746520697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c697420657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e204578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c2073756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e20416c736f20697420656e647320696e2020612073696e676c6520616d70657273616e6420400302a1026e456e64206f66204d657373616765a201644d656d6f0278193e20e29a9befb88f5c7532363942e29a9befb88f2020202020a2016446656573026a302e3030322041544f4da3016946656520706179657202782d636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b68357404f5a3016b466565206772616e74657202782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e767161386579687304f5a30169476173206c696d697402673130302730303004f5a3016e54696d656f7574206865696768740262323004f5a3016c4f74686572207369676e6572026c31205369676e6572496e666f04f5a401724f74686572207369676e65722028312f312902715369676e6572496e666f206f626a656374030104f5a4016a5075626c6963206b65790278292f636f736d6f732e63727970746f2e6d756c74697369672e4c6567616379416d696e6f5075624b6579030204f5a401695468726573686f6c64026132030304f5a4016b5075626c6963206b65797302653220416e79030304f5a401715075626c6963206b6579732028312f322902781f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b6579030404f5a401634b657902785230323537203445424520304246432037353446203539363720334241312031423237203530304620393135382041444532204531374520314130312038324230204341384220433635322034444230203933030504f5a401715075626c6963206b6579732028322f322902781d2f636f736d6f732e63727970746f2e656432353531392e5075624b6579030404f5a401634b657902785230333135203043343720463138412041333237203136413620353437452044413842203733363920303637442043453131204431343120363234352042373738203735364320463833352039363738203737030504f5a30272456e64206f66205075626c6963206b657973030304f5a401694d6f646520696e666f026f4d6f6465496e666f206f626a656374030204f5a401654d756c7469026c4d756c7469206f626a656374030304f5a4016842697461727261790276436f6d706163744269744172726179206f626a656374030404f5a40171457874726120626974732073746f726564026135030504f5a40165456c656d7302623438030504f5a4016a4d6f646520696e666f73026a32204d6f6465496e666f030404f5a401704d6f646520696e666f732028312f3229026f4d6f6465496e666f206f626a656374030504f5a4016653696e676c65026d53696e676c65206f626a656374030604f5a401644d6f646502781b5349474e5f4d4f44455f4c45474143595f414d494e4f5f4a534f4e030704f5a401704d6f646520696e666f732028322f3229026f4d6f6465496e666f206f626a656374030504f5a4016653696e676c65026d53696e676c65206f626a656374030604f5a401644d6f646502781b5349474e5f4d4f44455f4c45474143595f414d494e4f5f4a534f4e030704f5a30271456e64206f66204d6f646520696e666f73030404f5a4016853657175656e6365026135030204f5a20273456e64206f66204f74686572207369676e657204f5a30171457874656e73696f6e206f7074696f6e7302653120416e7904f5a40177457874656e73696f6e206f7074696f6e732028312f31290278192f636f736d6f732e626173652e763162657461312e436f696e030104f5a30266352041544f4d030204f5a2027818456e64206f6620457874656e73696f6e206f7074696f6e7304f5a301781e4e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e7302653120416e7904f5a40178244e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e732028312f312902781b2f636f736d6f732e617574682e763162657461312e506172616d73030104f5a401734d6178206d656d6f206368617261637465727302623130030204f5a2027825456e64206f66204e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e7304f5a3017148617368206f66207261772062797465730278406537626537383038646534393835626436303938313164326133323830356362323333633136386337643234376436316433376634613664643463663361326104f5" } ] diff --git a/x/tx/signing/textual/internal/testdata/tx.json b/x/tx/signing/textual/internal/testdata/tx.json index db7ea86eea75..bbafe3b14120 100644 --- a/x/tx/signing/textual/internal/testdata/tx.json +++ b/x/tx/signing/textual/internal/testdata/tx.json @@ -142,7 +142,7 @@ "@type": "/cosmos.gov.v1.MsgVote", "proposal_id": 1, "voter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", - "option": "VOTE_OPTION_ONE", + "option": "VOTE_OPTION_YES", "metadata": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @" } ] @@ -193,7 +193,7 @@ { "title": "Message (1/1)", "content": "/cosmos.gov.v1.MsgVote", "indent": 1 }, { "title": "Proposal id", "content": "1", "indent": 2 }, { "title": "Voter", "content": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 2 }, - { "title": "Option", "content": "VOTE_OPTION_ONE", "indent": 2 }, + { "title": "Option", "content": "VOTE_OPTION_YES", "indent": 2 }, { "title": "Metadata", "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @", @@ -226,7 +226,7 @@ "@type": "/cosmos.gov.v1.MsgVote", "proposal_id": 1, "voter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", - "option": "VOTE_OPTION_ONE", + "option": "VOTE_OPTION_YES", "metadata": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @" } ], @@ -339,7 +339,7 @@ { "title": "Message (2/2)", "content": "/cosmos.gov.v1.MsgVote", "indent": 1 }, { "title": "Proposal id", "content": "1", "indent": 2 }, { "title": "Voter", "content": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 2 }, - { "title": "Option", "content": "VOTE_OPTION_ONE", "indent": 2 }, + { "title": "Option", "content": "VOTE_OPTION_YES", "indent": 2 }, { "title": "Metadata", "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @", diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index 775ede36bb9e..6d56912b5ee4 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -176,14 +176,14 @@ require ( go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.20.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect diff --git a/x/upgrade/go.sum b/x/upgrade/go.sum index e5a75f8a242f..3d95da986863 100644 --- a/x/upgrade/go.sum +++ b/x/upgrade/go.sum @@ -1073,8 +1073,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1315,13 +1315,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/x/upgrade/keeper/abci_test.go b/x/upgrade/keeper/abci_test.go index e74005dd8949..831d39cf1957 100644 --- a/x/upgrade/keeper/abci_test.go +++ b/x/upgrade/keeper/abci_test.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -111,7 +112,7 @@ func (s *TestSuite) VerifySet(t *testing.T, skipUpgradeHeights map[int64]bool) { func setupTest(t *testing.T, height int64, skip map[int64]bool) *TestSuite { t.Helper() s := TestSuite{} - s.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModule{}) + s.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, upgrade.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) env := runtime.NewEnvironment(storeService, log.NewNopLogger()) @@ -458,7 +459,7 @@ func TestBinaryVersion(t *testing.T) { func TestDowngradeVerification(t *testing.T) { // could not use setupTest() here, because we have to use the same key // for the two keepers. - encCfg := moduletestutil.MakeTestEncodingConfig(upgrade.AppModule{}) + encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, upgrade.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) env := runtime.NewEnvironment(storeService, log.NewNopLogger()) diff --git a/x/upgrade/keeper/grpc_query_test.go b/x/upgrade/keeper/grpc_query_test.go index 2911f11380c7..c866df64e767 100644 --- a/x/upgrade/keeper/grpc_query_test.go +++ b/x/upgrade/keeper/grpc_query_test.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" @@ -35,7 +36,7 @@ type UpgradeTestSuite struct { } func (suite *UpgradeTestSuite) SetupTest() { - suite.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModule{}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, upgrade.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) env := runtime.NewEnvironment(storeService, log.NewNopLogger()) diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index 798c93d9ce99..f17d6ae870d8 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -43,7 +44,7 @@ type KeeperTestSuite struct { } func (s *KeeperTestSuite) SetupTest() { - s.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModule{}) + s.encCfg = moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, upgrade.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) env := runtime.NewEnvironment(storeService, log.NewNopLogger()) diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 7a609ae4b25a..7ddebb6bc1e8 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -10,13 +10,13 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/registry" "cosmossdk.io/x/upgrade/client/cli" "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -28,11 +28,11 @@ func init() { const ConsensusVersion uint64 = 3 var ( - _ module.HasName = AppModule{} - _ module.HasAminoCodec = AppModule{} - _ module.HasGRPCGateway = AppModule{} - _ module.HasRegisterInterfaces = AppModule{} - _ module.HasGenesis = AppModule{} + _ module.HasName = AppModule{} + _ module.HasAminoCodec = AppModule{} + _ module.HasGRPCGateway = AppModule{} + _ appmodule.HasRegisterInterfaces = AppModule{} + _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasPreBlocker = AppModule{} @@ -78,7 +78,7 @@ func (AppModule) GetTxCmd() *cobra.Command { } // RegisterInterfaces registers interfaces and implementations of the upgrade module. -func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +func (AppModule) RegisterInterfaces(registry registry.LegacyRegistry) { types.RegisterInterfaces(registry) } diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index 66ba3c2fe282..366bb3105b24 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -1,9 +1,10 @@ package types import ( + "cosmossdk.io/core/registry" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -18,7 +19,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } // RegisterInterfaces registers the interfaces types with the Interface Registry. -func RegisterInterfaces(registry types.InterfaceRegistry) { +func RegisterInterfaces(registry registry.LegacyRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSoftwareUpgrade{}, &MsgCancelUpgrade{},