From cc155e73729b1c55caffeb7705aa4703b9692c25 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Mon, 16 Sep 2024 17:50:24 -0500 Subject: [PATCH] Fix namespaces to com-pile --- .../controller/keeper/account.go | 6 +-- .../controller/keeper/genesis_test.go | 7 +++- .../controller/keeper/keeper_test.go | 10 ++++- .../host/keeper/keeper_test.go | 12 ++++-- modules/apps/transfer/keeper/forwarding.go | 2 +- modules/apps/transfer/keeper/keeper_test.go | 17 +++++++-- modules/apps/transfer/keeper/relay.go | 2 +- modules/apps/transfer/simulation/proposals.go | 9 +++-- .../transfer/simulation/proposals_test.go | 3 +- .../apps/transfer/types/expected_keepers.go | 2 +- modules/core/02-client/abci.go | 2 +- modules/core/keeper/keeper_test.go | 10 ++++- modules/core/simulation/proposals.go | 38 ++++++++++--------- modules/core/simulation/proposals_test.go | 12 ++++-- testing/chain.go | 37 +++++++++++++++--- testing/endpoint.go | 2 +- 16 files changed, 119 insertions(+), 52 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account.go b/modules/apps/27-interchain-accounts/controller/keeper/account.go index b93ca05e791..3189642e8b3 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/ibc-go/v9/internal/logging" icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" @@ -84,8 +83,9 @@ func (k Keeper) registerInterchainAccount(ctx context.Context, connectionID, por return "", err } - k.EventService.EventManager(ctx).Events() - k.Logger.Debug("emitting interchain account registration events", logging.SdkEventsToLogArguments(events)) + // TODO: .Events() is no longer a thing on the SDK + events := sdkCtx.EventManager().Events() + k.Logger.Debug("emitting interchain account registration events", events) // NOTE: The sdk msg handler creates a new EventManager, so events must be correctly propagated back to the current context sdkCtx.EventManager().EmitEvents(events) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go index 4a8e5d19bcb..e548f9fc0f2 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "cosmossdk.io/core/appmodule" "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/keeper" "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/types" genesistypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/genesis/types" @@ -13,6 +14,10 @@ import ( func (suite *KeeperTestSuite) TestInitGenesis() { ports := []string{"port1", "port2", "port3"} + env := appmodule.Environment{ + Logger: suite.chainA.GetSimApp().Logger(), + } + testCases := []struct { name string malleate func() @@ -30,7 +35,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { }, } - interchainAccAddr := icatypes.GenerateAddress(suite.chainB.GetContext(), ibctesting.FirstConnectionID, TestPortID) + interchainAccAddr := icatypes.GenerateAddress(suite.chainB.GetContext(), env, ibctesting.FirstConnectionID, TestPortID) genesisState := genesistypes.ControllerGenesisState{ ActiveChannels: []genesistypes.ActiveChannel{ { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go index 001a048ae53..0826faca5c7 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( testifysuite "github.com/stretchr/testify/suite" + "cosmossdk.io/core/appmodule" govtypes "cosmossdk.io/x/gov/types" "github.com/cosmos/cosmos-sdk/runtime" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -110,6 +111,11 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestNewKeeper() { + env := appmodule.Environment{ + Logger: suite.chainA.GetSimApp().Logger(), + KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + } + testCases := []struct { name string instantiateFn func() @@ -118,7 +124,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"success", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + env, suite.chainA.GetSimApp().GetSubspace(types.SubModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, @@ -131,7 +137,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"failure: empty authority", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + env, suite.chainA.GetSimApp().GetSubspace(types.SubModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index 4a4e000bfd5..6f664d79b84 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "cosmossdk.io/core/appmodule" testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/runtime" @@ -134,6 +135,11 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestNewKeeper() { + env := appmodule.Environment{ + Logger: suite.chainA.GetSimApp().Logger(), + KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + } + testCases := []struct { name string instantiateFn func() @@ -142,7 +148,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"success", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + env, suite.chainA.GetSimApp().GetSubspace(types.SubModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, @@ -157,7 +163,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"failure: interchain accounts module account does not exist", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + env, suite.chainA.GetSimApp().GetSubspace(types.SubModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, @@ -172,7 +178,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"failure: empty mock staking keeper", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + env, suite.chainA.GetSimApp().GetSubspace(types.SubModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, diff --git a/modules/apps/transfer/keeper/forwarding.go b/modules/apps/transfer/keeper/forwarding.go index cb68b9d919a..fa0072b558a 100644 --- a/modules/apps/transfer/keeper/forwarding.go +++ b/modules/apps/transfer/keeper/forwarding.go @@ -83,7 +83,7 @@ func (k Keeper) revertForwardedPacket(ctx context.Context, forwardedPacket chann // given that the packet is being reversed, we check the DestinationChannel and DestinationPort // of the forwardedPacket to see if a hop was added to the trace during the receive step if token.Denom.HasPrefix(forwardedPacket.DestinationPort, forwardedPacket.DestinationChannel) { - if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil { + if err := k.bankKeeper.BurnCoins(ctx, k.authKeeper.GetModuleAddress(types.ModuleName), sdk.NewCoins(coin)); err != nil { return err } } else { diff --git a/modules/apps/transfer/keeper/keeper_test.go b/modules/apps/transfer/keeper/keeper_test.go index 0e7589d3596..9dbc683e7cd 100644 --- a/modules/apps/transfer/keeper/keeper_test.go +++ b/modules/apps/transfer/keeper/keeper_test.go @@ -6,6 +6,7 @@ import ( testifysuite "github.com/stretchr/testify/suite" + "cosmossdk.io/core/appmodule" "cosmossdk.io/math" sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" @@ -58,7 +59,10 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"success", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + appmodule.Environment{ + Logger: suite.chainA.GetSimApp().Logger(), + KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + }, suite.chainA.GetSimApp().GetSubspace(types.ModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, @@ -72,7 +76,10 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"failure: transfer module account does not exist", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + appmodule.Environment{ + Logger: suite.chainA.GetSimApp().Logger(), + KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + }, suite.chainA.GetSimApp().GetSubspace(types.ModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, @@ -86,7 +93,10 @@ func (suite *KeeperTestSuite) TestNewKeeper() { {"failure: empty authority", func() { keeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + appmodule.Environment{ + Logger: suite.chainA.GetSimApp().Logger(), + KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), + }, suite.chainA.GetSimApp().GetSubspace(types.ModuleName), suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper, @@ -284,7 +294,6 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() { storeKey := suite.chainA.GetSimApp().GetKey(types.ModuleName) store = ctx.KVStore(storeKey) - cdc = suite.chainA.App.AppCodec() tc.malleate() diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 6b1c37384bc..69acb056cc3 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -119,7 +119,7 @@ func (k Keeper) sendTransfer( } if err := k.bankKeeper.BurnCoins( - ctx, types.ModuleName, sdk.NewCoins(coin), + ctx, k.authKeeper.GetModuleAddress(types.ModuleName), sdk.NewCoins(coin), ); err != nil { // NOTE: should not happen as the module account was // retrieved on the step above and it has enough balance diff --git a/modules/apps/transfer/simulation/proposals.go b/modules/apps/transfer/simulation/proposals.go index 404a24ff3a0..a0f17371357 100644 --- a/modules/apps/transfer/simulation/proposals.go +++ b/modules/apps/transfer/simulation/proposals.go @@ -3,9 +3,10 @@ package simulation import ( "math/rand" + "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" @@ -30,13 +31,13 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a MsgUpdateParams -func SimulateMsgUpdateParams(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { - var gov sdk.AccAddress = address.Module("gov") +func SimulateMsgUpdateParams(_ *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { + var gov sdk.AccAddress = authtypes.NewModuleAddress("gov") params := types.DefaultParams() params.SendEnabled = false return &types.MsgUpdateParams{ Signer: gov.String(), Params: params, - } + }, nil } diff --git a/modules/apps/transfer/simulation/proposals_test.go b/modules/apps/transfer/simulation/proposals_test.go index 7e399e3afd1..90add4d33da 100644 --- a/modules/apps/transfer/simulation/proposals_test.go +++ b/modules/apps/transfer/simulation/proposals_test.go @@ -32,7 +32,8 @@ func TestProposalMsgs(t *testing.T) { require.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) require.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg := w0.MsgSimulatorFn()(r, ctx, accounts) + msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, nil) + require.NoError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) require.True(t, ok) diff --git a/modules/apps/transfer/types/expected_keepers.go b/modules/apps/transfer/types/expected_keepers.go index b2822dc8e3b..735b49f653e 100644 --- a/modules/apps/transfer/types/expected_keepers.go +++ b/modules/apps/transfer/types/expected_keepers.go @@ -23,7 +23,7 @@ type AccountKeeper interface { type BankKeeper interface { SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error - BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx context.Context, moduleName []byte, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error BlockedAddr(addr sdk.AccAddress) bool diff --git a/modules/core/02-client/abci.go b/modules/core/02-client/abci.go index ed048962399..1901405b979 100644 --- a/modules/core/02-client/abci.go +++ b/modules/core/02-client/abci.go @@ -23,7 +23,7 @@ func BeginBlocker(ctx context.Context, k *keeper.Keeper) { if err == nil && hi.Height == plan.Height-1 { upgradedConsState := &ibctm.ConsensusState{ Timestamp: hi.Time, - NextValidatorsHash: ctx.NextValidatorsHash, //TODO: need to pass the consensus modules blocked on https://github.com/cosmos/cosmos-sdk/pull/21480 + NextValidatorsHash: hi.NextValidatorsHash, //TODO: need to pass the consensus modules blocked on https://github.com/cosmos/cosmos-sdk/pull/21480 } bz := types.MustMarshalConsensusState(k.Codec(), upgradedConsState) diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index eb35bd015c3..7d78c3a6165 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( testifysuite "github.com/stretchr/testify/suite" + "cosmossdk.io/core/appmodule" upgradekeeper "cosmossdk.io/x/upgrade/keeper" "github.com/cosmos/cosmos-sdk/runtime" @@ -50,6 +51,11 @@ func (suite *KeeperTestSuite) TestNewKeeper() { newIBCKeeperFn func() ) + env := appmodule.Environment{ + Logger: suite.chainA.GetSimApp().Logger(), + KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)), + } + testCases := []struct { name string malleate func() @@ -74,7 +80,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { newIBCKeeperFn = func() { ibckeeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)), + env, suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName), upgradeKeeper, scopedKeeper, @@ -93,7 +99,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { newIBCKeeperFn = func() { ibckeeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)), + env, suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName), upgradeKeeper, scopedKeeper, diff --git a/modules/core/simulation/proposals.go b/modules/core/simulation/proposals.go index e909d1fa1f0..8e46ac213f9 100644 --- a/modules/core/simulation/proposals.go +++ b/modules/core/simulation/proposals.go @@ -1,16 +1,18 @@ package simulation import ( + "context" "math/rand" "time" upgradetypes "cosmossdk.io/x/upgrade/types" + "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -29,22 +31,22 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeight, SimulateClientMsgUpdateParams, ), - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeight, SimulateConnectionMsgUpdateParams, ), - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgRecoverClient, DefaultWeight, SimulateClientMsgRecoverClient, ), - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgIBCSoftwareUpgrade, DefaultWeight, SimulateClientMsgScheduleIBCSoftwareUpgrade, @@ -52,32 +54,34 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } } +// func(ctx context.Context, r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) + // SimulateClientMsgUpdateParams returns a MsgUpdateParams for 02-client -func SimulateClientMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { - var signer sdk.AccAddress = address.Module("gov") +func SimulateClientMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { + var signer sdk.AccAddress = authtypes.NewModuleAddress("gov") params := types.DefaultParams() params.AllowedClients = []string{"06-solomachine", "07-tendermint"} return &types.MsgUpdateParams{ Signer: signer.String(), Params: params, - } + }, nil } // SimulateClientMsgRecoverClient returns a MsgRecoverClient for 02-client -func SimulateClientMsgRecoverClient(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { - var signer sdk.AccAddress = address.Module("gov") +func SimulateClientMsgRecoverClient(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { + var signer sdk.AccAddress = authtypes.NewModuleAddress("gov") return &types.MsgRecoverClient{ Signer: signer.String(), SubjectClientId: "07-tendermint-0", SubstituteClientId: "07-tendermint-1", - } + }, nil } // SimulateClientMsgScheduleIBCSoftwareUpgrade returns a MsgScheduleIBCSoftwareUpgrade for 02-client -func SimulateClientMsgScheduleIBCSoftwareUpgrade(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { - var signer sdk.AccAddress = address.Module("gov") +func SimulateClientMsgScheduleIBCSoftwareUpgrade(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { + var signer sdk.AccAddress = authtypes.NewModuleAddress("gov") chainID := "chain-a-0" ubdPeriod := time.Hour * 24 * 7 * 2 @@ -101,17 +105,17 @@ func SimulateClientMsgScheduleIBCSoftwareUpgrade(r *rand.Rand, _ sdk.Context, _ Height: 100, }, UpgradedClientState: anyClient, - } + }, nil } // SimulateConnectionMsgUpdateParams returns a MsgUpdateParams 03-connection -func SimulateConnectionMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { - var signer sdk.AccAddress = address.Module("gov") +func SimulateConnectionMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { + var signer sdk.AccAddress = authtypes.NewModuleAddress("gov") params := connectiontypes.DefaultParams() params.MaxExpectedTimePerBlock = uint64(100) return &connectiontypes.MsgUpdateParams{ Signer: signer.String(), Params: params, - } + }, nil } diff --git a/modules/core/simulation/proposals_test.go b/modules/core/simulation/proposals_test.go index 1d1a86c7f6e..a8bb36ed2b6 100644 --- a/modules/core/simulation/proposals_test.go +++ b/modules/core/simulation/proposals_test.go @@ -34,7 +34,8 @@ func TestProposalMsgs(t *testing.T) { require.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) require.Equal(t, simulation.DefaultWeight, w0.DefaultWeight()) - msg := w0.MsgSimulatorFn()(r, ctx, accounts) + msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, nil) // TODO: codec + require.NoError(t, err) msgUpdateParams, ok := msg.(*clienttypes.MsgUpdateParams) require.True(t, ok) @@ -46,7 +47,8 @@ func TestProposalMsgs(t *testing.T) { require.Equal(t, simulation.OpWeightMsgUpdateParams, w1.AppParamsKey()) require.Equal(t, simulation.DefaultWeight, w1.DefaultWeight()) - msg1 := w1.MsgSimulatorFn()(r, ctx, accounts) + msg1, err := w1.MsgSimulatorFn()(ctx, r, accounts, nil) // TODO: codec + require.NoError(t, err) msgUpdateConnectionParams, ok := msg1.(*connectiontypes.MsgUpdateParams) require.True(t, ok) @@ -58,7 +60,8 @@ func TestProposalMsgs(t *testing.T) { require.Equal(t, simulation.OpWeightMsgRecoverClient, w2.AppParamsKey()) require.Equal(t, simulation.DefaultWeight, w2.DefaultWeight()) - msg2 := w2.MsgSimulatorFn()(r, ctx, accounts) + msg2, err := w2.MsgSimulatorFn()(ctx, r, accounts, nil) // TODO: codec + require.NoError(t, err) msgRecoverClient, ok := msg2.(*clienttypes.MsgRecoverClient) require.True(t, ok) @@ -70,7 +73,8 @@ func TestProposalMsgs(t *testing.T) { require.Equal(t, simulation.OpWeightMsgIBCSoftwareUpgrade, w3.AppParamsKey()) require.Equal(t, simulation.DefaultWeight, w3.DefaultWeight()) - msg3 := w3.MsgSimulatorFn()(r, ctx, accounts) + msg3, err := w3.MsgSimulatorFn()(ctx, r, accounts, nil) // TODO: codec + require.NoError(t, err) msgIBCSoftwareUpgrade, ok := msg3.(*clienttypes.MsgIBCSoftwareUpgrade) require.True(t, ok) diff --git a/testing/chain.go b/testing/chain.go index 902dcc2fede..9746f1100fd 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -8,10 +8,10 @@ import ( "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdkmath "cosmossdk.io/math" banktypes "cosmossdk.io/x/bank/types" - "cosmossdk.io/x/staking/testutil" stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -27,6 +27,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" cmtversion "github.com/cometbft/cometbft/version" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -226,7 +227,7 @@ func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, cl func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height int64) ([]byte, clienttypes.Height) { res, err := chain.App.Query( chain.GetContext().Context(), - &abci.RequestQuery{ + &abci.QueryRequest{ Path: fmt.Sprintf("store/%s/key", storeKey), Height: height - 1, Data: key, @@ -253,7 +254,7 @@ func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height i func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height) { res, err := chain.App.Query( chain.GetContext().Context(), - &abci.RequestQuery{ + &abci.QueryRequest{ Path: "store/upgrade/key", Height: int64(height - 1), Data: key, @@ -293,7 +294,7 @@ func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clien // returned on block `n` to the validators of block `n+2`. // It calls BeginBlock with the new block created before returning. func (chain *TestChain) NextBlock() { - res, err := chain.App.FinalizeBlock(&abci.RequestFinalizeBlock{ + res, err := chain.App.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: chain.ProposedHeader.Height, Time: chain.ProposedHeader.GetTime(), NextValidatorsHash: chain.NextVals.Hash(), @@ -302,7 +303,7 @@ func (chain *TestChain) NextBlock() { chain.commitBlock(res) } -func (chain *TestChain) commitBlock(res *abci.ResponseFinalizeBlock) { +func (chain *TestChain) commitBlock(res *abci.FinalizeBlockResponse) { _, err := chain.App.Commit() require.NoError(chain.TB, err) @@ -426,13 +427,37 @@ func (chain *TestChain) GetTrustedValidators(trustedHeight int64) (*cmttypes.Val Validators: histInfo.Valset, } - tmValidators, err := testutil.ToCmtValidators(valSet, sdk.DefaultPowerReduction) + tmValidators, err := ToCmtValidators(valSet, sdk.DefaultPowerReduction) if err != nil { return nil, err } return cmttypes.NewValidatorSet(tmValidators), nil } +// ToCmtValidators casts all validators to the corresponding CometBFT type. +func ToCmtValidators(v stakingtypes.Validators, r math.Int) ([]*cmttypes.Validator, error) { + validators := make([]*cmttypes.Validator, len(v.Validators)) + for i, val := range v.Validators { + pk, err := val.ConsPubKey() + if err != nil { + return nil, err + } + + tmPk, err := cryptocodec.ToCmtPubKeyInterface(pk) + if err != nil { + return nil, err + } + cmtVal := cmttypes.NewValidator(tmPk, val.ConsensusPower(r)) + + validators[i] = cmtVal + if err != nil { + return nil, err + } + } + + return validators, nil +} + // GetAcknowledgement retrieves an acknowledgement for the provided packet. If the // acknowledgement does not exist then testing will fail. func (chain *TestChain) GetAcknowledgement(packet channeltypes.Packet) []byte { diff --git a/testing/endpoint.go b/testing/endpoint.go index f4ec1213eef..0e06346baf8 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -619,7 +619,7 @@ func (endpoint *Endpoint) ChanUpgradeInit() error { endpoint.ChannelID, "upgrade-init", fmt.Sprintf("gov proposal for initialising channel upgrade: %s", endpoint.ChannelID), - false, + govtypesv1.ProposalType_PROPOSAL_TYPE_STANDARD, ) require.NoError(endpoint.Chain.TB, err)