diff --git a/CHANGELOG.md b/CHANGELOG.md index 20e5795ef9..2333287f5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,8 +101,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes +* (types) [#19792](https://github.com/cosmos/cosmos-sdk/pull/19792) In `MsgSimulatorFn` `sdk.Context` argument is replaced for an `address.Codec`. It also returns an error. * (types) [#19742](https://github.com/cosmos/cosmos-sdk/pull/19742) Removes the use of `Accounts.String` - * `MsgSimulatorFn` now takes an `address.Codec` as argument and also returns an error. * `SimulationState` now has address and validator codecs as fields. * (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`). diff --git a/UPGRADING.md b/UPGRADING.md index a1a6bc8ce2..672bc04688 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -147,12 +147,12 @@ If you were depending on `cosmossdk.io/api/tendermint`, please use the buf gener ##### Simulation -As an effort to remove the use of the global config, `sdk.Address.String` method must be removed. As a consequence, `MsgSimulatorFn` has been updated to return an error and use an `address.Codec` to set -`staking.MsgUpdateParams.Authority`. +`MsgSimulatorFn` has been updated to return an error. Its context argument has been removed, and an address.Codec has +been added to avoid the use of the Accounts.String() method. ```diff -type MsgSimulatorFn func(r *rand.Rand, ctx sdk.Context, accs []Account) sdk.Msg -+type MsgSimulatorFn func(r *rand.Rand, ctx sdk.Context, accs []Account, cdc address.Codec) (sdk.Msg, error) ++type MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) ``` ##### Core API diff --git a/store/root/reader.go b/store/root/reader.go index 51d798ba75..0bb63db36f 100644 --- a/store/root/reader.go +++ b/store/root/reader.go @@ -2,12 +2,13 @@ package root import ( corestore "cosmossdk.io/core/store" - "cosmossdk.io/store/v2" ) -var _ corestore.Reader = (*Reader)(nil) -var _ corestore.ReaderMap = (*ReaderMap)(nil) +var ( + _ corestore.Reader = (*Reader)(nil) + _ corestore.ReaderMap = (*ReaderMap)(nil) +) // ReaderMap defines an adapter around a RootStore that only exposes read-only // operations. This is useful for exposing a read-only view of the RootStore at diff --git a/tests/sims/gov/operations_test.go b/tests/sims/gov/operations_test.go index 972aedec60..581b663746 100644 --- a/tests/sims/gov/operations_test.go +++ b/tests/sims/gov/operations_test.go @@ -56,7 +56,7 @@ func (m MockWeightedProposals) DefaultWeight() int { } func (m MockWeightedProposals) MsgSimulatorFn() simtypes.MsgSimulatorFn { - return func(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { + return func(r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { return nil, nil } } diff --git a/types/simulation/types.go b/types/simulation/types.go index 15bcb2bef1..da9c67332f 100644 --- a/types/simulation/types.go +++ b/types/simulation/types.go @@ -41,7 +41,7 @@ type WeightedProposalMsg interface { MsgSimulatorFn() MsgSimulatorFn // msg simulator function } -type MsgSimulatorFn func(r *rand.Rand, ctx sdk.Context, accs []Account, cdc address.Codec) (sdk.Msg, error) +type MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) type SimValFn func(r *rand.Rand) string diff --git a/x/accounts/defaults/lockup/types/encoding.go b/x/accounts/defaults/lockup/types/encoding.go index e4aff1f1da..ec41739a09 100644 --- a/x/accounts/defaults/lockup/types/encoding.go +++ b/x/accounts/defaults/lockup/types/encoding.go @@ -5,8 +5,9 @@ import ( "reflect" "strings" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" proto "github.com/cosmos/gogoproto/proto" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) func UnpackAnyRaw(m *codectypes.Any) (proto.Message, error) { diff --git a/x/auth/simulation/proposals.go b/x/auth/simulation/proposals.go index 148753163a..244acb1975 100644 --- a/x/auth/simulation/proposals.go +++ b/x/auth/simulation/proposals.go @@ -31,7 +31,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/auth/simulation/proposals_test.go b/x/auth/simulation/proposals_test.go index 6a1168afd5..bbe53b58ef 100644 --- a/x/auth/simulation/proposals_test.go +++ b/x/auth/simulation/proposals_test.go @@ -20,7 +20,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalMsgs function @@ -33,7 +32,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/bank/simulation/proposals.go b/x/bank/simulation/proposals.go index 18340ded35..6672be0dc2 100644 --- a/x/bank/simulation/proposals.go +++ b/x/bank/simulation/proposals.go @@ -31,7 +31,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/bank/simulation/proposals_test.go b/x/bank/simulation/proposals_test.go index 479d55488e..db035620a8 100644 --- a/x/bank/simulation/proposals_test.go +++ b/x/bank/simulation/proposals_test.go @@ -20,7 +20,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalMsgs function @@ -33,7 +32,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/distribution/simulation/proposals.go b/x/distribution/simulation/proposals.go index fadbf3bb93..d8559fb747 100644 --- a/x/distribution/simulation/proposals.go +++ b/x/distribution/simulation/proposals.go @@ -32,7 +32,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/distribution/simulation/proposals_test.go b/x/distribution/simulation/proposals_test.go index cd9a4b81b3..2af78c81e3 100644 --- a/x/distribution/simulation/proposals_test.go +++ b/x/distribution/simulation/proposals_test.go @@ -21,7 +21,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalMsgs function @@ -34,7 +33,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 352ce95202..749106a582 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -155,7 +155,7 @@ func SimulateMsgSubmitProposal( return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgs := []sdk.Msg{} - proposalMsg, err := msgSim(r, ctx, accs, ak.AddressCodec()) + proposalMsg, err := msgSim(r, accs, ak.AddressCodec()) if err != nil { return simtypes.OperationMsg{}, nil, err } diff --git a/x/gov/simulation/proposals.go b/x/gov/simulation/proposals.go index 91b5d67e7b..bc508cce4e 100644 --- a/x/gov/simulation/proposals.go +++ b/x/gov/simulation/proposals.go @@ -27,7 +27,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { // SimulateTextProposal returns a random text proposal content. // A text proposal is a proposal that contains no msgs. -func SimulateTextProposal(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateTextProposal(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { return nil, nil } diff --git a/x/gov/simulation/proposals_test.go b/x/gov/simulation/proposals_test.go index 42ef52a7db..41a4068e7b 100644 --- a/x/gov/simulation/proposals_test.go +++ b/x/gov/simulation/proposals_test.go @@ -18,7 +18,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalMsgs function @@ -31,7 +30,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightSubmitTextProposal, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightTextProposal, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) assert.Assert(t, msg == nil) } diff --git a/x/mint/simulation/proposals.go b/x/mint/simulation/proposals.go index 9ba75b4a66..e1d5471bf9 100644 --- a/x/mint/simulation/proposals.go +++ b/x/mint/simulation/proposals.go @@ -32,7 +32,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/mint/simulation/proposals_test.go b/x/mint/simulation/proposals_test.go index 42d604b3e0..2f7ee4f854 100644 --- a/x/mint/simulation/proposals_test.go +++ b/x/mint/simulation/proposals_test.go @@ -21,7 +21,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalMsgs function @@ -34,7 +33,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/protocolpool/simulation/proposals.go b/x/protocolpool/simulation/proposals.go index 224a9f8fb5..8559a1095a 100644 --- a/x/protocolpool/simulation/proposals.go +++ b/x/protocolpool/simulation/proposals.go @@ -28,7 +28,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } } -func SimulateMsgCommunityPoolSpend(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgCommunityPoolSpend(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/protocolpool/simulation/proposals_test.go b/x/protocolpool/simulation/proposals_test.go index 4cef1da31b..6823a9957e 100644 --- a/x/protocolpool/simulation/proposals_test.go +++ b/x/protocolpool/simulation/proposals_test.go @@ -20,7 +20,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalMsgs function @@ -33,7 +32,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgCommunityPoolSpend, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgCommunityPoolSpend, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgCommunityPoolSpend, ok := msg.(*pooltypes.MsgCommunityPoolSpend) assert.Assert(t, ok) diff --git a/x/slashing/simulation/proposals.go b/x/slashing/simulation/proposals.go index 1a6e60f012..5d37412ad8 100644 --- a/x/slashing/simulation/proposals.go +++ b/x/slashing/simulation/proposals.go @@ -33,7 +33,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/slashing/simulation/proposals_test.go b/x/slashing/simulation/proposals_test.go index eb63a817ac..6a67de33fd 100644 --- a/x/slashing/simulation/proposals_test.go +++ b/x/slashing/simulation/proposals_test.go @@ -22,7 +22,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) // execute ProposalMsgs function @@ -35,7 +34,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/staking/simulation/proposals.go b/x/staking/simulation/proposals.go index 9a74e2509b..000984b46c 100644 --- a/x/staking/simulation/proposals.go +++ b/x/staking/simulation/proposals.go @@ -33,7 +33,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account, addressCodec coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, addressCodec coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/staking/simulation/proposals_test.go b/x/staking/simulation/proposals_test.go index 359a218b48..64eb447a85 100644 --- a/x/staking/simulation/proposals_test.go +++ b/x/staking/simulation/proposals_test.go @@ -12,7 +12,6 @@ import ( "cosmossdk.io/x/staking/types" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -22,7 +21,6 @@ func TestProposalMsgs(t *testing.T) { s := rand.NewSource(1) r := rand.New(s) - ctx := sdk.NewContext(nil, true, nil) accounts := simtypes.RandomAccounts(r, 3) addressCodec := codectestutil.CodecOptions{}.GetAddressCodec() // execute ProposalMsgs function @@ -35,7 +33,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, ctx, accounts, addressCodec) + msg, err := w0.MsgSimulatorFn()(r, accounts, addressCodec) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok)