diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ae2ddf904c0d..9a5564e09a57d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,6 +162,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ All implementations of `InterfaceRegistry` by other users must now embed the official implementation. * `AminoCodec` is marked as deprecated. * (x/crisis) [#15852](https://github.com/cosmos/cosmos-sdk/pull/15852) Crisis keeper now takes a instance of the address codec to be able to decode user addresses +* (x/slashing) [#15875](https://github.com/cosmos/cosmos-sdk/pull/15875) `x/slashing.NewAppModule` now requires an `InterfaceRegistry` parameter. ### Client Breaking Changes diff --git a/simapp/app.go b/simapp/app.go index 0a34c622dd772..e11defc2d9cf6 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -395,7 +395,7 @@ func NewSimApp( feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.GetAddressCodec()), diff --git a/testutil/sims/simulation_helpers.go b/testutil/sims/simulation_helpers.go index 1fdf87eb1cd08..72bbde88a9051 100644 --- a/testutil/sims/simulation_helpers.go +++ b/testutil/sims/simulation_helpers.go @@ -16,6 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/types/module" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -53,6 +54,7 @@ func SimulationOperations(app runtime.AppI, cdc codec.JSONCodec, config simtypes simState := module.SimulationState{ AppParams: make(simtypes.AppParams), Cdc: cdc, + TxConfig: moduletestutil.MakeTestTxConfig(), BondDenom: sdk.DefaultBondDenom, } diff --git a/types/module/simulation.go b/types/module/simulation.go index 00d0d00dd017e..79ac42c99d3a1 100644 --- a/types/module/simulation.go +++ b/types/module/simulation.go @@ -7,6 +7,7 @@ import ( "time" sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -142,6 +143,7 @@ func (sm *SimulationManager) WeightedOperations(simState SimulationState) []simu type SimulationState struct { AppParams simulation.AppParams Cdc codec.JSONCodec // application codec + TxConfig client.TxConfig // Shared TxConfig; this is expensive to create and stateless, so create it once up front. Rand *rand.Rand // random number GenState map[string]json.RawMessage // genesis state Accounts []simulation.Account // simulation accounts diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 9bf6cd170502f..a6cc28efb96bf 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -212,7 +212,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( am.registry, - simState.AppParams, simState.Cdc, + simState.AppParams, simState.Cdc, simState.TxConfig, am.accountKeeper, am.bankKeeper, am.keeper, ) } diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 6cb1f39b887e9..5375970760eb6 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -5,13 +5,13 @@ import ( "time" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/authz" "github.com/cosmos/cosmos-sdk/x/authz/keeper" banktype "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -44,6 +44,7 @@ func WeightedOperations( registry cdctypes.InterfaceRegistry, appParams simtypes.AppParams, cdc codec.JSONCodec, + txGen client.TxConfig, ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper, @@ -72,24 +73,32 @@ func WeightedOperations( }, ) + pCdc := codec.NewProtoCodec(registry) + return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgGrant, - SimulateMsgGrant(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgGrant(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightExec, - SimulateMsgExec(codec.NewProtoCodec(registry), ak, bk, k, registry), + SimulateMsgExec(pCdc, txGen, ak, bk, k, registry), ), simulation.NewWeightedOperation( weightRevoke, - SimulateMsgRevoke(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgRevoke(pCdc, txGen, ak, bk, k), ), } } // SimulateMsgGrant generates a MsgGrant with random values. -func SimulateMsgGrant(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.BankKeeper, _ keeper.Keeper) simtypes.Operation { +func SimulateMsgGrant( + cdc *codec.ProtoCodec, + txCfg client.TxConfig, + ak authz.AccountKeeper, + bk authz.BankKeeper, + _ keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -123,7 +132,6 @@ func SimulateMsgGrant(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.Ba if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err } - txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txCfg, @@ -157,7 +165,13 @@ func generateRandomAuthorization(r *rand.Rand, spendLimit sdk.Coins) authz.Autho } // SimulateMsgRevoke generates a MsgRevoke with random values. -func SimulateMsgRevoke(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper) simtypes.Operation { +func SimulateMsgRevoke( + cdc *codec.ProtoCodec, + txCfg client.TxConfig, + ak authz.AccountKeeper, + bk authz.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -194,7 +208,6 @@ func SimulateMsgRevoke(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.B } msg := authz.NewMsgRevoke(granterAddr, granteeAddr, a.MsgTypeURL()) - txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) account := ak.GetAccount(ctx, granterAddr) tx, err := simtestutil.GenSignedMockTx( r, @@ -221,7 +234,14 @@ func SimulateMsgRevoke(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.B } // SimulateMsgExec generates a MsgExec with random values. -func SimulateMsgExec(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper, unpacker cdctypes.AnyUnpacker) simtypes.Operation { +func SimulateMsgExec( + cdc *codec.ProtoCodec, + txCfg client.TxConfig, + ak authz.AccountKeeper, + bk authz.BankKeeper, + k keeper.Keeper, + unpacker cdctypes.AnyUnpacker, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -288,7 +308,6 @@ func SimulateMsgExec(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.Ban return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "fee error"), nil, err } - txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) granteeAcc := ak.GetAccount(ctx, granteeAddr) tx, err := simtestutil.GenSignedMockTx( r, diff --git a/x/authz/simulation/operations_test.go b/x/authz/simulation/operations_test.go index 3a5ec4c9380da..7e298fb93cebd 100644 --- a/x/authz/simulation/operations_test.go +++ b/x/authz/simulation/operations_test.go @@ -9,6 +9,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/suite" + "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/runtime" @@ -34,6 +35,7 @@ type SimTestSuite struct { legacyAmino *codec.LegacyAmino codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry + txConfig client.TxConfig accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper authzKeeper authzkeeper.Keeper @@ -45,6 +47,7 @@ func (suite *SimTestSuite) SetupTest() { &suite.legacyAmino, &suite.codec, &suite.interfaceRegistry, + &suite.txConfig, &suite.accountKeeper, &suite.bankKeeper, &suite.authzKeeper, @@ -58,7 +61,7 @@ func (suite *SimTestSuite) TestWeightedOperations() { cdc := suite.codec appParams := make(simtypes.AppParams) - weightedOps := simulation.WeightedOperations(suite.interfaceRegistry, appParams, cdc, suite.accountKeeper, + weightedOps := simulation.WeightedOperations(suite.interfaceRegistry, appParams, cdc, suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.authzKeeper) s := rand.NewSource(3) @@ -125,7 +128,7 @@ func (suite *SimTestSuite) TestSimulateGrant() { grantee := accounts[1] // execute operation - op := simulation.SimulateMsgGrant(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.authzKeeper) + op := simulation.SimulateMsgGrant(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.authzKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, ctx, accounts, "") suite.Require().NoError(err) @@ -163,7 +166,7 @@ func (suite *SimTestSuite) TestSimulateRevoke() { suite.Require().NoError(err) // execute operation - op := simulation.SimulateMsgRevoke(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.authzKeeper) + op := simulation.SimulateMsgRevoke(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.authzKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -198,7 +201,7 @@ func (suite *SimTestSuite) TestSimulateExec() { suite.Require().NoError(err) // execute operation - op := simulation.SimulateMsgExec(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.authzKeeper, suite.codec) + op := simulation.SimulateMsgExec(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.authzKeeper, suite.codec) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) diff --git a/x/bank/module.go b/x/bank/module.go index adfea3c183d9c..e892e95cd8197 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -194,7 +194,7 @@ func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} // WeightedOperations returns the all the gov module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, am.accountKeeper, am.keeper, + simState.AppParams, simState.Cdc, simState.TxConfig, am.accountKeeper, am.keeper, ) } diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 4251f2e89a5a4..f2c00d9170dda 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -4,11 +4,11 @@ import ( "math/rand" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -26,7 +26,11 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk keeper.Keeper, + appParams simtypes.AppParams, + cdc codec.JSONCodec, + txGen client.TxConfig, + ak types.AccountKeeper, + bk keeper.Keeper, ) simulation.WeightedOperations { var weightMsgSend, weightMsgMultiSend int appParams.GetOrGenerate(cdc, OpWeightMsgSend, &weightMsgSend, nil, @@ -44,18 +48,22 @@ func WeightedOperations( return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgSend, - SimulateMsgSend(ak, bk), + SimulateMsgSend(txGen, ak, bk), ), simulation.NewWeightedOperation( weightMsgMultiSend, - SimulateMsgMultiSend(ak, bk), + SimulateMsgMultiSend(txGen, ak, bk), ), } } // SimulateMsgSend tests and runs a single msg send where both // accounts already exist. -func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operation { +func SimulateMsgSend( + txGen client.TxConfig, + ak types.AccountKeeper, + bk keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -79,7 +87,7 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio msg := types.NewMsgSend(from.Address, to.Address, coins) - err := sendMsgSend(r, app, bk, ak, msg, ctx, chainID, []cryptotypes.PrivKey{from.PrivKey}) + err := sendMsgSend(r, app, txGen, bk, ak, msg, ctx, chainID, []cryptotypes.PrivKey{from.PrivKey}) if err != nil { return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "invalid transfers"), nil, err } @@ -90,7 +98,12 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio // SimulateMsgSendToModuleAccount tests and runs a single msg send where both // accounts already exist. -func SimulateMsgSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keeper, moduleAccCount int) simtypes.Operation { +func SimulateMsgSendToModuleAccount( + txGen client.TxConfig, + ak types.AccountKeeper, + bk keeper.Keeper, + moduleAccCount int, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -113,7 +126,7 @@ func SimulateMsgSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keeper, mo msg := types.NewMsgSend(from.Address, to.Address, coins) - err := sendMsgSend(r, app, bk, ak, msg, ctx, chainID, []cryptotypes.PrivKey{from.PrivKey}) + err := sendMsgSend(r, app, txGen, bk, ak, msg, ctx, chainID, []cryptotypes.PrivKey{from.PrivKey}) if err != nil { return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "invalid transfers"), nil, err } @@ -124,7 +137,9 @@ func SimulateMsgSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keeper, mo // sendMsgSend sends a transaction with a MsgSend from a provided random account. func sendMsgSend( - r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, + r *rand.Rand, app *baseapp.BaseApp, + txGen client.TxConfig, + bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { var ( @@ -147,7 +162,6 @@ func sendMsgSend( return err } } - txGen := moduletestutil.MakeTestTxConfig() tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -173,7 +187,7 @@ func sendMsgSend( // SimulateMsgMultiSend tests and runs a single msg multisend, with randomized, capped number of inputs/outputs. // all accounts in msg fields exist in state -func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operation { +func SimulateMsgMultiSend(txGen client.TxConfig, ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -253,7 +267,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope Inputs: inputs, Outputs: outputs, } - err := sendMsgMultiSend(r, app, bk, ak, msg, ctx, chainID, privs) + err := sendMsgMultiSend(r, app, txGen, bk, ak, msg, ctx, chainID, privs) if err != nil { return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "invalid transfers"), nil, err } @@ -263,7 +277,12 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope } // SimulateMsgMultiSendToModuleAccount sends coins to Module Accounts -func SimulateMsgMultiSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keeper, moduleAccCount int) simtypes.Operation { +func SimulateMsgMultiSendToModuleAccount( + txGen client.TxConfig, + ak types.AccountKeeper, + bk keeper.Keeper, + moduleAccCount int, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -313,7 +332,7 @@ func SimulateMsgMultiSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keepe Inputs: inputs, Outputs: outputs, } - err := sendMsgMultiSend(r, app, bk, ak, msg, ctx, chainID, privs) + err := sendMsgMultiSend(r, app, txGen, bk, ak, msg, ctx, chainID, privs) if err != nil { return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "invalid transfers"), nil, err } @@ -324,7 +343,9 @@ func SimulateMsgMultiSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keepe // sendMsgMultiSend sends a transaction with a MsgMultiSend from a provided random // account. func sendMsgMultiSend( - r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, + r *rand.Rand, app *baseapp.BaseApp, + txGen client.TxConfig, + bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { accountNumbers := make([]uint64, len(msg.Inputs)) @@ -350,7 +371,6 @@ func sendMsgMultiSend( return err } } - txGen := moduletestutil.MakeTestTxConfig() tx, err := simtestutil.GenSignedMockTx( r, txGen, diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index ee50ddf0cd597..8f95b4199c690 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -8,6 +8,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/suite" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" @@ -33,6 +34,7 @@ type SimTestSuite struct { accountKeeper types.AccountKeeper bankKeeper keeper.Keeper cdc codec.Codec + txConfig client.TxConfig app *runtime.App } @@ -48,7 +50,7 @@ func (suite *SimTestSuite) SetupTest() { configurator.StakingModule(), configurator.ConsensusModule(), configurator.TxModule(), - ), &suite.accountKeeper, &suite.bankKeeper, &suite.cdc, &appBuilder) + ), &suite.accountKeeper, &suite.bankKeeper, &suite.cdc, &suite.txConfig, &appBuilder) suite.NoError(err) @@ -60,7 +62,7 @@ func (suite *SimTestSuite) TestWeightedOperations() { cdc := suite.cdc appParams := make(simtypes.AppParams) - weightesOps := simulation.WeightedOperations(appParams, cdc, suite.accountKeeper, suite.bankKeeper) + weightesOps := simulation.WeightedOperations(appParams, cdc, suite.txConfig, suite.accountKeeper, suite.bankKeeper) // setup 3 accounts s := rand.NewSource(1) @@ -101,7 +103,7 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { suite.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgSend(suite.accountKeeper, suite.bankKeeper) + op := simulation.SimulateMsgSend(suite.txConfig, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -128,7 +130,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() { suite.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgMultiSend(suite.accountKeeper, suite.bankKeeper) + op := simulation.SimulateMsgMultiSend(suite.txConfig, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") require := suite.Require() require.NoError(err) @@ -161,7 +163,7 @@ func (suite *SimTestSuite) TestSimulateModuleAccountMsgSend() { suite.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgSendToModuleAccount(suite.accountKeeper, suite.bankKeeper, moduleAccCount) + op := simulation.SimulateMsgSendToModuleAccount(suite.txConfig, suite.accountKeeper, suite.bankKeeper, moduleAccCount) s = rand.NewSource(1) r = rand.New(s) @@ -192,7 +194,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSendToModuleAccount() { suite.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgMultiSendToModuleAccount(suite.accountKeeper, suite.bankKeeper, mAccCount) + op := simulation.SimulateMsgMultiSendToModuleAccount(suite.txConfig, suite.accountKeeper, suite.bankKeeper, mAccCount) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().Error(err) diff --git a/x/distribution/module.go b/x/distribution/module.go index 6306eb86f5942..45bdb93f24f9d 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -203,7 +203,8 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { // WeightedOperations returns the all the gov module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, am.stakingKeeper, + simState.AppParams, simState.Cdc, simState.TxConfig, + am.accountKeeper, am.bankKeeper, am.keeper, am.stakingKeeper, ) } diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index 0a97faf3a1895..f39203070e874 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -7,11 +7,9 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "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/testutil" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/distribution/keeper" "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -31,7 +29,15 @@ const ( ) // WeightedOperations returns all the operations from the module with their respective weights -func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper) simulation.WeightedOperations { +func WeightedOperations( + appParams simtypes.AppParams, + cdc codec.JSONCodec, + txConfig client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, + sk types.StakingKeeper, +) simulation.WeightedOperations { var weightMsgSetWithdrawAddress int appParams.GetOrGenerate(cdc, OpWeightMsgSetWithdrawAddress, &weightMsgSetWithdrawAddress, nil, func(_ *rand.Rand) { @@ -60,9 +66,6 @@ func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak ty }, ) - interfaceRegistry := codectypes.NewInterfaceRegistry() - txConfig := tx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), tx.DefaultSignModes) - return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgSetWithdrawAddress, diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index 6e5631e57b837..9a5ed8b246c3d 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -30,7 +30,7 @@ import ( func (suite *SimTestSuite) TestWeightedOperations() { appParams := make(simtypes.AppParams) - weightesOps := simulation.WeightedOperations(appParams, suite.cdc, suite.accountKeeper, + weightedOps := simulation.WeightedOperations(appParams, suite.cdc, suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.distrKeeper, suite.stakingKeeper) // setup 3 accounts @@ -49,7 +49,7 @@ func (suite *SimTestSuite) TestWeightedOperations() { {simulation.DefaultWeightMsgFundCommunityPool, types.ModuleName, sdk.MsgTypeURL(&types.MsgFundCommunityPool{})}, } - for i, w := range weightesOps { + for i, w := range weightedOps { operationMsg, _, err := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "") suite.Require().NoError(err) diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index 366ca5e1b1927..663b8c6f2546a 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -12,7 +12,7 @@ require ( cosmossdk.io/store v0.1.0-alpha.1.0.20230328185921-37ba88872dbc github.com/cometbft/cometbft v0.37.1-0.20230411132551-3a91d155e664 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418140744-0dde947d0ab7 + github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418200457-cd283a676d79 github.com/cosmos/gogoproto v1.4.8 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index 2257d26402717..7c376b0a5caa3 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -187,8 +187,8 @@ github.com/cosmos/cosmos-db v1.0.0-rc.1 h1:SjnT8B6WKMW9WEIX32qMhnEEKcI7ZP0+G1Sa9 github.com/cosmos/cosmos-db v1.0.0-rc.1/go.mod h1:Dnmk3flSf5lkwCqvvjNpoxjpXzhxnCAFzKHlbaForso= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418140744-0dde947d0ab7 h1:+Q/K5pdQdQjp21gIxlQgGy4dOZk9gUBSQmJCYIf1bWA= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418140744-0dde947d0ab7/go.mod h1:BPvKPN63ettXrpz67uM1rHEqX/UVVkAfceFCPyp217E= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418200457-cd283a676d79 h1:Qa98Gl7JmoPWfrmfn/sL+vyeNZcqjM7EXhIypvUDkFs= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418200457-cd283a676d79/go.mod h1:BPvKPN63ettXrpz67uM1rHEqX/UVVkAfceFCPyp217E= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 46545f8b758fc..559c5cec0b495 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -218,6 +218,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { // WeightedOperations returns all the feegrant module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - am.registry, simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, am.ac, + am.registry, simState.AppParams, simState.Cdc, simState.TxConfig, + am.accountKeeper, am.bankKeeper, am.keeper, am.ac, ) } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index de01159da7465..8dbcf1f7f90d7 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -7,11 +7,11 @@ import ( "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/baseapp" + "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" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/simulation" ) @@ -32,6 +32,7 @@ func WeightedOperations( registry codectypes.InterfaceRegistry, appParams simtypes.AppParams, cdc codec.JSONCodec, + txConfig client.TxConfig, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, k keeper.Keeper, @@ -54,20 +55,28 @@ func WeightedOperations( }, ) + pCdc := codec.NewProtoCodec(registry) + return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgGrantAllowance, - SimulateMsgGrantAllowance(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgGrantAllowance(pCdc, txConfig, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgRevokeAllowance, - SimulateMsgRevokeAllowance(codec.NewProtoCodec(registry), ak, bk, k, ac), + SimulateMsgRevokeAllowance(pCdc, txConfig, ak, bk, k, ac), ), } } // SimulateMsgGrantAllowance generates MsgGrantAllowance with random values. -func SimulateMsgGrantAllowance(cdc *codec.ProtoCodec, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, k keeper.Keeper) simtypes.Operation { +func SimulateMsgGrantAllowance( + cdc *codec.ProtoCodec, + txConfig client.TxConfig, + ak feegrant.AccountKeeper, + bk feegrant.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -100,7 +109,7 @@ func SimulateMsgGrantAllowance(cdc *codec.ProtoCodec, ak feegrant.AccountKeeper, txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: tx.NewTxConfig(cdc, tx.DefaultSignModes), + TxGen: txConfig, Cdc: nil, Msg: msg, Context: ctx, @@ -116,7 +125,14 @@ func SimulateMsgGrantAllowance(cdc *codec.ProtoCodec, ak feegrant.AccountKeeper, } // SimulateMsgRevokeAllowance generates a MsgRevokeAllowance with random values. -func SimulateMsgRevokeAllowance(cdc *codec.ProtoCodec, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, k keeper.Keeper, ac address.Codec) simtypes.Operation { +func SimulateMsgRevokeAllowance( + cdc *codec.ProtoCodec, + txConfig client.TxConfig, + ak feegrant.AccountKeeper, + bk feegrant.BankKeeper, + k keeper.Keeper, + ac address.Codec, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -155,7 +171,7 @@ func SimulateMsgRevokeAllowance(cdc *codec.ProtoCodec, ak feegrant.AccountKeeper txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: tx.NewTxConfig(cdc, tx.DefaultSignModes), + TxGen: txConfig, Cdc: nil, Msg: &msg, Context: ctx, diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index edb0987471604..065f2a19351ec 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -6,6 +6,7 @@ import ( "time" _ "cosmossdk.io/x/feegrant/module" + "github.com/cosmos/cosmos-sdk/client" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" _ "github.com/cosmos/cosmos-sdk/x/bank" @@ -41,6 +42,7 @@ type SimTestSuite struct { ctx sdk.Context feegrantKeeper keeper.Keeper interfaceRegistry codectypes.InterfaceRegistry + txConfig client.TxConfig accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper cdc codec.Codec @@ -63,6 +65,7 @@ func (suite *SimTestSuite) SetupTest() { &suite.bankKeeper, &suite.accountKeeper, &suite.interfaceRegistry, + &suite.txConfig, &suite.cdc, &suite.legacyAmino, ) @@ -94,7 +97,7 @@ func (suite *SimTestSuite) TestWeightedOperations() { weightedOps := simulation.WeightedOperations( suite.interfaceRegistry, - appParams, suite.cdc, suite.accountKeeper, + appParams, suite.cdc, suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper, codecaddress.NewBech32Codec("cosmos"), ) @@ -144,7 +147,7 @@ func (suite *SimTestSuite) TestSimulateMsgGrantAllowance() { app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgGrantAllowance(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper) + op := simulation.SimulateMsgGrantAllowance(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper) operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(err) @@ -186,7 +189,7 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeAllowance() { require.NoError(err) // execute operation - op := simulation.SimulateMsgRevokeAllowance(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper, codecaddress.NewBech32Codec("cosmos")) + op := simulation.SimulateMsgRevokeAllowance(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.feegrantKeeper, codecaddress.NewBech32Codec("cosmos")) operationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(err) diff --git a/x/gov/module.go b/x/gov/module.go index f30b6a2b9eaab..1f46cab77d4ef 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -357,7 +357,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { // WeightedOperations returns the all the gov module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, + simState.AppParams, simState.Cdc, simState.TxConfig, am.accountKeeper, am.bankKeeper, am.keeper, simState.ProposalMsgs, simState.LegacyProposalContents, ) diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 7dccbc632e0ff..97a0e7734337b 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -8,10 +8,10 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gov/keeper" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -45,7 +45,16 @@ const ( ) // WeightedOperations returns all the operations from the module with their respective weights -func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, wMsgs []simtypes.WeightedProposalMsg, wContents []simtypes.WeightedProposalContent) simulation.WeightedOperations { //nolint:staticcheck // used for legacy testing +func WeightedOperations( + appParams simtypes.AppParams, + cdc codec.JSONCodec, + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, + wMsgs []simtypes.WeightedProposalMsg, + wContents []simtypes.WeightedProposalContent, //nolint:staticcheck // used for legacy testing +) simulation.WeightedOperations { var ( weightMsgDeposit int weightMsgVote int @@ -90,7 +99,7 @@ func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak ty wProposalOps, simulation.NewWeightedOperation( weight, - SimulateMsgSubmitProposal(ak, bk, k, wMsg.MsgSimulatorFn()), + SimulateMsgSubmitProposal(txGen, ak, bk, k, wMsg.MsgSimulatorFn()), ), ) } @@ -108,7 +117,7 @@ func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak ty wLegacyProposalOps, simulation.NewWeightedOperation( weight, - SimulateMsgSubmitLegacyProposal(ak, bk, k, wContent.ContentSimulatorFn()), + SimulateMsgSubmitLegacyProposal(txGen, ak, bk, k, wContent.ContentSimulatorFn()), ), ) } @@ -116,19 +125,19 @@ func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak ty wGovOps := simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgDeposit, - SimulateMsgDeposit(ak, bk, k), + SimulateMsgDeposit(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgVote, - SimulateMsgVote(ak, bk, k), + SimulateMsgVote(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgVoteWeighted, - SimulateMsgVoteWeighted(ak, bk, k), + SimulateMsgVoteWeighted(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgCancelProposal, - SimulateMsgCancelProposal(ak, bk, k), + SimulateMsgCancelProposal(txGen, ak, bk, k), ), } @@ -138,7 +147,13 @@ func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak ty // SimulateMsgSubmitProposal simulates creating a msg Submit Proposal // voting on the proposal, and subsequently slashing the proposal. It is implemented using // future operations. -func SimulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, msgSim simtypes.MsgSimulatorFn) simtypes.Operation { +func SimulateMsgSubmitProposal( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, + msgSim simtypes.MsgSimulatorFn, +) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgs := []sdk.Msg{} @@ -147,14 +162,20 @@ func SimulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k msgs = append(msgs, proposalMsg) } - return simulateMsgSubmitProposal(ak, bk, k, msgs)(r, app, ctx, accs, chainID) + return simulateMsgSubmitProposal(txGen, ak, bk, k, msgs)(r, app, ctx, accs, chainID) } } // SimulateMsgSubmitLegacyProposal simulates creating a msg Submit Proposal // voting on the proposal, and subsequently slashing the proposal. It is implemented using // future operations. -func SimulateMsgSubmitLegacyProposal(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, contentSim simtypes.ContentSimulatorFn) simtypes.Operation { //nolint:staticcheck // used for legacy testing +func SimulateMsgSubmitLegacyProposal( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, + contentSim simtypes.ContentSimulatorFn, //nolint:staticcheck // used for legacy testing +) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { // 1) submit proposal now @@ -169,11 +190,17 @@ func SimulateMsgSubmitLegacyProposal(ak types.AccountKeeper, bk types.BankKeeper return simtypes.NoOpMsg(types.ModuleName, TypeMsgSubmitProposal, "error converting legacy content into proposal message"), nil, err } - return simulateMsgSubmitProposal(ak, bk, k, []sdk.Msg{contentMsg})(r, app, ctx, accs, chainID) + return simulateMsgSubmitProposal(txGen, ak, bk, k, []sdk.Msg{contentMsg})(r, app, ctx, accs, chainID) } } -func simulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, proposalMsgs []sdk.Msg) simtypes.Operation { +func simulateMsgSubmitProposal( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, + proposalMsgs []sdk.Msg, +) simtypes.Operation { // The states are: // column 1: All validators vote // column 2: 90% vote @@ -226,7 +253,6 @@ func simulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k } account := ak.GetAccount(ctx, simAccount.Address) - txGen := moduletestutil.MakeTestTxConfig() tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -272,7 +298,7 @@ func simulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k whenVote := ctx.BlockHeader().Time.Add(time.Duration(r.Int63n(int64(votingPeriod.Seconds()))) * time.Second) fops[i] = simtypes.FutureOperation{ BlockTime: whenVote, - Op: operationSimulateMsgVote(ak, bk, k, accs[whoVotes[i]], int64(proposalID)), + Op: operationSimulateMsgVote(txGen, ak, bk, k, accs[whoVotes[i]], int64(proposalID)), } } @@ -281,7 +307,12 @@ func simulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k } // SimulateMsgDeposit generates a MsgDeposit with random values. -func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgDeposit( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -317,7 +348,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.K txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -331,11 +362,23 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.K } // SimulateMsgVote generates a MsgVote with random values. -func SimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { - return operationSimulateMsgVote(ak, bk, k, simtypes.Account{}, -1) +func SimulateMsgVote( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { + return operationSimulateMsgVote(txGen, ak, bk, k, simtypes.Account{}, -1) } -func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, simAccount simtypes.Account, proposalIDInt int64) simtypes.Operation { +func operationSimulateMsgVote( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, + simAccount simtypes.Account, + proposalIDInt int64, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -366,7 +409,7 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k *ke txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -382,11 +425,23 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k *ke } // SimulateMsgVoteWeighted generates a MsgVoteWeighted with random values. -func SimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { - return operationSimulateMsgVoteWeighted(ak, bk, k, simtypes.Account{}, -1) +func SimulateMsgVoteWeighted( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { + return operationSimulateMsgVoteWeighted(txGen, ak, bk, k, simtypes.Account{}, -1) } -func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, simAccount simtypes.Account, proposalIDInt int64) simtypes.Operation { +func operationSimulateMsgVoteWeighted( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, + simAccount simtypes.Account, + proposalIDInt int64, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -417,7 +472,7 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -433,7 +488,12 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe } // SimulateMsgCancelProposal generates a MsgCancelProposal. -func SimulateMsgCancelProposal(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgCancelProposal( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -460,7 +520,7 @@ func SimulateMsgCancelProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index d0b85dfdc7ed5..aa661f639b945 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -10,6 +10,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -90,7 +91,7 @@ func TestWeightedOperations(t *testing.T) { ctx.WithChainID("test-chain") appParams := make(simtypes.AppParams) - weightesOps := simulation.WeightedOperations(appParams, govcodec.ModuleCdc, suite.AccountKeeper, + weightesOps := simulation.WeightedOperations(appParams, govcodec.ModuleCdc, suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, mockWeightedProposalMsg(3), mockWeightedLegacyProposalContent(1), ) @@ -143,7 +144,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgSubmitProposal(suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, MockWeightedProposals{3}.MsgSimulatorFn()) + op := simulation.SimulateMsgSubmitProposal(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, MockWeightedProposals{3}.MsgSimulatorFn()) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(t, err) @@ -173,7 +174,7 @@ func TestSimulateMsgSubmitLegacyProposal(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgSubmitLegacyProposal(suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, MockWeightedProposals{3}.ContentSimulatorFn()) + op := simulation.SimulateMsgSubmitLegacyProposal(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, MockWeightedProposals{3}.ContentSimulatorFn()) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(t, err) @@ -220,7 +221,7 @@ func TestSimulateMsgCancelProposal(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgCancelProposal(suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) + op := simulation.SimulateMsgCancelProposal(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(t, err) @@ -264,7 +265,7 @@ func TestSimulateMsgDeposit(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgDeposit(suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) + op := simulation.SimulateMsgDeposit(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(t, err) @@ -310,7 +311,7 @@ func TestSimulateMsgVote(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgVote(suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) + op := simulation.SimulateMsgVote(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(t, err) @@ -353,7 +354,7 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgVoteWeighted(suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) + op := simulation.SimulateMsgVoteWeighted(suite.TxConfig, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper) operationMsg, _, err := op(r, app.BaseApp, ctx, accounts, "") require.NoError(t, err) @@ -368,6 +369,7 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { } type suite struct { + TxConfig client.TxConfig AccountKeeper authkeeper.AccountKeeper BankKeeper bankkeeper.Keeper GovKeeper *keeper.Keeper @@ -389,7 +391,7 @@ func createTestSuite(t *testing.T, isCheckTx bool) (suite, sdk.Context) { configurator.ConsensusModule(), configurator.DistributionModule(), configurator.GovModule(), - ), &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, &res.DistributionKeeper) + ), &res.TxConfig, &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, &res.DistributionKeeper) require.NoError(t, err) ctx := app.BaseApp.NewContext(isCheckTx, cmtproto.Header{}) diff --git a/x/group/module/module.go b/x/group/module/module.go index d073242f2263b..f86389b53b9b5 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -182,7 +182,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( am.registry, - simState.AppParams, simState.Cdc, + simState.AppParams, simState.Cdc, simState.TxConfig, am.accKeeper, am.bankKeeper, am.keeper, am.cdc, ) } diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 9e8e6fd12795d..7a17ebba89d0c 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -8,12 +8,12 @@ import ( "time" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/group/keeper" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -80,8 +80,9 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( registry cdctypes.InterfaceRegistry, - appParams simtypes.AppParams, cdc codec.JSONCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, appCdc cdctypes.AnyUnpacker, + appParams simtypes.AppParams, cdc codec.JSONCodec, txGen client.TxConfig, + ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper, + appCdc cdctypes.AnyUnpacker, ) simulation.WeightedOperations { var ( weightMsgCreateGroup int @@ -171,70 +172,72 @@ func WeightedOperations( }, ) + pCdc := codec.NewProtoCodec(registry) + // create two proposals for weightedOperations var createProposalOps simulation.WeightedOperations for i := 0; i < 2; i++ { createProposalOps = append(createProposalOps, simulation.NewWeightedOperation( weightMsgSubmitProposal, - SimulateMsgSubmitProposal(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgSubmitProposal(pCdc, txGen, ak, bk, k), )) } wPreCreateProposalOps := simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgCreateGroup, - SimulateMsgCreateGroup(codec.NewProtoCodec(registry), ak, bk), + SimulateMsgCreateGroup(pCdc, txGen, ak, bk), ), simulation.NewWeightedOperation( weightMsgCreateGroupPolicy, - SimulateMsgCreateGroupPolicy(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgCreateGroupPolicy(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgCreateGroupWithPolicy, - SimulateMsgCreateGroupWithPolicy(codec.NewProtoCodec(registry), ak, bk), + SimulateMsgCreateGroupWithPolicy(pCdc, txGen, ak, bk), ), } wPostCreateProposalOps := simulation.WeightedOperations{ simulation.NewWeightedOperation( WeightMsgWithdrawProposal, - SimulateMsgWithdrawProposal(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgWithdrawProposal(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgVote, - SimulateMsgVote(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgVote(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgExec, - SimulateMsgExec(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgExec(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgUpdateGroupMetadata, - SimulateMsgUpdateGroupMetadata(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgUpdateGroupMetadata(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgUpdateGroupAdmin, - SimulateMsgUpdateGroupAdmin(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgUpdateGroupAdmin(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgUpdateGroupMembers, - SimulateMsgUpdateGroupMembers(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgUpdateGroupMembers(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgUpdateGroupPolicyAdmin, - SimulateMsgUpdateGroupPolicyAdmin(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgUpdateGroupPolicyAdmin(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgUpdateGroupPolicyDecisionPolicy, - SimulateMsgUpdateGroupPolicyDecisionPolicy(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgUpdateGroupPolicyDecisionPolicy(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgUpdateGroupPolicyMetadata, - SimulateMsgUpdateGroupPolicyMetadata(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgUpdateGroupPolicyMetadata(pCdc, txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgLeaveGroup, - SimulateMsgLeaveGroup(codec.NewProtoCodec(registry), k, ak, bk), + SimulateMsgLeaveGroup(pCdc, txGen, k, ak, bk), ), } @@ -242,7 +245,12 @@ func WeightedOperations( } // SimulateMsgCreateGroup generates a MsgCreateGroup with random values -func SimulateMsgCreateGroup(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk group.BankKeeper) simtypes.Operation { +func SimulateMsgCreateGroup( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -259,7 +267,6 @@ func SimulateMsgCreateGroup(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk gr members := genGroupMembers(r, accounts) msg := &group.MsgCreateGroup{Admin: accAddr, Members: members, Metadata: simtypes.RandStringOfLength(r, 10)} - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -285,7 +292,12 @@ func SimulateMsgCreateGroup(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk gr } // SimulateMsgCreateGroupWithPolicy generates a MsgCreateGroupWithPolicy with random values -func SimulateMsgCreateGroupWithPolicy(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk group.BankKeeper) simtypes.Operation { +func SimulateMsgCreateGroupWithPolicy( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -319,7 +331,6 @@ func SimulateMsgCreateGroupWithPolicy(cdc *codec.ProtoCodec, ak group.AccountKee return simtypes.NoOpMsg(group.ModuleName, sdk.MsgTypeURL(msg), "unable to set decision policy"), nil, err } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -345,7 +356,13 @@ func SimulateMsgCreateGroupWithPolicy(cdc *codec.ProtoCodec, ak group.AccountKee } // SimulateMsgCreateGroupPolicy generates a NewMsgCreateGroupPolicy with random values -func SimulateMsgCreateGroupPolicy(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { +func SimulateMsgCreateGroupPolicy( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -379,7 +396,6 @@ func SimulateMsgCreateGroupPolicy(cdc *codec.ProtoCodec, ak group.AccountKeeper, return simtypes.NoOpMsg(group.ModuleName, TypeMsgCreateGroupPolicy, err.Error()), nil, err } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -406,7 +422,13 @@ func SimulateMsgCreateGroupPolicy(cdc *codec.ProtoCodec, ak group.AccountKeeper, } // SimulateMsgSubmitProposal generates a NewMsgSubmitProposal with random values -func SimulateMsgSubmitProposal(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { +func SimulateMsgSubmitProposal( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -456,7 +478,6 @@ func SimulateMsgSubmitProposal(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk Summary: "Summary of the proposal", } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -482,7 +503,13 @@ func SimulateMsgSubmitProposal(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk } // SimulateMsgUpdateGroupAdmin generates a MsgUpdateGroupAdmin with random values -func SimulateMsgUpdateGroupAdmin(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { +func SimulateMsgUpdateGroupAdmin( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -516,7 +543,6 @@ func SimulateMsgUpdateGroupAdmin(cdc *codec.ProtoCodec, ak group.AccountKeeper, NewAdmin: newAdmin.Address.String(), } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -542,7 +568,13 @@ func SimulateMsgUpdateGroupAdmin(cdc *codec.ProtoCodec, ak group.AccountKeeper, } // SimulateMsgUpdateGroupMetadata generates a MsgUpdateGroupMetadata with random values -func SimulateMsgUpdateGroupMetadata(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { +func SimulateMsgUpdateGroupMetadata( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -567,7 +599,6 @@ func SimulateMsgUpdateGroupMetadata(cdc *codec.ProtoCodec, ak group.AccountKeepe Metadata: simtypes.RandStringOfLength(r, 10), } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -593,8 +624,12 @@ func SimulateMsgUpdateGroupMetadata(cdc *codec.ProtoCodec, ak group.AccountKeepe } // SimulateMsgUpdateGroupMembers generates a MsgUpdateGroupMembers with random values -func SimulateMsgUpdateGroupMembers(cdc *codec.ProtoCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, +func SimulateMsgUpdateGroupMembers( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, @@ -647,7 +682,6 @@ func SimulateMsgUpdateGroupMembers(cdc *codec.ProtoCodec, ak group.AccountKeeper MemberUpdates: members, } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -673,7 +707,13 @@ func SimulateMsgUpdateGroupMembers(cdc *codec.ProtoCodec, ak group.AccountKeeper } // SimulateMsgUpdateGroupPolicyAdmin generates a MsgUpdateGroupPolicyAdmin with random values -func SimulateMsgUpdateGroupPolicyAdmin(cdc *codec.ProtoCodec, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { +func SimulateMsgUpdateGroupPolicyAdmin( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -707,7 +747,6 @@ func SimulateMsgUpdateGroupPolicyAdmin(cdc *codec.ProtoCodec, ak group.AccountKe NewAdmin: newAdmin.Address.String(), } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -733,8 +772,12 @@ func SimulateMsgUpdateGroupPolicyAdmin(cdc *codec.ProtoCodec, ak group.AccountKe } // // SimulateMsgUpdateGroupPolicyDecisionPolicy generates a NewMsgUpdateGroupPolicyDecisionPolicy with random values -func SimulateMsgUpdateGroupPolicyDecisionPolicy(cdc *codec.ProtoCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, +func SimulateMsgUpdateGroupPolicyDecisionPolicy( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, @@ -769,7 +812,6 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(cdc *codec.ProtoCodec, ak group. return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyDecisionPolicy, err.Error()), nil, err } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -794,8 +836,12 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(cdc *codec.ProtoCodec, ak group. } // // SimulateMsgUpdateGroupPolicyMetadata generates a MsgUpdateGroupPolicyMetadata with random values -func SimulateMsgUpdateGroupPolicyMetadata(cdc *codec.ProtoCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, +func SimulateMsgUpdateGroupPolicyMetadata( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, @@ -821,7 +867,6 @@ func SimulateMsgUpdateGroupPolicyMetadata(cdc *codec.ProtoCodec, ak group.Accoun Metadata: simtypes.RandStringOfLength(r, 10), } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -847,8 +892,12 @@ func SimulateMsgUpdateGroupPolicyMetadata(cdc *codec.ProtoCodec, ak group.Accoun } // SimulateMsgWithdrawProposal generates a MsgWithdrawProposal with random values -func SimulateMsgWithdrawProposal(cdc *codec.ProtoCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, +func SimulateMsgWithdrawProposal( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, @@ -922,7 +971,6 @@ func SimulateMsgWithdrawProposal(cdc *codec.ProtoCodec, ak group.AccountKeeper, Address: proposer.Address.String(), } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -952,8 +1000,12 @@ func SimulateMsgWithdrawProposal(cdc *codec.ProtoCodec, ak group.AccountKeeper, } // SimulateMsgVote generates a MsgVote with random values -func SimulateMsgVote(cdc *codec.ProtoCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, +func SimulateMsgVote( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, @@ -1027,7 +1079,6 @@ func SimulateMsgVote(cdc *codec.ProtoCodec, ak group.AccountKeeper, Option: group.VOTE_OPTION_YES, Metadata: simtypes.RandStringOfLength(r, 10), } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -1057,8 +1108,12 @@ func SimulateMsgVote(cdc *codec.ProtoCodec, ak group.AccountKeeper, } // // SimulateMsgExec generates a MsgExec with random values -func SimulateMsgExec(cdc *codec.ProtoCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, +func SimulateMsgExec( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak group.AccountKeeper, + bk group.BankKeeper, + k keeper.Keeper, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, @@ -1105,7 +1160,6 @@ func SimulateMsgExec(cdc *codec.ProtoCodec, ak group.AccountKeeper, ProposalId: uint64(proposalID), Executor: acc.Address.String(), } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, @@ -1134,7 +1188,13 @@ func SimulateMsgExec(cdc *codec.ProtoCodec, ak group.AccountKeeper, } // SimulateMsgLeaveGroup generates a MsgLeaveGroup with random values -func SimulateMsgLeaveGroup(cdc *codec.ProtoCodec, k keeper.Keeper, ak group.AccountKeeper, bk group.BankKeeper) simtypes.Operation { +func SimulateMsgLeaveGroup( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + k keeper.Keeper, + ak group.AccountKeeper, + bk group.BankKeeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -1167,7 +1227,6 @@ func SimulateMsgLeaveGroup(cdc *codec.ProtoCodec, k keeper.Keeper, ak group.Acco GroupId: groupInfo.Id, } - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, diff --git a/x/group/simulation/operations_test.go b/x/group/simulation/operations_test.go index b3f4ccc539c23..315b5280ad0f4 100644 --- a/x/group/simulation/operations_test.go +++ b/x/group/simulation/operations_test.go @@ -9,6 +9,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/suite" + "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/runtime" @@ -33,6 +34,7 @@ type SimTestSuite struct { app *runtime.App codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry + txConfig client.TxConfig accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper groupKeeper groupkeeper.Keeper @@ -43,6 +45,7 @@ func (suite *SimTestSuite) SetupTest() { grouptestutil.AppConfig, &suite.codec, &suite.interfaceRegistry, + &suite.txConfig, &suite.accountKeeper, &suite.bankKeeper, &suite.groupKeeper, @@ -57,7 +60,7 @@ func (suite *SimTestSuite) TestWeightedOperations() { cdc := suite.codec appParams := make(simtypes.AppParams) - weightedOps := simulation.WeightedOperations(suite.interfaceRegistry, appParams, cdc, suite.accountKeeper, + weightedOps := simulation.WeightedOperations(suite.interfaceRegistry, appParams, cdc, suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper, cdc, ) @@ -133,7 +136,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroup() { acc := accounts[0] // execute operation - op := simulation.SimulateMsgCreateGroup(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper) + op := simulation.SimulateMsgCreateGroup(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -162,7 +165,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupWithPolicy() { acc := accounts[0] // execute operation - op := simulation.SimulateMsgCreateGroupWithPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper) + op := simulation.SimulateMsgCreateGroupWithPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -204,7 +207,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupPolicy() { }) // execute operation - op := simulation.SimulateMsgCreateGroupPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgCreateGroupPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -257,7 +260,7 @@ func (suite *SimTestSuite) TestSimulateSubmitProposal() { }) // execute operation - op := simulation.SimulateMsgSubmitProposal(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgSubmitProposal(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -323,7 +326,7 @@ func (suite *SimTestSuite) TestWithdrawProposal() { }) // execute operation - op := simulation.SimulateMsgWithdrawProposal(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgWithdrawProposal(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -390,7 +393,7 @@ func (suite *SimTestSuite) TestSimulateVote() { }) // execute operation - op := simulation.SimulateMsgVote(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgVote(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -465,7 +468,7 @@ func (suite *SimTestSuite) TestSimulateExec() { }) // execute operation - op := simulation.SimulateMsgExec(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgExec(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -507,7 +510,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupAdmin() { }) // execute operation - op := simulation.SimulateMsgUpdateGroupAdmin(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgUpdateGroupAdmin(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -549,7 +552,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMetadata() { }) // execute operation - op := simulation.SimulateMsgUpdateGroupMetadata(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgUpdateGroupMetadata(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -591,7 +594,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMembers() { }) // execute operation - op := simulation.SimulateMsgUpdateGroupMembers(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgUpdateGroupMembers(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -644,7 +647,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyAdmin() { }) // execute operation - op := simulation.SimulateMsgUpdateGroupPolicyAdmin(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgUpdateGroupPolicyAdmin(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -697,7 +700,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyDecisionPolicy() { }) // execute operation - op := simulation.SimulateMsgUpdateGroupPolicyDecisionPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgUpdateGroupPolicyDecisionPolicy(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -750,7 +753,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyMetadata() { }) // execute operation - op := simulation.SimulateMsgUpdateGroupPolicyMetadata(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) + op := simulation.SimulateMsgUpdateGroupPolicyMetadata(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.groupKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) @@ -816,7 +819,7 @@ func (suite *SimTestSuite) TestSimulateLeaveGroup() { }) // execute operation - op := simulation.SimulateMsgLeaveGroup(codec.NewProtoCodec(suite.interfaceRegistry), suite.groupKeeper, suite.accountKeeper, suite.bankKeeper) + op := simulation.SimulateMsgLeaveGroup(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.groupKeeper, suite.accountKeeper, suite.bankKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, suite.ctx, accounts, "") suite.Require().NoError(err) diff --git a/x/nft/go.mod b/x/nft/go.mod index 11dc3675da4e9..dc0487e827d93 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/store v0.1.0-alpha.1.0.20230328185921-37ba88872dbc github.com/cometbft/cometbft v0.37.1-0.20230411132551-3a91d155e664 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418140744-0dde947d0ab7 + github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418200457-cd283a676d79 github.com/cosmos/gogoproto v1.4.8 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 diff --git a/x/nft/go.sum b/x/nft/go.sum index 738aa5d72c891..75bbc9ef8eac3 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -182,8 +182,8 @@ github.com/cosmos/cosmos-db v1.0.0-rc.1 h1:SjnT8B6WKMW9WEIX32qMhnEEKcI7ZP0+G1Sa9 github.com/cosmos/cosmos-db v1.0.0-rc.1/go.mod h1:Dnmk3flSf5lkwCqvvjNpoxjpXzhxnCAFzKHlbaForso= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418140744-0dde947d0ab7 h1:+Q/K5pdQdQjp21gIxlQgGy4dOZk9gUBSQmJCYIf1bWA= -github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418140744-0dde947d0ab7/go.mod h1:BPvKPN63ettXrpz67uM1rHEqX/UVVkAfceFCPyp217E= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418200457-cd283a676d79 h1:Qa98Gl7JmoPWfrmfn/sL+vyeNZcqjM7EXhIypvUDkFs= +github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230418200457-cd283a676d79/go.mod h1:BPvKPN63ettXrpz67uM1rHEqX/UVVkAfceFCPyp217E= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 5012f76679e83..94db19427c17a 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -170,7 +170,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( am.registry, - simState.AppParams, simState.Cdc, + simState.AppParams, simState.Cdc, simState.TxConfig, am.accountKeeper, am.bankKeeper, am.keeper, ) } diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index 219bd23b75ad9..b3bccf2b84f14 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -4,12 +4,12 @@ import ( "math/rand" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/simulation" "cosmossdk.io/x/nft" @@ -31,6 +31,7 @@ func WeightedOperations( registry cdctypes.InterfaceRegistry, appParams simtypes.AppParams, cdc codec.JSONCodec, + txCfg client.TxConfig, ak nft.AccountKeeper, bk nft.BankKeeper, k keeper.Keeper, @@ -46,7 +47,7 @@ func WeightedOperations( return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgSend, - SimulateMsgSend(codec.NewProtoCodec(registry), ak, bk, k), + SimulateMsgSend(codec.NewProtoCodec(registry), txCfg, ak, bk, k), ), } } @@ -54,6 +55,7 @@ func WeightedOperations( // SimulateMsgSend generates a MsgSend with random values. func SimulateMsgSend( cdc *codec.ProtoCodec, + txCfg client.TxConfig, ak nft.AccountKeeper, bk nft.BankKeeper, k keeper.Keeper, @@ -92,7 +94,6 @@ func SimulateMsgSend( Receiver: receiver.Address.String(), } - txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txCfg, diff --git a/x/nft/simulation/operations_test.go b/x/nft/simulation/operations_test.go index f32daf2dec872..8274fdbae9168 100644 --- a/x/nft/simulation/operations_test.go +++ b/x/nft/simulation/operations_test.go @@ -14,6 +14,7 @@ import ( nftkeeper "cosmossdk.io/x/nft/keeper" "cosmossdk.io/x/nft/simulation" "cosmossdk.io/x/nft/testutil" + "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/runtime" @@ -34,6 +35,7 @@ type SimTestSuite struct { app *runtime.App codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry + txConfig client.TxConfig accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper stakingKeeper *stakingkeeper.Keeper @@ -45,6 +47,7 @@ func (suite *SimTestSuite) SetupTest() { testutil.AppConfig, &suite.codec, &suite.interfaceRegistry, + &suite.txConfig, &suite.accountKeeper, &suite.bankKeeper, &suite.stakingKeeper, @@ -61,6 +64,7 @@ func (suite *SimTestSuite) TestWeightedOperations() { suite.interfaceRegistry, make(simtypes.AppParams), suite.codec, + suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.nftKeeper, @@ -125,7 +129,7 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { // execute operation registry := suite.interfaceRegistry - op := simulation.SimulateMsgSend(codec.NewProtoCodec(registry), suite.accountKeeper, suite.bankKeeper, suite.nftKeeper) + op := simulation.SimulateMsgSend(codec.NewProtoCodec(registry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.nftKeeper) operationMsg, futureOperations, err := op(r, suite.app.BaseApp, ctx, accounts, "") suite.Require().NoError(err) diff --git a/x/slashing/module.go b/x/slashing/module.go index 7c15f966b940b..e92ad1b47a3f2 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -96,6 +96,8 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic + registry cdctypes.InterfaceRegistry + keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper @@ -106,7 +108,15 @@ type AppModule struct { } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, ss exported.Subspace) AppModule { +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + ak types.AccountKeeper, + bk types.BankKeeper, + sk types.StakingKeeper, + ss exported.Subspace, + registry cdctypes.InterfaceRegistry, +) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, @@ -198,7 +208,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { // WeightedOperations returns the all the slashing module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, + am.registry, simState.AppParams, simState.Cdc, simState.TxConfig, am.accountKeeper, am.bankKeeper, am.keeper, am.stakingKeeper, ) } @@ -221,6 +231,7 @@ type ModuleInputs struct { Key *store.KVStoreKey Cdc codec.Codec LegacyAmino *codec.LegacyAmino + Registry cdctypes.InterfaceRegistry AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper @@ -246,7 +257,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { } k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.Key, in.StakingKeeper, authority.String()) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.LegacySubspace) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.LegacySubspace, in.Registry) return ModuleOutputs{ Keeper: k, Module: m, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 9937665aaf6c4..cbdeb2b102eb8 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -5,13 +5,13 @@ import ( "math/rand" "github.com/cosmos/cosmos-sdk/baseapp" + "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/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/slashing/keeper" "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -26,11 +26,15 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, - bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper, + registry codectypes.InterfaceRegistry, + appParams simtypes.AppParams, + cdc codec.JSONCodec, + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, + sk types.StakingKeeper, ) simulation.WeightedOperations { - interfaceRegistry := codectypes.NewInterfaceRegistry() - var weightMsgUnjail int appParams.GetOrGenerate(cdc, OpWeightMsgUnjail, &weightMsgUnjail, nil, func(_ *rand.Rand) { @@ -41,13 +45,20 @@ func WeightedOperations( return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgUnjail, - SimulateMsgUnjail(codec.NewProtoCodec(interfaceRegistry), ak, bk, k, sk), + SimulateMsgUnjail(codec.NewProtoCodec(registry), txGen, ak, bk, k, sk), ), } } // SimulateMsgUnjail generates a MsgUnjail with random values -func SimulateMsgUnjail(cdc *codec.ProtoCodec, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper) simtypes.Operation { +func SimulateMsgUnjail( + cdc *codec.ProtoCodec, + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, + sk types.StakingKeeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -93,7 +104,6 @@ func SimulateMsgUnjail(cdc *codec.ProtoCodec, ak types.AccountKeeper, bk types.B msg := types.NewMsgUnjail(validator.GetOperator()) - txGen := tx.NewTxConfig(cdc, tx.DefaultSignModes) tx, err := simtestutil.GenSignedMockTx( r, txGen, diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index de71e3153e95c..0990f5f9e891f 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -46,6 +47,7 @@ type SimTestSuite struct { legacyAmino *codec.LegacyAmino codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry + txConfig client.TxConfig accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper stakingKeeper *stakingkeeper.Keeper @@ -81,6 +83,7 @@ func (suite *SimTestSuite) SetupTest() { &suite.legacyAmino, &suite.codec, &suite.interfaceRegistry, + &suite.txConfig, &suite.accountKeeper, &suite.bankKeeper, &suite.stakingKeeper, @@ -127,8 +130,8 @@ func (suite *SimTestSuite) TestWeightedOperations() { {simulation.DefaultWeightMsgUnjail, types.ModuleName, sdk.MsgTypeURL(&types.MsgUnjail{})}, } - weightesOps := simulation.WeightedOperations(appParams, suite.codec, suite.accountKeeper, suite.bankKeeper, suite.slashingKeeper, suite.stakingKeeper) - for i, w := range weightesOps { + weightedOps := simulation.WeightedOperations(suite.interfaceRegistry, appParams, suite.codec, suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.slashingKeeper, suite.stakingKeeper) + for i, w := range weightedOps { operationMsg, _, err := w.Op()(suite.r, suite.app.BaseApp, ctx, suite.accounts, ctx.ChainID()) suite.Require().NoError(err) @@ -175,7 +178,7 @@ func (suite *SimTestSuite) TestSimulateMsgUnjail() { suite.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgUnjail(codec.NewProtoCodec(suite.interfaceRegistry), suite.accountKeeper, suite.bankKeeper, suite.slashingKeeper, suite.stakingKeeper) + op := simulation.SimulateMsgUnjail(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.slashingKeeper, suite.stakingKeeper) operationMsg, futureOperations, err := op(suite.r, suite.app.BaseApp, ctx, suite.accounts, "") suite.Require().NoError(err) diff --git a/x/staking/module.go b/x/staking/module.go index bd60ca1d5f83e..d7d421f738a47 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -307,6 +307,7 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { // WeightedOperations returns the all the staking module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper, + simState.AppParams, simState.Cdc, simState.TxConfig, + am.accountKeeper, am.bankKeeper, am.keeper, ) } diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 5aabb0ba2a400..adfda8fccfd5c 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -6,10 +6,10 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -35,8 +35,12 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, - bk types.BankKeeper, k *keeper.Keeper, + appParams simtypes.AppParams, + cdc codec.JSONCodec, + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, ) simulation.WeightedOperations { var ( weightMsgCreateValidator int @@ -86,33 +90,38 @@ func WeightedOperations( return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgCreateValidator, - SimulateMsgCreateValidator(ak, bk, k), + SimulateMsgCreateValidator(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgEditValidator, - SimulateMsgEditValidator(ak, bk, k), + SimulateMsgEditValidator(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgDelegate, - SimulateMsgDelegate(ak, bk, k), + SimulateMsgDelegate(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgUndelegate, - SimulateMsgUndelegate(ak, bk, k), + SimulateMsgUndelegate(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgBeginRedelegate, - SimulateMsgBeginRedelegate(ak, bk, k), + SimulateMsgBeginRedelegate(txGen, ak, bk, k), ), simulation.NewWeightedOperation( weightMsgCancelUnbondingDelegation, - SimulateMsgCancelUnbondingDelegate(ak, bk, k), + SimulateMsgCancelUnbondingDelegate(txGen, ak, bk, k), ), } } // SimulateMsgCreateValidator generates a MsgCreateValidator with random values -func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgCreateValidator( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -177,7 +186,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k * txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -191,7 +200,12 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k * } // SimulateMsgEditValidator generates a MsgEditValidator with random values -func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgEditValidator( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -235,7 +249,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k *ke txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -251,7 +265,12 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k *ke } // SimulateMsgDelegate generates a MsgDelegate with random values -func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgDelegate( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -302,7 +321,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keeper. txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -316,7 +335,12 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keeper. } // SimulateMsgUndelegate generates a MsgUndelegate with random values -func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgUndelegate( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -379,7 +403,7 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keepe txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -395,7 +419,12 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keepe } // SimulateMsgCancelUnbondingDelegate generates a MsgCancelUnbondingDelegate with random values -func SimulateMsgCancelUnbondingDelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgCancelUnbondingDelegate( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -460,7 +489,7 @@ func SimulateMsgCancelUnbondingDelegate(ak types.AccountKeeper, bk types.BankKee txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, @@ -476,7 +505,12 @@ func SimulateMsgCancelUnbondingDelegate(ak types.AccountKeeper, bk types.BankKee } // SimulateMsgBeginRedelegate generates a MsgBeginRedelegate with random values -func SimulateMsgBeginRedelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { +func SimulateMsgBeginRedelegate( + txGen client.TxConfig, + ak types.AccountKeeper, + bk types.BankKeeper, + k *keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -563,7 +597,7 @@ func SimulateMsgBeginRedelegate(ak types.AccountKeeper, bk types.BankKeeper, k * txCtx := simulation.OperationInput{ R: r, App: app, - TxGen: moduletestutil.MakeTestTxConfig(), + TxGen: txGen, Cdc: nil, Msg: msg, Context: ctx, diff --git a/x/staking/simulation/operations_test.go b/x/staking/simulation/operations_test.go index 2ccfe937d7387..6d1484a6991f9 100644 --- a/x/staking/simulation/operations_test.go +++ b/x/staking/simulation/operations_test.go @@ -13,6 +13,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/client" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" @@ -42,6 +43,7 @@ type SimTestSuite struct { suite.Suite r *rand.Rand + txConfig client.TxConfig accounts []simtypes.Account ctx sdk.Context app *runtime.App @@ -86,7 +88,7 @@ func (s *SimTestSuite) SetupTest() { stakingKeeper *stakingkeeper.Keeper ) - app, err := simtestutil.SetupWithConfiguration(testutil.AppConfig, startupCfg, &bankKeeper, &accountKeeper, &mintKeeper, &distrKeeper, &stakingKeeper) + app, err := simtestutil.SetupWithConfiguration(testutil.AppConfig, startupCfg, &s.txConfig, &bankKeeper, &accountKeeper, &mintKeeper, &distrKeeper, &stakingKeeper) require.NoError(s.T(), err) ctx := app.BaseApp.NewContext(false, cmtproto.Header{}) @@ -122,7 +124,7 @@ func (s *SimTestSuite) TestWeightedOperations() { cdc := s.encCfg.Codec appParams := make(simtypes.AppParams) - weightesOps := simulation.WeightedOperations(appParams, cdc, s.accountKeeper, + weightedOps := simulation.WeightedOperations(appParams, cdc, s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper, ) @@ -139,7 +141,7 @@ func (s *SimTestSuite) TestWeightedOperations() { {simulation.DefaultWeightMsgCancelUnbondingDelegation, types.ModuleName, sdk.MsgTypeURL(&types.MsgCancelUnbondingDelegation{})}, } - for i, w := range weightesOps { + for i, w := range weightedOps { operationMsg, _, _ := w.Op()(s.r, s.app.BaseApp, s.ctx, s.accounts, s.ctx.ChainID()) // require.NoError(t, err) // TODO check if it should be NoError @@ -160,7 +162,7 @@ func (s *SimTestSuite) TestSimulateMsgCreateValidator() { s.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash}}) // execute operation - op := simulation.SimulateMsgCreateValidator(s.accountKeeper, s.bankKeeper, s.stakingKeeper) + op := simulation.SimulateMsgCreateValidator(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) operationMsg, futureOperations, err := op(s.r, s.app.BaseApp, s.ctx, s.accounts[1:], "") require.NoError(err) @@ -205,7 +207,7 @@ func (s *SimTestSuite) TestSimulateMsgCancelUnbondingDelegation() { s.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgCancelUnbondingDelegate(s.accountKeeper, s.bankKeeper, s.stakingKeeper) + op := simulation.SimulateMsgCancelUnbondingDelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) accounts := []simtypes.Account{delegator} operationMsg, futureOperations, err := op(s.r, s.app.BaseApp, ctx, accounts, "") require.NoError(err) @@ -234,7 +236,7 @@ func (s *SimTestSuite) TestSimulateMsgEditValidator() { s.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgEditValidator(s.accountKeeper, s.bankKeeper, s.stakingKeeper) + op := simulation.SimulateMsgEditValidator(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) operationMsg, futureOperations, err := op(s.r, s.app.BaseApp, ctx, s.accounts, "") require.NoError(err) @@ -255,7 +257,7 @@ func (s *SimTestSuite) TestSimulateMsgDelegate() { ctx := s.ctx.WithBlockTime(blockTime) // execute operation - op := simulation.SimulateMsgDelegate(s.accountKeeper, s.bankKeeper, s.stakingKeeper) + op := simulation.SimulateMsgDelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) operationMsg, futureOperations, err := op(s.r, s.app.BaseApp, ctx, s.accounts[1:], "") require.NoError(err) @@ -294,7 +296,7 @@ func (s *SimTestSuite) TestSimulateMsgUndelegate() { s.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgUndelegate(s.accountKeeper, s.bankKeeper, s.stakingKeeper) + op := simulation.SimulateMsgUndelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) operationMsg, futureOperations, err := op(s.r, s.app.BaseApp, ctx, s.accounts, "") require.NoError(err) @@ -337,7 +339,7 @@ func (s *SimTestSuite) TestSimulateMsgBeginRedelegate() { s.app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{Height: s.app.LastBlockHeight() + 1, AppHash: s.app.LastCommitID().Hash, Time: blockTime}}) // execute operation - op := simulation.SimulateMsgBeginRedelegate(s.accountKeeper, s.bankKeeper, s.stakingKeeper) + op := simulation.SimulateMsgBeginRedelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) operationMsg, futureOperations, err := op(s.r, s.app.BaseApp, ctx, s.accounts, "") s.T().Logf("operation message: %v", operationMsg) require.NoError(err)