From 41a6f7f143eec4e91976b505056cf3b26f2d768b Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 3 Apr 2024 15:57:21 +0200 Subject: [PATCH 1/3] refactor: standardise sub keeper usage in core ibc --- .../controller/keeper/keeper_test.go | 2 +- .../host/keeper/keeper_test.go | 4 ++-- modules/apps/29-fee/keeper/keeper_test.go | 4 ++-- modules/apps/callbacks/ibc_middleware_test.go | 2 +- modules/apps/transfer/keeper/keeper_test.go | 4 ++-- modules/core/02-client/genesis.go | 4 ++-- modules/core/02-client/keeper/keeper.go | 4 ++-- modules/core/02-client/migrations/v7/genesis_test.go | 4 ++-- modules/core/02-client/types/genesis_test.go | 2 +- modules/core/03-connection/genesis.go | 4 ++-- modules/core/03-connection/keeper/keeper.go | 4 ++-- modules/core/03-connection/keeper/migrations.go | 4 ++-- modules/core/04-channel/genesis.go | 4 ++-- modules/core/04-channel/keeper/keeper.go | 4 ++-- modules/core/04-channel/keeper/migrations.go | 4 ++-- modules/core/05-port/keeper/keeper.go | 4 ++-- modules/core/genesis.go | 4 ++-- modules/core/keeper/keeper.go | 12 ++++++------ modules/core/migrations/v7/genesis_test.go | 4 ++-- 19 files changed, 39 insertions(+), 39 deletions(-) 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 b8028d53354..1d77e77220d 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -361,6 +361,6 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { suite.chainA.GetSimApp().ICAControllerKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) ics4Wrapper = suite.chainA.GetSimApp().ICAControllerKeeper.GetICS4Wrapper() - _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) suite.Require().True(isChannelKeeper) } 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 3b25bf90a85..cac5309e148 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -411,14 +411,14 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { _, isFeeKeeper := ics4Wrapper.(ibcfeekeeper.Keeper) suite.Require().True(isFeeKeeper) - _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper := ics4Wrapper.(*channelkeeper.Keeper) suite.Require().False(isChannelKeeper) // set the ics4 wrapper to the channel keeper suite.chainA.GetSimApp().ICAHostKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) ics4Wrapper = suite.chainA.GetSimApp().ICAHostKeeper.GetICS4Wrapper() - _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) suite.Require().True(isChannelKeeper) _, isFeeKeeper = ics4Wrapper.(ibcfeekeeper.Keeper) suite.Require().False(isFeeKeeper) diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 36f1199fd3d..7d0905d9242 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -306,7 +306,7 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { // test if the ics4 wrapper is the channel keeper initially ics4Wrapper := suite.chainA.GetSimApp().IBCFeeKeeper.GetICS4Wrapper() - _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper := ics4Wrapper.(*channelkeeper.Keeper) suite.Require().True(isChannelKeeper) _, isFeeKeeper := ics4Wrapper.(keeper.Keeper) suite.Require().False(isFeeKeeper) @@ -317,6 +317,6 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { _, isFeeKeeper = ics4Wrapper.(keeper.Keeper) suite.Require().True(isFeeKeeper) - _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) suite.Require().False(isChannelKeeper) } diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index d041ea61b2c..026f2595524 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -89,7 +89,7 @@ func (s *CallbacksTestSuite) TestWithICS4Wrapper() { cbsMiddleware.WithICS4Wrapper(s.chainA.App.GetIBCKeeper().ChannelKeeper) ics4Wrapper := cbsMiddleware.GetICS4Wrapper() - s.Require().IsType(channelkeeper.Keeper{}, ics4Wrapper) + s.Require().IsType(&channelkeeper.Keeper{}, ics4Wrapper) } func (s *CallbacksTestSuite) TestSendPacket() { diff --git a/modules/apps/transfer/keeper/keeper_test.go b/modules/apps/transfer/keeper/keeper_test.go index 2e164f05c5b..78d71ce6a59 100644 --- a/modules/apps/transfer/keeper/keeper_test.go +++ b/modules/apps/transfer/keeper/keeper_test.go @@ -341,13 +341,13 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { // test if the ics4 wrapper is the channel keeper initially ics4Wrapper := suite.chainA.GetSimApp().TransferKeeper.GetICS4Wrapper() - _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper := ics4Wrapper.(*channelkeeper.Keeper) suite.Require().False(isChannelKeeper) // set the ics4 wrapper to the channel keeper suite.chainA.GetSimApp().TransferKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) ics4Wrapper = suite.chainA.GetSimApp().TransferKeeper.GetICS4Wrapper() - _, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) suite.Require().True(isChannelKeeper) } diff --git a/modules/core/02-client/genesis.go b/modules/core/02-client/genesis.go index 3127d665d55..d89cc5073ed 100644 --- a/modules/core/02-client/genesis.go +++ b/modules/core/02-client/genesis.go @@ -13,7 +13,7 @@ import ( // InitGenesis initializes the ibc client submodule's state from a provided genesis // state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { +func InitGenesis(ctx sdk.Context, k *keeper.Keeper, gs types.GenesisState) { if err := gs.Params.Validate(); err != nil { panic(fmt.Errorf("invalid ibc client genesis state parameters: %v", err)) } @@ -61,7 +61,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { // ExportGenesis returns the ibc client submodule's exported genesis. // NOTE: the export process is not optimized, it will iterate three // times over the 02-client sub-store. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { +func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) types.GenesisState { genClients := k.GetAllGenesisClients(ctx) clientsMetadata, err := k.GetAllClientMetadata(ctx, genClients) if err != nil { diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 1e5c6f0ca50..0de4bd6e4b7 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -33,12 +33,12 @@ type Keeper struct { } // NewKeeper creates a new NewKeeper instance -func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, sk types.StakingKeeper, uk types.UpgradeKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, sk types.StakingKeeper, uk types.UpgradeKeeper) *Keeper { router := types.NewRouter(key) localhostModule := localhost.NewLightClientModule(cdc, key) router.AddRoute(exported.Localhost, localhostModule) - return Keeper{ + return &Keeper{ storeKey: key, cdc: cdc, router: router, diff --git a/modules/core/02-client/migrations/v7/genesis_test.go b/modules/core/02-client/migrations/v7/genesis_test.go index 944e579892f..4abbb646f0c 100644 --- a/modules/core/02-client/migrations/v7/genesis_test.go +++ b/modules/core/02-client/migrations/v7/genesis_test.go @@ -33,7 +33,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1) solomachineMulti := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4) - clientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), *suite.chainA.App.GetIBCKeeper().ClientKeeper) + clientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper) // manually generate old proto buf definitions and set in genesis // NOTE: we cannot use 'ExportGenesis' for the solo machines since we are @@ -108,7 +108,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { // NOTE: tendermint clients are not pruned in genesis so the test should not have expired tendermint clients err := v7.MigrateStore(suite.chainA.GetContext(), suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey), suite.chainA.App.AppCodec(), suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) suite.Require().NoError(err) - expectedClientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), *suite.chainA.App.GetIBCKeeper().ClientKeeper) + expectedClientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper) cdc, ok := suite.chainA.App.AppCodec().(codec.ProtoCodecMarshaler) suite.Require().True(ok) diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index 2a91d94b764..ab9a5c18150 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -32,7 +32,7 @@ func (suite *TypesTestSuite) TestMarshalGenesisState() { err := path.EndpointA.UpdateClient() suite.Require().NoError(err) - genesis := client.ExportGenesis(suite.chainA.GetContext(), *suite.chainA.App.GetIBCKeeper().ClientKeeper) + genesis := client.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper) bz, err := cdc.MarshalJSON(&genesis) suite.Require().NoError(err) diff --git a/modules/core/03-connection/genesis.go b/modules/core/03-connection/genesis.go index fd315407664..46f214719dd 100644 --- a/modules/core/03-connection/genesis.go +++ b/modules/core/03-connection/genesis.go @@ -9,7 +9,7 @@ import ( // InitGenesis initializes the ibc connection submodule's state from a provided genesis // state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { +func InitGenesis(ctx sdk.Context, k *keeper.Keeper, gs types.GenesisState) { for _, connection := range gs.Connections { conn := types.NewConnectionEnd(connection.State, connection.ClientId, connection.Counterparty, connection.Versions, connection.DelayPeriod) k.SetConnection(ctx, connection.Id, conn) @@ -24,7 +24,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { } // ExportGenesis returns the ibc connection submodule's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { +func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) types.GenesisState { return types.GenesisState{ Connections: k.GetAllConnections(ctx), ClientConnectionPaths: k.GetAllClientConnectionPaths(ctx), diff --git a/modules/core/03-connection/keeper/keeper.go b/modules/core/03-connection/keeper/keeper.go index f7b787854fb..f8fc73efee2 100644 --- a/modules/core/03-connection/keeper/keeper.go +++ b/modules/core/03-connection/keeper/keeper.go @@ -29,8 +29,8 @@ type Keeper struct { } // NewKeeper creates a new IBC connection Keeper instance -func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, ck types.ClientKeeper) Keeper { - return Keeper{ +func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, ck types.ClientKeeper) *Keeper { + return &Keeper{ storeKey: key, cdc: cdc, legacySubspace: legacySubspace, diff --git a/modules/core/03-connection/keeper/migrations.go b/modules/core/03-connection/keeper/migrations.go index 64b84e7885e..c120ff6c2cd 100644 --- a/modules/core/03-connection/keeper/migrations.go +++ b/modules/core/03-connection/keeper/migrations.go @@ -9,11 +9,11 @@ import ( // Migrator is a struct for handling in-place store migrations. type Migrator struct { - keeper Keeper + keeper *Keeper } // NewMigrator returns a new Migrator. -func NewMigrator(keeper Keeper) Migrator { +func NewMigrator(keeper *Keeper) Migrator { return Migrator{keeper: keeper} } diff --git a/modules/core/04-channel/genesis.go b/modules/core/04-channel/genesis.go index 42481e558c1..eaccf98340b 100644 --- a/modules/core/04-channel/genesis.go +++ b/modules/core/04-channel/genesis.go @@ -11,7 +11,7 @@ import ( // InitGenesis initializes the ibc channel submodule's state from a provided genesis // state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { +func InitGenesis(ctx sdk.Context, k *keeper.Keeper, gs types.GenesisState) { if err := gs.Params.Validate(); err != nil { panic(fmt.Sprintf("invalid ibc channel genesis state parameters: %v", err)) } @@ -42,7 +42,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { } // ExportGenesis returns the ibc channel submodule's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { +func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) types.GenesisState { return types.GenesisState{ Channels: k.GetAllChannels(ctx), Acknowledgements: k.GetAllPacketAcks(ctx), diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 5272554204d..0249db46ca8 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -43,8 +43,8 @@ func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, clientKeeper types.ClientKeeper, connectionKeeper types.ConnectionKeeper, portKeeper types.PortKeeper, scopedKeeper exported.ScopedKeeper, -) Keeper { - return Keeper{ +) *Keeper { + return &Keeper{ storeKey: key, cdc: cdc, clientKeeper: clientKeeper, diff --git a/modules/core/04-channel/keeper/migrations.go b/modules/core/04-channel/keeper/migrations.go index 5bc0fcf0a41..2eacf49aca7 100644 --- a/modules/core/04-channel/keeper/migrations.go +++ b/modules/core/04-channel/keeper/migrations.go @@ -8,11 +8,11 @@ import ( // Migrator is a struct for handling in-place store migrations. type Migrator struct { - keeper Keeper + keeper *Keeper } // NewMigrator returns a new Migrator. -func NewMigrator(keeper Keeper) Migrator { +func NewMigrator(keeper *Keeper) Migrator { return Migrator{keeper: keeper} } diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index 68e89ecac69..a7475a95fa0 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -21,8 +21,8 @@ type Keeper struct { } // NewKeeper creates a new IBC connection Keeper instance -func NewKeeper(sck exported.ScopedKeeper) Keeper { - return Keeper{ +func NewKeeper(sck exported.ScopedKeeper) *Keeper { + return &Keeper{ scopedKeeper: sck, } } diff --git a/modules/core/genesis.go b/modules/core/genesis.go index d1379de4b84..3eaada47208 100644 --- a/modules/core/genesis.go +++ b/modules/core/genesis.go @@ -13,7 +13,7 @@ import ( // InitGenesis initializes the ibc state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs *types.GenesisState) { - client.InitGenesis(ctx, *k.ClientKeeper, gs.ClientGenesis) + client.InitGenesis(ctx, k.ClientKeeper, gs.ClientGenesis) connection.InitGenesis(ctx, k.ConnectionKeeper, gs.ConnectionGenesis) channel.InitGenesis(ctx, k.ChannelKeeper, gs.ChannelGenesis) } @@ -21,7 +21,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs *types.GenesisState) { // ExportGenesis returns the ibc exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { return &types.GenesisState{ - ClientGenesis: client.ExportGenesis(ctx, *k.ClientKeeper), + ClientGenesis: client.ExportGenesis(ctx, k.ClientKeeper), ConnectionGenesis: connection.ExportGenesis(ctx, k.ConnectionKeeper), ChannelGenesis: channel.ExportGenesis(ctx, k.ChannelKeeper), } diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index d5982a6faa6..c5ac800a2c9 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -29,8 +29,8 @@ type Keeper struct { cdc codec.BinaryCodec ClientKeeper *clientkeeper.Keeper - ConnectionKeeper connectionkeeper.Keeper - ChannelKeeper channelkeeper.Keeper + ConnectionKeeper *connectionkeeper.Keeper + ChannelKeeper *channelkeeper.Keeper PortKeeper *portkeeper.Keeper Router *porttypes.Router @@ -60,16 +60,16 @@ func NewKeeper( } clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper, upgradeKeeper) - connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, &clientKeeper) + connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) - channelKeeper := channelkeeper.NewKeeper(cdc, key, &clientKeeper, &connectionKeeper, &portKeeper, scopedKeeper) + channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) return &Keeper{ cdc: cdc, - ClientKeeper: &clientKeeper, + ClientKeeper: clientKeeper, ConnectionKeeper: connectionKeeper, ChannelKeeper: channelKeeper, - PortKeeper: &portKeeper, + PortKeeper: portKeeper, authority: authority, } } diff --git a/modules/core/migrations/v7/genesis_test.go b/modules/core/migrations/v7/genesis_test.go index 781d4f594ba..de941f3a2d2 100644 --- a/modules/core/migrations/v7/genesis_test.go +++ b/modules/core/migrations/v7/genesis_test.go @@ -61,7 +61,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1) solomachineMulti := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4) - clientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), *suite.chainA.App.GetIBCKeeper().ClientKeeper) + clientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper) // manually generate old proto buf definitions and set in genesis // NOTE: we cannot use 'ExportGenesis' for the solo machines since we are @@ -135,7 +135,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { // NOTE: tendermint clients are not pruned in genesis so the test should not have expired tendermint clients err := clientv7.MigrateStore(suite.chainA.GetContext(), suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey), suite.chainA.App.AppCodec(), suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) suite.Require().NoError(err) - expectedClientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), *suite.chainA.App.GetIBCKeeper().ClientKeeper) + expectedClientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper) cdc := suite.chainA.App.AppCodec().(*codec.ProtoCodec) From 5800bad470543c693ed65fbd1201c2ad8cb95970 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 10 Apr 2024 10:25:11 +0200 Subject: [PATCH 2/3] testing: type assertion nits --- .../27-interchain-accounts/controller/keeper/keeper_test.go | 3 +-- .../apps/27-interchain-accounts/host/keeper/keeper_test.go | 4 ++-- modules/apps/29-fee/keeper/keeper_test.go | 5 ++--- modules/apps/callbacks/ibc_middleware_test.go | 2 +- modules/apps/transfer/keeper/keeper_test.go | 3 +-- 5 files changed, 7 insertions(+), 10 deletions(-) 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 1d77e77220d..48c41afc108 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -361,6 +361,5 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { suite.chainA.GetSimApp().ICAControllerKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) ics4Wrapper = suite.chainA.GetSimApp().ICAControllerKeeper.GetICS4Wrapper() - _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) - suite.Require().True(isChannelKeeper) + suite.Require().IsType((*channelkeeper.Keeper)(nil), ics4Wrapper) } 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 cac5309e148..acbc274ef2f 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -418,8 +418,8 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { suite.chainA.GetSimApp().ICAHostKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) ics4Wrapper = suite.chainA.GetSimApp().ICAHostKeeper.GetICS4Wrapper() - _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) - suite.Require().True(isChannelKeeper) + suite.Require().IsType((*channelkeeper.Keeper)(nil), ics4Wrapper) + _, isFeeKeeper = ics4Wrapper.(ibcfeekeeper.Keeper) suite.Require().False(isFeeKeeper) } diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 2d3b128558a..1a29a98d5ef 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -296,8 +296,7 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { // test if the ics4 wrapper is the channel keeper initially ics4Wrapper := suite.chainA.GetSimApp().IBCFeeKeeper.GetICS4Wrapper() - _, isChannelKeeper := ics4Wrapper.(*channelkeeper.Keeper) - suite.Require().True(isChannelKeeper) + suite.Require().IsType((*channelkeeper.Keeper)(nil), ics4Wrapper) _, isFeeKeeper := ics4Wrapper.(keeper.Keeper) suite.Require().False(isFeeKeeper) @@ -307,6 +306,6 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { _, isFeeKeeper = ics4Wrapper.(keeper.Keeper) suite.Require().True(isFeeKeeper) - _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) + _, isChannelKeeper := ics4Wrapper.(*channelkeeper.Keeper) suite.Require().False(isChannelKeeper) } diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index b735ed961b5..85fe56f0a34 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -89,7 +89,7 @@ func (s *CallbacksTestSuite) TestWithICS4Wrapper() { cbsMiddleware.WithICS4Wrapper(s.chainA.App.GetIBCKeeper().ChannelKeeper) ics4Wrapper := cbsMiddleware.GetICS4Wrapper() - s.Require().IsType(&channelkeeper.Keeper{}, ics4Wrapper) + s.Require().IsType((*channelkeeper.Keeper)(nil), ics4Wrapper) } func (s *CallbacksTestSuite) TestSendPacket() { diff --git a/modules/apps/transfer/keeper/keeper_test.go b/modules/apps/transfer/keeper/keeper_test.go index 78d71ce6a59..0d0da50c002 100644 --- a/modules/apps/transfer/keeper/keeper_test.go +++ b/modules/apps/transfer/keeper/keeper_test.go @@ -348,6 +348,5 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { suite.chainA.GetSimApp().TransferKeeper.WithICS4Wrapper(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) ics4Wrapper = suite.chainA.GetSimApp().TransferKeeper.GetICS4Wrapper() - _, isChannelKeeper = ics4Wrapper.(*channelkeeper.Keeper) - suite.Require().True(isChannelKeeper) + suite.Require().IsType((*channelkeeper.Keeper)(nil), ics4Wrapper) } From 1c1799a9a457a73c04df763f026ad30e47e149f0 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 10 Apr 2024 12:34:47 +0200 Subject: [PATCH 3/3] refactor: use pointer receivers on core module methods --- .../controller/keeper/keeper_test.go | 2 +- modules/apps/callbacks/ibc_middleware_test.go | 8 +- modules/core/02-client/keeper/client.go | 8 +- modules/core/02-client/keeper/encoding.go | 12 +- modules/core/02-client/keeper/grpc_query.go | 20 +-- modules/core/02-client/keeper/keeper.go | 62 ++++----- .../core/03-connection/keeper/grpc_query.go | 12 +- .../core/03-connection/keeper/handshake.go | 8 +- modules/core/03-connection/keeper/keeper.go | 32 ++--- modules/core/03-connection/keeper/verify.go | 22 ++-- modules/core/04-channel/keeper/export_test.go | 10 +- modules/core/04-channel/keeper/grpc_query.go | 34 ++--- modules/core/04-channel/keeper/handshake.go | 20 +-- modules/core/04-channel/keeper/keeper.go | 124 +++++++++--------- modules/core/04-channel/keeper/packet.go | 8 +- modules/core/04-channel/keeper/timeout.go | 6 +- modules/core/04-channel/keeper/upgrade.go | 44 +++---- modules/core/05-port/keeper/keeper.go | 6 +- modules/core/keeper/grpc_query.go | 66 +++++----- modules/core/keeper/keeper.go | 4 +- modules/core/keeper/msg_server.go | 62 ++++----- modules/core/keeper/msg_server_test.go | 26 ++-- 22 files changed, 298 insertions(+), 298 deletions(-) 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 48c41afc108..b733adff9ca 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -354,7 +354,7 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() { // test if the ics4 wrapper is the channel keeper initially ics4Wrapper := suite.chainA.GetSimApp().ICAControllerKeeper.GetICS4Wrapper() - _, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper) + _, isChannelKeeper := ics4Wrapper.(*channelkeeper.Keeper) suite.Require().False(isChannelKeeper) // set the ics4 wrapper to the channel keeper diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index 85fe56f0a34..2631c639d6a 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -33,21 +33,21 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { { "success", func() { - _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, channelkeeper.Keeper{}, simapp.ContractKeeper{}, maxCallbackGas) + _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, &channelkeeper.Keeper{}, simapp.ContractKeeper{}, maxCallbackGas) }, nil, }, { "panics with nil underlying app", func() { - _ = ibccallbacks.NewIBCMiddleware(nil, channelkeeper.Keeper{}, simapp.ContractKeeper{}, maxCallbackGas) + _ = ibccallbacks.NewIBCMiddleware(nil, &channelkeeper.Keeper{}, simapp.ContractKeeper{}, maxCallbackGas) }, fmt.Errorf("underlying application does not implement %T", (*types.CallbacksCompatibleModule)(nil)), }, { "panics with nil contract keeper", func() { - _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, channelkeeper.Keeper{}, nil, maxCallbackGas) + _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, &channelkeeper.Keeper{}, nil, maxCallbackGas) }, fmt.Errorf("contract keeper cannot be nil"), }, @@ -61,7 +61,7 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { { "panics with zero maxCallbackGas", func() { - _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, channelkeeper.Keeper{}, simapp.ContractKeeper{}, uint64(0)) + _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, &channelkeeper.Keeper{}, simapp.ContractKeeper{}, uint64(0)) }, fmt.Errorf("maxCallbackGas cannot be zero"), }, diff --git a/modules/core/02-client/keeper/client.go b/modules/core/02-client/keeper/client.go index 4711491faae..07adefa2e53 100644 --- a/modules/core/02-client/keeper/client.go +++ b/modules/core/02-client/keeper/client.go @@ -17,7 +17,7 @@ import ( // client identifier. The light client module is responsible for setting any client-specific data in the store // via the Initialize method. This includes the client state, initial consensus state and any associated // metadata. The generated client identifier will be returned if a client was successfully initialized. -func (k Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, consensusState []byte) (string, error) { +func (k *Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, consensusState []byte) (string, error) { if clientType == exported.Localhost { return "", errorsmod.Wrapf(types.ErrInvalidClientType, "cannot create client of type: %s", clientType) } @@ -60,7 +60,7 @@ func (k Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, co } // UpdateClient updates the consensus state and the state root from a provided header. -func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error { +func (k *Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error { if status := k.GetClientStatus(ctx, clientID); status != exported.Active { return errorsmod.Wrapf(types.ErrClientNotActive, "cannot update client (%s) with status %s", clientID, status) } @@ -122,7 +122,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exporte // UpgradeClient upgrades the client to a new client state if this new client was committed to // by the old client at the specified upgrade height -func (k Keeper) UpgradeClient( +func (k *Keeper) UpgradeClient( ctx sdk.Context, clientID string, upgradedClient, upgradedConsState, upgradeClientProof, upgradeConsensusStateProof []byte, @@ -167,7 +167,7 @@ func (k Keeper) UpgradeClient( // is responsible for validating the parameters of the substitute (ensuring they match the subject's parameters) // as well as copying the necessary consensus states from the substitute to the subject client store. // The substitute must be Active and the subject must not be Active. -func (k Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClientID string) error { +func (k *Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClientID string) error { if status := k.GetClientStatus(ctx, subjectClientID); status == exported.Active { return errorsmod.Wrapf(types.ErrInvalidRecoveryClient, "cannot recover %s subject client", exported.Active) } diff --git a/modules/core/02-client/keeper/encoding.go b/modules/core/02-client/keeper/encoding.go index 63191d8a3d8..19a927165e2 100644 --- a/modules/core/02-client/keeper/encoding.go +++ b/modules/core/02-client/keeper/encoding.go @@ -7,36 +7,36 @@ import ( // UnmarshalClientState attempts to decode and return an ClientState object from // raw encoded bytes. -func (k Keeper) UnmarshalClientState(bz []byte) (exported.ClientState, error) { +func (k *Keeper) UnmarshalClientState(bz []byte) (exported.ClientState, error) { return types.UnmarshalClientState(k.cdc, bz) } // MustUnmarshalClientState attempts to decode and return an ClientState object from // raw encoded bytes. It panics on error. -func (k Keeper) MustUnmarshalClientState(bz []byte) exported.ClientState { +func (k *Keeper) MustUnmarshalClientState(bz []byte) exported.ClientState { return types.MustUnmarshalClientState(k.cdc, bz) } // UnmarshalConsensusState attempts to decode and return an ConsensusState object from // raw encoded bytes. -func (k Keeper) UnmarshalConsensusState(bz []byte) (exported.ConsensusState, error) { +func (k *Keeper) UnmarshalConsensusState(bz []byte) (exported.ConsensusState, error) { return types.UnmarshalConsensusState(k.cdc, bz) } // MustUnmarshalConsensusState attempts to decode and return an ConsensusState object from // raw encoded bytes. It panics on error. -func (k Keeper) MustUnmarshalConsensusState(bz []byte) exported.ConsensusState { +func (k *Keeper) MustUnmarshalConsensusState(bz []byte) exported.ConsensusState { return types.MustUnmarshalConsensusState(k.cdc, bz) } // MustMarshalClientState attempts to encode an ClientState object and returns the // raw encoded bytes. It panics on error. -func (k Keeper) MustMarshalClientState(clientState exported.ClientState) []byte { +func (k *Keeper) MustMarshalClientState(clientState exported.ClientState) []byte { return types.MustMarshalClientState(k.cdc, clientState) } // MustMarshalConsensusState attempts to encode an ConsensusState object and returns the // raw encoded bytes. It panics on error. -func (k Keeper) MustMarshalConsensusState(consensusState exported.ConsensusState) []byte { +func (k *Keeper) MustMarshalConsensusState(consensusState exported.ConsensusState) []byte { return types.MustMarshalConsensusState(k.cdc, consensusState) } diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index a94ff45dc33..41c52f7c7d6 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -25,7 +25,7 @@ import ( var _ types.QueryServer = (*Keeper)(nil) // ClientState implements the Query/ClientState gRPC method -func (k Keeper) ClientState(c context.Context, req *types.QueryClientStateRequest) (*types.QueryClientStateResponse, error) { +func (k *Keeper) ClientState(c context.Context, req *types.QueryClientStateRequest) (*types.QueryClientStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -56,7 +56,7 @@ func (k Keeper) ClientState(c context.Context, req *types.QueryClientStateReques } // ClientStates implements the Query/ClientStates gRPC method -func (k Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequest) (*types.QueryClientStatesResponse, error) { +func (k *Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequest) (*types.QueryClientStatesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -100,7 +100,7 @@ func (k Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ } // ConsensusState implements the Query/ConsensusState gRPC method -func (k Keeper) ConsensusState(c context.Context, req *types.QueryConsensusStateRequest) (*types.QueryConsensusStateResponse, error) { +func (k *Keeper) ConsensusState(c context.Context, req *types.QueryConsensusStateRequest) (*types.QueryConsensusStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -147,7 +147,7 @@ func (k Keeper) ConsensusState(c context.Context, req *types.QueryConsensusState } // ConsensusStates implements the Query/ConsensusStates gRPC method -func (k Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStatesRequest) (*types.QueryConsensusStatesResponse, error) { +func (k *Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStatesRequest) (*types.QueryConsensusStatesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -191,7 +191,7 @@ func (k Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat } // ConsensusStateHeights implements the Query/ConsensusStateHeights gRPC method -func (k Keeper) ConsensusStateHeights(c context.Context, req *types.QueryConsensusStateHeightsRequest) (*types.QueryConsensusStateHeightsResponse, error) { +func (k *Keeper) ConsensusStateHeights(c context.Context, req *types.QueryConsensusStateHeightsRequest) (*types.QueryConsensusStateHeightsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -230,7 +230,7 @@ func (k Keeper) ConsensusStateHeights(c context.Context, req *types.QueryConsens } // ClientStatus implements the Query/ClientStatus gRPC method -func (k Keeper) ClientStatus(c context.Context, req *types.QueryClientStatusRequest) (*types.QueryClientStatusResponse, error) { +func (k *Keeper) ClientStatus(c context.Context, req *types.QueryClientStatusRequest) (*types.QueryClientStatusResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -248,7 +248,7 @@ func (k Keeper) ClientStatus(c context.Context, req *types.QueryClientStatusRequ } // ClientParams implements the Query/ClientParams gRPC method -func (k Keeper) ClientParams(c context.Context, _ *types.QueryClientParamsRequest) (*types.QueryClientParamsResponse, error) { +func (k *Keeper) ClientParams(c context.Context, _ *types.QueryClientParamsRequest) (*types.QueryClientParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) params := k.GetParams(ctx) @@ -258,7 +258,7 @@ func (k Keeper) ClientParams(c context.Context, _ *types.QueryClientParamsReques } // UpgradedClientState implements the Query/UpgradedClientState gRPC method -func (k Keeper) UpgradedClientState(c context.Context, req *types.QueryUpgradedClientStateRequest) (*types.QueryUpgradedClientStateResponse, error) { +func (k *Keeper) UpgradedClientState(c context.Context, req *types.QueryUpgradedClientStateRequest) (*types.QueryUpgradedClientStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -293,7 +293,7 @@ func (k Keeper) UpgradedClientState(c context.Context, req *types.QueryUpgradedC } // UpgradedConsensusState implements the Query/UpgradedConsensusState gRPC method -func (k Keeper) UpgradedConsensusState(c context.Context, req *types.QueryUpgradedConsensusStateRequest) (*types.QueryUpgradedConsensusStateResponse, error) { +func (k *Keeper) UpgradedConsensusState(c context.Context, req *types.QueryUpgradedConsensusStateRequest) (*types.QueryUpgradedConsensusStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -325,7 +325,7 @@ func (k Keeper) UpgradedConsensusState(c context.Context, req *types.QueryUpgrad // VerifyMembership implements the Query/VerifyMembership gRPC method // NOTE: Any state changes made within this handler are discarded by leveraging a cached context. Gas is consumed for underlying state access. // This gRPC method is intended to be used within the context of the state machine and delegates to light clients to verify proofs. -func (k Keeper) VerifyMembership(c context.Context, req *types.QueryVerifyMembershipRequest) (*types.QueryVerifyMembershipResponse, error) { +func (k *Keeper) VerifyMembership(c context.Context, req *types.QueryVerifyMembershipRequest) (*types.QueryVerifyMembershipResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 678ffcebf97..f65f76746a7 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -54,17 +54,17 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { } // GetRouter returns the light client module router. -func (k Keeper) GetRouter() *types.Router { +func (k *Keeper) GetRouter() *types.Router { return k.router } // Route returns the light client module for the given client identifier. -func (k Keeper) Route(clientID string) (exported.LightClientModule, bool) { +func (k *Keeper) Route(clientID string) (exported.LightClientModule, bool) { return k.router.GetRoute(clientID) } // CreateLocalhostClient initialises the 09-localhost client state and sets it in state. -func (k Keeper) CreateLocalhostClient(ctx sdk.Context) error { +func (k *Keeper) CreateLocalhostClient(ctx sdk.Context) error { clientModule, found := k.router.GetRoute(exported.LocalhostClientID) if !found { return errorsmod.Wrap(types.ErrRouteNotFound, exported.LocalhostClientID) @@ -74,7 +74,7 @@ func (k Keeper) CreateLocalhostClient(ctx sdk.Context) error { } // UpdateLocalhostClient updates the 09-localhost client to the latest block height and chain ID. -func (k Keeper) UpdateLocalhostClient(ctx sdk.Context, clientState exported.ClientState) []exported.Height { +func (k *Keeper) UpdateLocalhostClient(ctx sdk.Context, clientState exported.ClientState) []exported.Height { clientModule, found := k.router.GetRoute(exported.LocalhostClientID) if !found { panic(errorsmod.Wrap(types.ErrRouteNotFound, exported.LocalhostClientID)) @@ -93,7 +93,7 @@ func (k *Keeper) SetConsensusHost(consensusHost types.ConsensusHost) { } // GenerateClientIdentifier returns the next client identifier. -func (k Keeper) GenerateClientIdentifier(ctx sdk.Context, clientType string) string { +func (k *Keeper) GenerateClientIdentifier(ctx sdk.Context, clientType string) string { nextClientSeq := k.GetNextClientSequence(ctx) clientID := types.FormatClientIdentifier(clientType, nextClientSeq) @@ -134,13 +134,13 @@ func (k *Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, heigh // SetClientConsensusState sets a ConsensusState to a particular client at the given // height -func (k Keeper) SetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height, consensusState exported.ConsensusState) { +func (k *Keeper) SetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height, consensusState exported.ConsensusState) { store := k.ClientStore(ctx, clientID) store.Set(host.ConsensusStateKey(height), k.MustMarshalConsensusState(consensusState)) } // GetNextClientSequence gets the next client sequence from the store. -func (k Keeper) GetNextClientSequence(ctx sdk.Context) uint64 { +func (k *Keeper) GetNextClientSequence(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.KeyNextClientSequence)) if len(bz) == 0 { @@ -151,7 +151,7 @@ func (k Keeper) GetNextClientSequence(ctx sdk.Context) uint64 { } // SetNextClientSequence sets the next client sequence to the store. -func (k Keeper) SetNextClientSequence(ctx sdk.Context, sequence uint64) { +func (k *Keeper) SetNextClientSequence(ctx sdk.Context, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set([]byte(types.KeyNextClientSequence), bz) @@ -160,7 +160,7 @@ func (k Keeper) SetNextClientSequence(ctx sdk.Context, sequence uint64) { // IterateConsensusStates provides an iterator over all stored consensus states. // objects. For each State object, cb will be called. If the cb returns true, // the iterator will close and stop. -func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, cs types.ConsensusStateWithHeight) bool) { +func (k *Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, cs types.ConsensusStateWithHeight) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, host.KeyClientStorePrefix) @@ -185,7 +185,7 @@ func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, // iterateMetadata provides an iterator over all stored metadata keys in the client store. // For each metadata object, it will perform a callback. -func (k Keeper) iterateMetadata(ctx sdk.Context, cb func(clientID string, key, value []byte) bool) { +func (k *Keeper) iterateMetadata(ctx sdk.Context, cb func(clientID string, key, value []byte) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, host.KeyClientStorePrefix) @@ -220,7 +220,7 @@ func (k Keeper) iterateMetadata(ctx sdk.Context, cb func(clientID string, key, v } // GetAllGenesisClients returns all the clients in state with their client ids returned as IdentifiedClientState -func (k Keeper) GetAllGenesisClients(ctx sdk.Context) types.IdentifiedClientStates { +func (k *Keeper) GetAllGenesisClients(ctx sdk.Context) types.IdentifiedClientStates { var genClients types.IdentifiedClientStates k.IterateClientStates(ctx, nil, func(clientID string, cs exported.ClientState) bool { genClients = append(genClients, types.NewIdentifiedClientState(clientID, cs)) @@ -233,7 +233,7 @@ func (k Keeper) GetAllGenesisClients(ctx sdk.Context) types.IdentifiedClientStat // GetAllClientMetadata will take a list of IdentifiedClientState and return a list // of IdentifiedGenesisMetadata necessary for exporting and importing client metadata // into the client store. -func (k Keeper) GetAllClientMetadata(ctx sdk.Context, genClients []types.IdentifiedClientState) ([]types.IdentifiedGenesisMetadata, error) { +func (k *Keeper) GetAllClientMetadata(ctx sdk.Context, genClients []types.IdentifiedClientState) ([]types.IdentifiedGenesisMetadata, error) { metadataMap := make(map[string][]types.GenesisMetadata) k.iterateMetadata(ctx, func(clientID string, key, value []byte) bool { metadataMap[clientID] = append(metadataMap[clientID], types.NewGenesisMetadata(key, value)) @@ -255,7 +255,7 @@ func (k Keeper) GetAllClientMetadata(ctx sdk.Context, genClients []types.Identif } // SetAllClientMetadata takes a list of IdentifiedGenesisMetadata and stores all of the metadata in the client store at the appropriate paths. -func (k Keeper) SetAllClientMetadata(ctx sdk.Context, genMetadata []types.IdentifiedGenesisMetadata) { +func (k *Keeper) SetAllClientMetadata(ctx sdk.Context, genMetadata []types.IdentifiedGenesisMetadata) { for _, igm := range genMetadata { // create client store store := k.ClientStore(ctx, igm.ClientId) @@ -267,7 +267,7 @@ func (k Keeper) SetAllClientMetadata(ctx sdk.Context, genMetadata []types.Identi } // GetAllConsensusStates returns all stored client consensus states. -func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusStates { +func (k *Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusStates { clientConsStates := make(types.ClientsConsensusStates, 0) mapClientIDToConsStateIdx := make(map[string]int) @@ -293,13 +293,13 @@ func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusSta // HasClientConsensusState returns if keeper has a ConsensusState for a particular // client at the given height -func (k Keeper) HasClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) bool { +func (k *Keeper) HasClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) bool { store := k.ClientStore(ctx, clientID) return store.Has(host.ConsensusStateKey(height)) } // GetLatestClientConsensusState gets the latest ConsensusState stored for a given client -func (k Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string) (exported.ConsensusState, bool) { +func (k *Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string) (exported.ConsensusState, bool) { clientModule, found := k.router.GetRoute(clientID) if !found { return nil, false @@ -311,7 +311,7 @@ func (k Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string) // GetSelfConsensusState introspects the (self) past historical info at a given height // and returns the expected consensus state at that height. // For now, can only retrieve self consensus states for the current revision -func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, error) { +func (k *Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, error) { return k.consensusHost.GetSelfConsensusState(ctx, height) } @@ -319,34 +319,34 @@ func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) ( // This function is only used to validate the client state the counterparty stores for this chain. // NOTE: If the client type is not of type Tendermint then delegate to a custom client validator function. // This allows support for non-Tendermint clients, for example 08-wasm clients. -func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error { +func (k *Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error { return k.consensusHost.ValidateSelfClient(ctx, clientState) } // GetUpgradePlan executes the upgrade keeper GetUpgradePlan function. -func (k Keeper) GetUpgradePlan(ctx sdk.Context) (upgradetypes.Plan, error) { +func (k *Keeper) GetUpgradePlan(ctx sdk.Context) (upgradetypes.Plan, error) { return k.upgradeKeeper.GetUpgradePlan(ctx) } // GetUpgradedClient executes the upgrade keeper GetUpgradeClient function. -func (k Keeper) GetUpgradedClient(ctx sdk.Context, planHeight int64) ([]byte, error) { +func (k *Keeper) GetUpgradedClient(ctx sdk.Context, planHeight int64) ([]byte, error) { return k.upgradeKeeper.GetUpgradedClient(ctx, planHeight) } // GetUpgradedConsensusState returns the upgraded consensus state -func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, planHeight int64) ([]byte, error) { +func (k *Keeper) GetUpgradedConsensusState(ctx sdk.Context, planHeight int64) ([]byte, error) { return k.upgradeKeeper.GetUpgradedConsensusState(ctx, planHeight) } // SetUpgradedConsensusState executes the upgrade keeper SetUpgradedConsensusState function. -func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error { +func (k *Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error { return k.upgradeKeeper.SetUpgradedConsensusState(ctx, planHeight, bz) } // IterateClientStates provides an iterator over all stored ibc ClientState // objects using the provided store prefix. For each ClientState object, cb will be called. If the cb returns true, // the iterator will close and stop. -func (k Keeper) IterateClientStates(ctx sdk.Context, storePrefix []byte, cb func(clientID string, cs exported.ClientState) bool) { +func (k *Keeper) IterateClientStates(ctx sdk.Context, storePrefix []byte, cb func(clientID string, cs exported.ClientState) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, host.PrefixedClientStoreKey(storePrefix)) @@ -368,7 +368,7 @@ func (k Keeper) IterateClientStates(ctx sdk.Context, storePrefix []byte, cb func } // GetAllClients returns all stored light client State objects. -func (k Keeper) GetAllClients(ctx sdk.Context) []exported.ClientState { +func (k *Keeper) GetAllClients(ctx sdk.Context) []exported.ClientState { var states []exported.ClientState k.IterateClientStates(ctx, nil, func(_ string, state exported.ClientState) bool { states = append(states, state) @@ -380,14 +380,14 @@ func (k Keeper) GetAllClients(ctx sdk.Context) []exported.ClientState { // ClientStore returns isolated prefix store for each client so they can read/write in separate // namespace without being able to read/write other client's data -func (k Keeper) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore { +func (k *Keeper) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore { clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID)) return prefix.NewStore(ctx.KVStore(k.storeKey), clientPrefix) } // GetClientStatus returns the status for a client state given a client identifier. If the client type is not in the allowed // clients param field, Unauthorized is returned, otherwise the client state status is returned. -func (k Keeper) GetClientStatus(ctx sdk.Context, clientID string) exported.Status { +func (k *Keeper) GetClientStatus(ctx sdk.Context, clientID string) exported.Status { clientType, _, err := types.ParseClientIdentifier(clientID) if err != nil { return exported.Unauthorized @@ -407,7 +407,7 @@ func (k Keeper) GetClientStatus(ctx sdk.Context, clientID string) exported.Statu // GetClientLatestHeight returns the latest height of a client state for a given client identifier. If the client type is not in the allowed // clients param field, a zero value height is returned, otherwise the client state latest height is returned. -func (k Keeper) GetClientLatestHeight(ctx sdk.Context, clientID string) types.Height { +func (k *Keeper) GetClientLatestHeight(ctx sdk.Context, clientID string) types.Height { clientType, _, err := types.ParseClientIdentifier(clientID) if err != nil { return types.ZeroHeight() @@ -431,7 +431,7 @@ func (k Keeper) GetClientLatestHeight(ctx sdk.Context, clientID string) types.He } // GetClientTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the given height. -func (k Keeper) GetClientTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) { +func (k *Keeper) GetClientTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) { clientType, _, err := types.ParseClientIdentifier(clientID) if err != nil { return 0, errorsmod.Wrapf(err, "clientID (%s)", clientID) @@ -450,7 +450,7 @@ func (k Keeper) GetClientTimestampAtHeight(ctx sdk.Context, clientID string, hei } // GetParams returns the total set of ibc-client parameters. -func (k Keeper) GetParams(ctx sdk.Context) types.Params { +func (k *Keeper) GetParams(ctx sdk.Context) types.Params { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.ParamsKey)) if bz == nil { // only panic on unset params and not on empty params @@ -463,14 +463,14 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { } // SetParams sets the total set of ibc-client parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(¶ms) store.Set([]byte(types.ParamsKey), bz) } // ScheduleIBCSoftwareUpgrade schedules an upgrade for the IBC client. -func (k Keeper) ScheduleIBCSoftwareUpgrade(ctx sdk.Context, plan upgradetypes.Plan, upgradedClientState exported.ClientState) error { +func (k *Keeper) ScheduleIBCSoftwareUpgrade(ctx sdk.Context, plan upgradetypes.Plan, upgradedClientState exported.ClientState) error { // zero out any custom fields before setting cs, ok := upgradedClientState.(*ibctm.ClientState) if !ok { diff --git a/modules/core/03-connection/keeper/grpc_query.go b/modules/core/03-connection/keeper/grpc_query.go index 1c9d7aef311..5832b1b517b 100644 --- a/modules/core/03-connection/keeper/grpc_query.go +++ b/modules/core/03-connection/keeper/grpc_query.go @@ -20,7 +20,7 @@ import ( var _ types.QueryServer = (*Keeper)(nil) // Connection implements the Query/Connection gRPC method -func (k Keeper) Connection(c context.Context, req *types.QueryConnectionRequest) (*types.QueryConnectionResponse, error) { +func (k *Keeper) Connection(c context.Context, req *types.QueryConnectionRequest) (*types.QueryConnectionResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -45,7 +45,7 @@ func (k Keeper) Connection(c context.Context, req *types.QueryConnectionRequest) } // Connections implements the Query/Connections gRPC method -func (k Keeper) Connections(c context.Context, req *types.QueryConnectionsRequest) (*types.QueryConnectionsResponse, error) { +func (k *Keeper) Connections(c context.Context, req *types.QueryConnectionsRequest) (*types.QueryConnectionsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -82,7 +82,7 @@ func (k Keeper) Connections(c context.Context, req *types.QueryConnectionsReques } // ClientConnections implements the Query/ClientConnections gRPC method -func (k Keeper) ClientConnections(c context.Context, req *types.QueryClientConnectionsRequest) (*types.QueryClientConnectionsResponse, error) { +func (k *Keeper) ClientConnections(c context.Context, req *types.QueryClientConnectionsRequest) (*types.QueryClientConnectionsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -107,7 +107,7 @@ func (k Keeper) ClientConnections(c context.Context, req *types.QueryClientConne } // ConnectionClientState implements the Query/ConnectionClientState gRPC method -func (k Keeper) ConnectionClientState(c context.Context, req *types.QueryConnectionClientStateRequest) (*types.QueryConnectionClientStateResponse, error) { +func (k *Keeper) ConnectionClientState(c context.Context, req *types.QueryConnectionClientStateRequest) (*types.QueryConnectionClientStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -141,7 +141,7 @@ func (k Keeper) ConnectionClientState(c context.Context, req *types.QueryConnect } // ConnectionConsensusState implements the Query/ConnectionConsensusState gRPC method -func (k Keeper) ConnectionConsensusState(c context.Context, req *types.QueryConnectionConsensusStateRequest) (*types.QueryConnectionConsensusStateResponse, error) { +func (k *Keeper) ConnectionConsensusState(c context.Context, req *types.QueryConnectionConsensusStateRequest) (*types.QueryConnectionConsensusStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -179,7 +179,7 @@ func (k Keeper) ConnectionConsensusState(c context.Context, req *types.QueryConn } // ConnectionParams implements the Query/ConnectionParams gRPC method. -func (k Keeper) ConnectionParams(c context.Context, req *types.QueryConnectionParamsRequest) (*types.QueryConnectionParamsResponse, error) { +func (k *Keeper) ConnectionParams(c context.Context, req *types.QueryConnectionParamsRequest) (*types.QueryConnectionParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) params := k.GetParams(ctx) diff --git a/modules/core/03-connection/keeper/handshake.go b/modules/core/03-connection/keeper/handshake.go index b85ccd1e68e..8fd698ac91a 100644 --- a/modules/core/03-connection/keeper/handshake.go +++ b/modules/core/03-connection/keeper/handshake.go @@ -18,7 +18,7 @@ import ( // // NOTE: Msg validation verifies the supplied identifiers and ensures that the counterparty // connection identifier is empty. -func (k Keeper) ConnOpenInit( +func (k *Keeper) ConnOpenInit( ctx sdk.Context, clientID string, counterparty types.Counterparty, // counterpartyPrefix, counterpartyClientIdentifier @@ -62,7 +62,7 @@ func (k Keeper) ConnOpenInit( // NOTE: // - Here chain A acts as the counterparty // - Identifiers are checked on msg validation -func (k Keeper) ConnOpenTry( +func (k *Keeper) ConnOpenTry( ctx sdk.Context, counterparty types.Counterparty, // counterpartyConnectionIdentifier, counterpartyPrefix and counterpartyClientIdentifier delayPeriod uint64, @@ -155,7 +155,7 @@ func (k Keeper) ConnOpenTry( // to chain A (this code is executed on chain A). // // NOTE: Identifiers are checked on msg validation. -func (k Keeper) ConnOpenAck( +func (k *Keeper) ConnOpenAck( ctx sdk.Context, connectionID string, clientState exported.ClientState, // client state for chainA on chainB @@ -253,7 +253,7 @@ func (k Keeper) ConnOpenAck( // which the connection is open on both chains (this code is executed on chain B). // // NOTE: Identifiers are checked on msg validation. -func (k Keeper) ConnOpenConfirm( +func (k *Keeper) ConnOpenConfirm( ctx sdk.Context, connectionID string, ackProof []byte, // proof that connection opened on ChainA during ConnOpenAck diff --git a/modules/core/03-connection/keeper/keeper.go b/modules/core/03-connection/keeper/keeper.go index f8fc73efee2..5bbfd783fd5 100644 --- a/modules/core/03-connection/keeper/keeper.go +++ b/modules/core/03-connection/keeper/keeper.go @@ -45,12 +45,12 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { // GetCommitmentPrefix returns the IBC connection store prefix as a commitment // Prefix -func (k Keeper) GetCommitmentPrefix() exported.Prefix { +func (k *Keeper) GetCommitmentPrefix() exported.Prefix { return commitmenttypes.NewMerklePrefix([]byte(k.storeKey.Name())) } // GenerateConnectionIdentifier returns the next connection identifier. -func (k Keeper) GenerateConnectionIdentifier(ctx sdk.Context) string { +func (k *Keeper) GenerateConnectionIdentifier(ctx sdk.Context) string { nextConnSeq := k.GetNextConnectionSequence(ctx) connectionID := types.FormatConnectionIdentifier(nextConnSeq) @@ -60,7 +60,7 @@ func (k Keeper) GenerateConnectionIdentifier(ctx sdk.Context) string { } // GetConnection returns a connection with a particular identifier -func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.ConnectionEnd, bool) { +func (k *Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.ConnectionEnd, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.ConnectionKey(connectionID)) if len(bz) == 0 { @@ -75,13 +75,13 @@ func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.Conne // HasConnection returns a true if the connection with the given identifier // exists in the store. -func (k Keeper) HasConnection(ctx sdk.Context, connectionID string) bool { +func (k *Keeper) HasConnection(ctx sdk.Context, connectionID string) bool { store := ctx.KVStore(k.storeKey) return store.Has(host.ConnectionKey(connectionID)) } // SetConnection sets a connection to the store -func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection types.ConnectionEnd) { +func (k *Keeper) SetConnection(ctx sdk.Context, connectionID string, connection types.ConnectionEnd) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&connection) store.Set(host.ConnectionKey(connectionID), bz) @@ -89,7 +89,7 @@ func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection t // GetClientConnectionPaths returns all the connection paths stored under a // particular client -func (k Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]string, bool) { +func (k *Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]string, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.ClientConnectionsKey(clientID)) if len(bz) == 0 { @@ -102,7 +102,7 @@ func (k Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]st } // SetClientConnectionPaths sets the connections paths for client -func (k Keeper) SetClientConnectionPaths(ctx sdk.Context, clientID string, paths []string) { +func (k *Keeper) SetClientConnectionPaths(ctx sdk.Context, clientID string, paths []string) { store := ctx.KVStore(k.storeKey) clientPaths := types.ClientPaths{Paths: paths} bz := k.cdc.MustMarshal(&clientPaths) @@ -110,7 +110,7 @@ func (k Keeper) SetClientConnectionPaths(ctx sdk.Context, clientID string, paths } // GetNextConnectionSequence gets the next connection sequence from the store. -func (k Keeper) GetNextConnectionSequence(ctx sdk.Context) uint64 { +func (k *Keeper) GetNextConnectionSequence(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.KeyNextConnectionSequence)) if len(bz) == 0 { @@ -121,7 +121,7 @@ func (k Keeper) GetNextConnectionSequence(ctx sdk.Context) uint64 { } // SetNextConnectionSequence sets the next connection sequence to the store. -func (k Keeper) SetNextConnectionSequence(ctx sdk.Context, sequence uint64) { +func (k *Keeper) SetNextConnectionSequence(ctx sdk.Context, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set([]byte(types.KeyNextConnectionSequence), bz) @@ -130,7 +130,7 @@ func (k Keeper) SetNextConnectionSequence(ctx sdk.Context, sequence uint64) { // GetAllClientConnectionPaths returns all stored clients connection id paths. It // will ignore the clients that haven't initialized a connection handshake since // no paths are stored. -func (k Keeper) GetAllClientConnectionPaths(ctx sdk.Context) []types.ConnectionPaths { +func (k *Keeper) GetAllClientConnectionPaths(ctx sdk.Context) []types.ConnectionPaths { var allConnectionPaths []types.ConnectionPaths k.clientKeeper.IterateClientStates(ctx, nil, func(clientID string, cs exported.ClientState) bool { paths, found := k.GetClientConnectionPaths(ctx, clientID) @@ -149,7 +149,7 @@ func (k Keeper) GetAllClientConnectionPaths(ctx sdk.Context) []types.ConnectionP // IterateConnections provides an iterator over all ConnectionEnd objects. // For each ConnectionEnd, cb will be called. If the cb returns true, the // iterator will close and stop. -func (k Keeper) IterateConnections(ctx sdk.Context, cb func(types.IdentifiedConnection) bool) { +func (k *Keeper) IterateConnections(ctx sdk.Context, cb func(types.IdentifiedConnection) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyConnectionPrefix)) @@ -167,7 +167,7 @@ func (k Keeper) IterateConnections(ctx sdk.Context, cb func(types.IdentifiedConn } // GetAllConnections returns all stored ConnectionEnd objects. -func (k Keeper) GetAllConnections(ctx sdk.Context) (connections []types.IdentifiedConnection) { +func (k *Keeper) GetAllConnections(ctx sdk.Context) (connections []types.IdentifiedConnection) { k.IterateConnections(ctx, func(connection types.IdentifiedConnection) bool { connections = append(connections, connection) return false @@ -176,7 +176,7 @@ func (k Keeper) GetAllConnections(ctx sdk.Context) (connections []types.Identifi } // CreateSentinelLocalhostConnection creates and sets the sentinel localhost connection end in the IBC store. -func (k Keeper) CreateSentinelLocalhostConnection(ctx sdk.Context) { +func (k *Keeper) CreateSentinelLocalhostConnection(ctx sdk.Context) { counterparty := types.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, commitmenttypes.NewMerklePrefix(k.GetCommitmentPrefix().Bytes())) connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.GetCompatibleVersions(), 0) @@ -185,7 +185,7 @@ func (k Keeper) CreateSentinelLocalhostConnection(ctx sdk.Context) { // addConnectionToClient is used to add a connection identifier to the set of // connections associated with a client. -func (k Keeper) addConnectionToClient(ctx sdk.Context, clientID, connectionID string) error { +func (k *Keeper) addConnectionToClient(ctx sdk.Context, clientID, connectionID string) error { _, found := k.clientKeeper.GetClientState(ctx, clientID) if !found { return errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID) @@ -202,7 +202,7 @@ func (k Keeper) addConnectionToClient(ctx sdk.Context, clientID, connectionID st } // GetParams returns the total set of ibc-connection parameters. -func (k Keeper) GetParams(ctx sdk.Context) types.Params { +func (k *Keeper) GetParams(ctx sdk.Context) types.Params { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.ParamsKey)) if bz == nil { // only panic on unset params and not on empty params @@ -215,7 +215,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { } // SetParams sets the total set of ibc-connection parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(¶ms) store.Set([]byte(types.ParamsKey), bz) diff --git a/modules/core/03-connection/keeper/verify.go b/modules/core/03-connection/keeper/verify.go index da90e78c9fb..c1cf804f91e 100644 --- a/modules/core/03-connection/keeper/verify.go +++ b/modules/core/03-connection/keeper/verify.go @@ -17,7 +17,7 @@ import ( // VerifyClientState verifies a proof of a client state of the running machine // stored on the target machine -func (k Keeper) VerifyClientState( +func (k *Keeper) VerifyClientState( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -58,7 +58,7 @@ func (k Keeper) VerifyClientState( // VerifyClientConsensusState verifies a proof of the consensus state of the // specified client stored on the target machine. -func (k Keeper) VerifyClientConsensusState( +func (k *Keeper) VerifyClientConsensusState( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -100,7 +100,7 @@ func (k Keeper) VerifyClientConsensusState( // VerifyConnectionState verifies a proof of the connection state of the // specified connection end stored on the target machine. -func (k Keeper) VerifyConnectionState( +func (k *Keeper) VerifyConnectionState( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -142,7 +142,7 @@ func (k Keeper) VerifyConnectionState( // VerifyChannelState verifies a proof of the channel state of the specified // channel end, under the specified port, stored on the target machine. -func (k Keeper) VerifyChannelState( +func (k *Keeper) VerifyChannelState( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -185,7 +185,7 @@ func (k Keeper) VerifyChannelState( // VerifyPacketCommitment verifies a proof of an outgoing packet commitment at // the specified port, specified channel, and specified sequence. -func (k Keeper) VerifyPacketCommitment( +func (k *Keeper) VerifyPacketCommitment( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -226,7 +226,7 @@ func (k Keeper) VerifyPacketCommitment( // VerifyPacketAcknowledgement verifies a proof of an incoming packet // acknowledgement at the specified port, specified channel, and specified sequence. -func (k Keeper) VerifyPacketAcknowledgement( +func (k *Keeper) VerifyPacketAcknowledgement( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -269,7 +269,7 @@ func (k Keeper) VerifyPacketAcknowledgement( // VerifyPacketReceiptAbsence verifies a proof of the absence of an // incoming packet receipt at the specified port, specified channel, and // specified sequence. -func (k Keeper) VerifyPacketReceiptAbsence( +func (k *Keeper) VerifyPacketReceiptAbsence( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -314,7 +314,7 @@ func (k Keeper) VerifyPacketReceiptAbsence( // VerifyNextSequenceRecv verifies a proof of the next sequence number to be // received of the specified channel at the specified port. -func (k Keeper) VerifyNextSequenceRecv( +func (k *Keeper) VerifyNextSequenceRecv( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -355,7 +355,7 @@ func (k Keeper) VerifyNextSequenceRecv( } // VerifyChannelUpgradeError verifies a proof of the provided upgrade error receipt. -func (k Keeper) VerifyChannelUpgradeError( +func (k *Keeper) VerifyChannelUpgradeError( ctx sdk.Context, connection types.ConnectionEnd, height exported.Height, @@ -397,7 +397,7 @@ func (k Keeper) VerifyChannelUpgradeError( } // VerifyChannelUpgrade verifies the proof that a particular proposed upgrade has been stored in the upgrade path. -func (k Keeper) VerifyChannelUpgrade( +func (k *Keeper) VerifyChannelUpgrade( ctx sdk.Context, connection types.ConnectionEnd, proofHeight exported.Height, @@ -440,7 +440,7 @@ func (k Keeper) VerifyChannelUpgrade( // getBlockDelay calculates the block delay period from the time delay of the connection // and the maximum expected time per block. -func (k Keeper) getBlockDelay(ctx sdk.Context, connection types.ConnectionEnd) uint64 { +func (k *Keeper) getBlockDelay(ctx sdk.Context, connection types.ConnectionEnd) uint64 { // expectedTimePerBlock should never be zero, however if it is then return a 0 block delay for safety // as the expectedTimePerBlock parameter was not set. expectedTimePerBlock := k.GetParams(ctx).MaxExpectedTimePerBlock diff --git a/modules/core/04-channel/keeper/export_test.go b/modules/core/04-channel/keeper/export_test.go index a36da4eea47..ae68eb5e275 100644 --- a/modules/core/04-channel/keeper/export_test.go +++ b/modules/core/04-channel/keeper/export_test.go @@ -11,26 +11,26 @@ import ( ) // StartFlushing is a wrapper around startFlushing to allow the function to be directly called in tests. -func (k Keeper) StartFlushing(ctx sdk.Context, portID, channelID string, upgrade *types.Upgrade) error { +func (k *Keeper) StartFlushing(ctx sdk.Context, portID, channelID string, upgrade *types.Upgrade) error { return k.startFlushing(ctx, portID, channelID, upgrade) } // ValidateSelfUpgradeFields is a wrapper around validateSelfUpgradeFields to allow the function to be directly called in tests. -func (k Keeper) ValidateSelfUpgradeFields(ctx sdk.Context, proposedUpgrade types.UpgradeFields, channel types.Channel) error { +func (k *Keeper) ValidateSelfUpgradeFields(ctx sdk.Context, proposedUpgrade types.UpgradeFields, channel types.Channel) error { return k.validateSelfUpgradeFields(ctx, proposedUpgrade, channel) } // CheckForUpgradeCompatibility is a wrapper around checkForUpgradeCompatibility to allow the function to be directly called in tests. -func (k Keeper) CheckForUpgradeCompatibility(ctx sdk.Context, upgradeFields, counterpartyUpgradeFields types.UpgradeFields) error { +func (k *Keeper) CheckForUpgradeCompatibility(ctx sdk.Context, upgradeFields, counterpartyUpgradeFields types.UpgradeFields) error { return k.checkForUpgradeCompatibility(ctx, upgradeFields, counterpartyUpgradeFields) } // SetUpgradeErrorReceipt is a wrapper around setUpgradeErrorReceipt to allow the function to be directly called in tests. -func (k Keeper) SetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt) { +func (k *Keeper) SetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt) { k.setUpgradeErrorReceipt(ctx, portID, channelID, errorReceipt) } // SetRecvStartSequence is a wrapper around setRecvStartSequence to allow the function to be directly called in tests. -func (k Keeper) SetRecvStartSequence(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) SetRecvStartSequence(ctx sdk.Context, portID, channelID string, sequence uint64) { k.setRecvStartSequence(ctx, portID, channelID, sequence) } diff --git a/modules/core/04-channel/keeper/grpc_query.go b/modules/core/04-channel/keeper/grpc_query.go index 98e5c9e3773..f15a232d911 100644 --- a/modules/core/04-channel/keeper/grpc_query.go +++ b/modules/core/04-channel/keeper/grpc_query.go @@ -24,7 +24,7 @@ import ( var _ types.QueryServer = (*Keeper)(nil) // Channel implements the Query/Channel gRPC method -func (k Keeper) Channel(c context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) { +func (k *Keeper) Channel(c context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -47,7 +47,7 @@ func (k Keeper) Channel(c context.Context, req *types.QueryChannelRequest) (*typ } // Channels implements the Query/Channels gRPC method -func (k Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*types.QueryChannelsResponse, error) { +func (k *Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*types.QueryChannelsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -85,7 +85,7 @@ func (k Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*t } // ConnectionChannels implements the Query/ConnectionChannels gRPC method -func (k Keeper) ConnectionChannels(c context.Context, req *types.QueryConnectionChannelsRequest) (*types.QueryConnectionChannelsResponse, error) { +func (k *Keeper) ConnectionChannels(c context.Context, req *types.QueryConnectionChannelsRequest) (*types.QueryConnectionChannelsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -134,7 +134,7 @@ func (k Keeper) ConnectionChannels(c context.Context, req *types.QueryConnection } // ChannelClientState implements the Query/ChannelClientState gRPC method -func (k Keeper) ChannelClientState(c context.Context, req *types.QueryChannelClientStateRequest) (*types.QueryChannelClientStateResponse, error) { +func (k *Keeper) ChannelClientState(c context.Context, req *types.QueryChannelClientStateRequest) (*types.QueryChannelClientStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -157,7 +157,7 @@ func (k Keeper) ChannelClientState(c context.Context, req *types.QueryChannelCli } // ChannelConsensusState implements the Query/ChannelConsensusState gRPC method -func (k Keeper) ChannelConsensusState(c context.Context, req *types.QueryChannelConsensusStateRequest) (*types.QueryChannelConsensusStateResponse, error) { +func (k *Keeper) ChannelConsensusState(c context.Context, req *types.QueryChannelConsensusStateRequest) (*types.QueryChannelConsensusStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -203,7 +203,7 @@ func (k Keeper) ChannelConsensusState(c context.Context, req *types.QueryChannel } // PacketCommitment implements the Query/PacketCommitment gRPC method -func (k Keeper) PacketCommitment(c context.Context, req *types.QueryPacketCommitmentRequest) (*types.QueryPacketCommitmentResponse, error) { +func (k *Keeper) PacketCommitment(c context.Context, req *types.QueryPacketCommitmentRequest) (*types.QueryPacketCommitmentResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -235,7 +235,7 @@ func (k Keeper) PacketCommitment(c context.Context, req *types.QueryPacketCommit } // PacketCommitments implements the Query/PacketCommitments gRPC method -func (k Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommitmentsRequest) (*types.QueryPacketCommitmentsResponse, error) { +func (k *Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommitmentsRequest) (*types.QueryPacketCommitmentsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -280,7 +280,7 @@ func (k Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi } // PacketReceipt implements the Query/PacketReceipt gRPC method -func (k Keeper) PacketReceipt(c context.Context, req *types.QueryPacketReceiptRequest) (*types.QueryPacketReceiptResponse, error) { +func (k *Keeper) PacketReceipt(c context.Context, req *types.QueryPacketReceiptRequest) (*types.QueryPacketReceiptResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -308,7 +308,7 @@ func (k Keeper) PacketReceipt(c context.Context, req *types.QueryPacketReceiptRe } // PacketAcknowledgement implements the Query/PacketAcknowledgement gRPC method -func (k Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketAcknowledgementRequest) (*types.QueryPacketAcknowledgementResponse, error) { +func (k *Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketAcknowledgementRequest) (*types.QueryPacketAcknowledgementResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -339,7 +339,7 @@ func (k Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketA } // PacketAcknowledgements implements the Query/PacketAcknowledgements gRPC method -func (k Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacketAcknowledgementsRequest) (*types.QueryPacketAcknowledgementsResponse, error) { +func (k *Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacketAcknowledgementsRequest) (*types.QueryPacketAcknowledgementsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -421,7 +421,7 @@ func (k Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacket // commitments is correct and will not function properly if the list // is not up to date. Ideally the query height should equal the latest height // on the counterparty's client which represents this chain. -func (k Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedPacketsRequest) (*types.QueryUnreceivedPacketsResponse, error) { +func (k *Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedPacketsRequest) (*types.QueryUnreceivedPacketsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -507,7 +507,7 @@ func (k Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedP // acknowledgements is correct and will not function properly if the list // is not up to date. Ideally the query height should equal the latest height // on the counterparty's client which represents this chain. -func (k Keeper) UnreceivedAcks(c context.Context, req *types.QueryUnreceivedAcksRequest) (*types.QueryUnreceivedAcksResponse, error) { +func (k *Keeper) UnreceivedAcks(c context.Context, req *types.QueryUnreceivedAcksRequest) (*types.QueryUnreceivedAcksResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -547,7 +547,7 @@ func (k Keeper) UnreceivedAcks(c context.Context, req *types.QueryUnreceivedAcks } // NextSequenceReceive implements the Query/NextSequenceReceive gRPC method -func (k Keeper) NextSequenceReceive(c context.Context, req *types.QueryNextSequenceReceiveRequest) (*types.QueryNextSequenceReceiveResponse, error) { +func (k *Keeper) NextSequenceReceive(c context.Context, req *types.QueryNextSequenceReceiveRequest) (*types.QueryNextSequenceReceiveResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -582,7 +582,7 @@ func (k Keeper) NextSequenceReceive(c context.Context, req *types.QueryNextSeque } // NextSequenceSend implements the Query/NextSequenceSend gRPC method -func (k Keeper) NextSequenceSend(c context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) { +func (k *Keeper) NextSequenceSend(c context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -605,7 +605,7 @@ func (k Keeper) NextSequenceSend(c context.Context, req *types.QueryNextSequence } // UpgradeErrorReceipt implements the Query/UpgradeErrorReceipt gRPC method -func (k Keeper) UpgradeErrorReceipt(c context.Context, req *types.QueryUpgradeErrorRequest) (*types.QueryUpgradeErrorResponse, error) { +func (k *Keeper) UpgradeErrorReceipt(c context.Context, req *types.QueryUpgradeErrorRequest) (*types.QueryUpgradeErrorResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -636,7 +636,7 @@ func (k Keeper) UpgradeErrorReceipt(c context.Context, req *types.QueryUpgradeEr } // Upgrade implements the Query/UpgradeSequence gRPC method -func (k Keeper) Upgrade(c context.Context, req *types.QueryUpgradeRequest) (*types.QueryUpgradeResponse, error) { +func (k *Keeper) Upgrade(c context.Context, req *types.QueryUpgradeRequest) (*types.QueryUpgradeResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -667,7 +667,7 @@ func (k Keeper) Upgrade(c context.Context, req *types.QueryUpgradeRequest) (*typ } // ChannelParams implements the Query/ChannelParams gRPC method. -func (k Keeper) ChannelParams(c context.Context, req *types.QueryChannelParamsRequest) (*types.QueryChannelParamsResponse, error) { +func (k *Keeper) ChannelParams(c context.Context, req *types.QueryChannelParamsRequest) (*types.QueryChannelParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) params := k.GetParams(ctx) diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index 4b5c536f5c8..3ea7b36587e 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -20,7 +20,7 @@ import ( // ChanOpenInit is called by a module to initiate a channel opening handshake with // a module on another chain. The counterparty channel identifier is validated to be // empty in msg validation. -func (k Keeper) ChanOpenInit( +func (k *Keeper) ChanOpenInit( ctx sdk.Context, order types.Order, connectionHops []string, @@ -73,7 +73,7 @@ func (k Keeper) ChanOpenInit( // WriteOpenInitChannel writes a channel which has successfully passed the OpenInit handshake step. // The channel is set in state and all the associated Send and Recv sequences are set to 1. // An event is emitted for the handshake step. -func (k Keeper) WriteOpenInitChannel( +func (k *Keeper) WriteOpenInitChannel( ctx sdk.Context, portID, channelID string, @@ -98,7 +98,7 @@ func (k Keeper) WriteOpenInitChannel( // ChanOpenTry is called by a module to accept the first step of a channel opening // handshake initiated by a module on another chain. -func (k Keeper) ChanOpenTry( +func (k *Keeper) ChanOpenTry( ctx sdk.Context, order types.Order, connectionHops []string, @@ -180,7 +180,7 @@ func (k Keeper) ChanOpenTry( // WriteOpenTryChannel writes a channel which has successfully passed the OpenTry handshake step. // The channel is set in state. If a previous channel state did not exist, all the Send and Recv // sequences are set to 1. An event is emitted for the handshake step. -func (k Keeper) WriteOpenTryChannel( +func (k *Keeper) WriteOpenTryChannel( ctx sdk.Context, portID, channelID string, @@ -206,7 +206,7 @@ func (k Keeper) WriteOpenTryChannel( // ChanOpenAck is called by the handshake-originating module to acknowledge the // acceptance of the initial request by the counterparty module on the other chain. -func (k Keeper) ChanOpenAck( +func (k *Keeper) ChanOpenAck( ctx sdk.Context, portID, channelID string, @@ -255,7 +255,7 @@ func (k Keeper) ChanOpenAck( // WriteOpenAckChannel writes an updated channel state for the successful OpenAck handshake step. // An event is emitted for the handshake step. -func (k Keeper) WriteOpenAckChannel( +func (k *Keeper) WriteOpenAckChannel( ctx sdk.Context, portID, channelID, @@ -281,7 +281,7 @@ func (k Keeper) WriteOpenAckChannel( // ChanOpenConfirm is called by the handshake-accepting module to confirm the acknowledgement // of the handshake-originating module on the other chain and finish the channel opening handshake. -func (k Keeper) ChanOpenConfirm( +func (k *Keeper) ChanOpenConfirm( ctx sdk.Context, portID, channelID string, @@ -332,7 +332,7 @@ func (k Keeper) ChanOpenConfirm( // WriteOpenConfirmChannel writes an updated channel state for the successful OpenConfirm handshake step. // An event is emitted for the handshake step. -func (k Keeper) WriteOpenConfirmChannel( +func (k *Keeper) WriteOpenConfirmChannel( ctx sdk.Context, portID, channelID string, @@ -358,7 +358,7 @@ func (k Keeper) WriteOpenConfirmChannel( // // ChanCloseInit is called by either module to close their end of the channel. Once // closed, channels cannot be reopened. -func (k Keeper) ChanCloseInit( +func (k *Keeper) ChanCloseInit( ctx sdk.Context, portID, channelID string, @@ -404,7 +404,7 @@ func (k Keeper) ChanCloseInit( // ChanCloseConfirm is called by the counterparty module to close their end of the // channel, since the other end has been closed. -func (k Keeper) ChanCloseConfirm( +func (k *Keeper) ChanCloseConfirm( ctx sdk.Context, portID, channelID string, diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 0249db46ca8..463c2174bb1 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -60,7 +60,7 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { } // GenerateChannelIdentifier returns the next channel identifier. -func (k Keeper) GenerateChannelIdentifier(ctx sdk.Context) string { +func (k *Keeper) GenerateChannelIdentifier(ctx sdk.Context) string { nextChannelSeq := k.GetNextChannelSequence(ctx) channelID := types.FormatChannelIdentifier(nextChannelSeq) @@ -70,13 +70,13 @@ func (k Keeper) GenerateChannelIdentifier(ctx sdk.Context) string { } // HasChannel true if the channel with the given identifiers exists in state. -func (k Keeper) HasChannel(ctx sdk.Context, portID, channelID string) bool { +func (k *Keeper) HasChannel(ctx sdk.Context, portID, channelID string) bool { store := ctx.KVStore(k.storeKey) return store.Has(host.ChannelKey(portID, channelID)) } // GetChannel returns a channel with a particular identifier binded to a specific port -func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Channel, bool) { +func (k *Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Channel, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.ChannelKey(portID, channelID)) if len(bz) == 0 { @@ -89,14 +89,14 @@ func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Cha } // SetChannel sets a channel to the store -func (k Keeper) SetChannel(ctx sdk.Context, portID, channelID string, channel types.Channel) { +func (k *Keeper) SetChannel(ctx sdk.Context, portID, channelID string, channel types.Channel) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&channel) store.Set(host.ChannelKey(portID, channelID), bz) } // GetAppVersion gets the version for the specified channel. -func (k Keeper) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { +func (k *Keeper) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { channel, found := k.GetChannel(ctx, portID, channelID) if !found { return "", false @@ -106,7 +106,7 @@ func (k Keeper) GetAppVersion(ctx sdk.Context, portID, channelID string) (string } // GetNextChannelSequence gets the next channel sequence from the store. -func (k Keeper) GetNextChannelSequence(ctx sdk.Context) uint64 { +func (k *Keeper) GetNextChannelSequence(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.KeyNextChannelSequence)) if len(bz) == 0 { @@ -117,14 +117,14 @@ func (k Keeper) GetNextChannelSequence(ctx sdk.Context) uint64 { } // SetNextChannelSequence sets the next channel sequence to the store. -func (k Keeper) SetNextChannelSequence(ctx sdk.Context, sequence uint64) { +func (k *Keeper) SetNextChannelSequence(ctx sdk.Context, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set([]byte(types.KeyNextChannelSequence), bz) } // GetNextSequenceSend gets a channel's next send sequence from the store -func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) { +func (k *Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.NextSequenceSendKey(portID, channelID)) if len(bz) == 0 { @@ -135,14 +135,14 @@ func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) ( } // SetNextSequenceSend sets a channel's next send sequence to the store -func (k Keeper) SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set(host.NextSequenceSendKey(portID, channelID), bz) } // GetNextSequenceRecv gets a channel's next receive sequence from the store -func (k Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) (uint64, bool) { +func (k *Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.NextSequenceRecvKey(portID, channelID)) if len(bz) == 0 { @@ -153,14 +153,14 @@ func (k Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) ( } // SetNextSequenceRecv sets a channel's next receive sequence to the store -func (k Keeper) SetNextSequenceRecv(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) SetNextSequenceRecv(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set(host.NextSequenceRecvKey(portID, channelID), bz) } // GetNextSequenceAck gets a channel's next ack sequence from the store -func (k Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (uint64, bool) { +func (k *Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.NextSequenceAckKey(portID, channelID)) if len(bz) == 0 { @@ -171,14 +171,14 @@ func (k Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (u } // SetNextSequenceAck sets a channel's next ack sequence to the store -func (k Keeper) SetNextSequenceAck(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) SetNextSequenceAck(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set(host.NextSequenceAckKey(portID, channelID), bz) } // GetPacketReceipt gets a packet receipt from the store -func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool) { +func (k *Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.PacketReceiptKey(portID, channelID, sequence)) if len(bz) == 0 { @@ -189,49 +189,49 @@ func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequ } // SetPacketReceipt sets an empty packet receipt to the store -func (k Keeper) SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) store.Set(host.PacketReceiptKey(portID, channelID, sequence), []byte{byte(1)}) } // deletePacketReceipt deletes a packet receipt from the store -func (k Keeper) deletePacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) deletePacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) store.Delete(host.PacketReceiptKey(portID, channelID, sequence)) } // GetPacketCommitment gets the packet commitment hash from the store -func (k Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte { +func (k *Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte { store := ctx.KVStore(k.storeKey) bz := store.Get(host.PacketCommitmentKey(portID, channelID, sequence)) return bz } // HasPacketCommitment returns true if the packet commitment exists -func (k Keeper) HasPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) bool { +func (k *Keeper) HasPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) bool { store := ctx.KVStore(k.storeKey) return store.Has(host.PacketCommitmentKey(portID, channelID, sequence)) } // SetPacketCommitment sets the packet commitment hash to the store -func (k Keeper) SetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64, commitmentHash []byte) { +func (k *Keeper) SetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64, commitmentHash []byte) { store := ctx.KVStore(k.storeKey) store.Set(host.PacketCommitmentKey(portID, channelID, sequence), commitmentHash) } -func (k Keeper) deletePacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) deletePacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) store.Delete(host.PacketCommitmentKey(portID, channelID, sequence)) } // SetPacketAcknowledgement sets the packet ack hash to the store -func (k Keeper) SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) { +func (k *Keeper) SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) { store := ctx.KVStore(k.storeKey) store.Set(host.PacketAcknowledgementKey(portID, channelID, sequence), ackHash) } // GetPacketAcknowledgement gets the packet ack hash from the store -func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) ([]byte, bool) { +func (k *Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) ([]byte, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.PacketAcknowledgementKey(portID, channelID, sequence)) if len(bz) == 0 { @@ -241,13 +241,13 @@ func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID stri } // HasPacketAcknowledgement check if the packet ack hash is already on the store -func (k Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) bool { +func (k *Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) bool { store := ctx.KVStore(k.storeKey) return store.Has(host.PacketAcknowledgementKey(portID, channelID, sequence)) } // deletePacketAcknowledgement deletes the packet ack hash from the store -func (k Keeper) deletePacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) deletePacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) store.Delete(host.PacketAcknowledgementKey(portID, channelID, sequence)) } @@ -273,7 +273,7 @@ func (Keeper) IteratePacketSequence(ctx sdk.Context, iterator db.Iterator, cb fu } // GetAllPacketSendSeqs returns all stored next send sequences. -func (k Keeper) GetAllPacketSendSeqs(ctx sdk.Context) (seqs []types.PacketSequence) { +func (k *Keeper) GetAllPacketSendSeqs(ctx sdk.Context) (seqs []types.PacketSequence) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyNextSeqSendPrefix)) k.IteratePacketSequence(ctx, iterator, func(portID, channelID string, nextSendSeq uint64) bool { @@ -285,7 +285,7 @@ func (k Keeper) GetAllPacketSendSeqs(ctx sdk.Context) (seqs []types.PacketSequen } // GetAllPacketRecvSeqs returns all stored next recv sequences. -func (k Keeper) GetAllPacketRecvSeqs(ctx sdk.Context) (seqs []types.PacketSequence) { +func (k *Keeper) GetAllPacketRecvSeqs(ctx sdk.Context) (seqs []types.PacketSequence) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyNextSeqRecvPrefix)) k.IteratePacketSequence(ctx, iterator, func(portID, channelID string, nextRecvSeq uint64) bool { @@ -297,7 +297,7 @@ func (k Keeper) GetAllPacketRecvSeqs(ctx sdk.Context) (seqs []types.PacketSequen } // GetAllPacketAckSeqs returns all stored next acknowledgements sequences. -func (k Keeper) GetAllPacketAckSeqs(ctx sdk.Context) (seqs []types.PacketSequence) { +func (k *Keeper) GetAllPacketAckSeqs(ctx sdk.Context) (seqs []types.PacketSequence) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyNextSeqAckPrefix)) k.IteratePacketSequence(ctx, iterator, func(portID, channelID string, nextAckSeq uint64) bool { @@ -311,14 +311,14 @@ func (k Keeper) GetAllPacketAckSeqs(ctx sdk.Context) (seqs []types.PacketSequenc // IteratePacketCommitment provides an iterator over all PacketCommitment objects. For each // packet commitment, cb will be called. If the cb returns true, the iterator will close // and stop. -func (k Keeper) IteratePacketCommitment(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { +func (k *Keeper) IteratePacketCommitment(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketCommitmentPrefix)) k.iterateHashes(ctx, iterator, cb) } // GetAllPacketCommitments returns all stored PacketCommitments objects. -func (k Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.PacketState) { +func (k *Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.PacketState) { k.IteratePacketCommitment(ctx, func(portID, channelID string, sequence uint64, hash []byte) bool { pc := types.NewPacketState(portID, channelID, sequence, hash) commitments = append(commitments, pc) @@ -330,7 +330,7 @@ func (k Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.Pa // IteratePacketCommitmentAtChannel provides an iterator over all PacketCommmitment objects // at a specified channel. For each packet commitment, cb will be called. If the cb returns // true, the iterator will close and stop. -func (k Keeper) IteratePacketCommitmentAtChannel(ctx sdk.Context, portID, channelID string, cb func(_, _ string, sequence uint64, hash []byte) bool) { +func (k *Keeper) IteratePacketCommitmentAtChannel(ctx sdk.Context, portID, channelID string, cb func(_, _ string, sequence uint64, hash []byte) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.PacketCommitmentPrefixPath(portID, channelID))) k.iterateHashes(ctx, iterator, cb) @@ -338,7 +338,7 @@ func (k Keeper) IteratePacketCommitmentAtChannel(ctx sdk.Context, portID, channe // GetAllPacketCommitmentsAtChannel returns all stored PacketCommitments objects for a specified // port ID and channel ID. -func (k Keeper) GetAllPacketCommitmentsAtChannel(ctx sdk.Context, portID, channelID string) (commitments []types.PacketState) { +func (k *Keeper) GetAllPacketCommitmentsAtChannel(ctx sdk.Context, portID, channelID string) (commitments []types.PacketState) { k.IteratePacketCommitmentAtChannel(ctx, portID, channelID, func(_, _ string, sequence uint64, hash []byte) bool { pc := types.NewPacketState(portID, channelID, sequence, hash) commitments = append(commitments, pc) @@ -350,14 +350,14 @@ func (k Keeper) GetAllPacketCommitmentsAtChannel(ctx sdk.Context, portID, channe // IteratePacketReceipt provides an iterator over all PacketReceipt objects. For each // receipt, cb will be called. If the cb returns true, the iterator will close // and stop. -func (k Keeper) IteratePacketReceipt(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, receipt []byte) bool) { +func (k *Keeper) IteratePacketReceipt(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, receipt []byte) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketReceiptPrefix)) k.iterateHashes(ctx, iterator, cb) } // GetAllPacketReceipts returns all stored PacketReceipt objects. -func (k Keeper) GetAllPacketReceipts(ctx sdk.Context) (receipts []types.PacketState) { +func (k *Keeper) GetAllPacketReceipts(ctx sdk.Context) (receipts []types.PacketState) { k.IteratePacketReceipt(ctx, func(portID, channelID string, sequence uint64, receipt []byte) bool { packetReceipt := types.NewPacketState(portID, channelID, sequence, receipt) receipts = append(receipts, packetReceipt) @@ -369,14 +369,14 @@ func (k Keeper) GetAllPacketReceipts(ctx sdk.Context) (receipts []types.PacketSt // IteratePacketAcknowledgement provides an iterator over all PacketAcknowledgement objects. For each // acknowledgement, cb will be called. If the cb returns true, the iterator will close // and stop. -func (k Keeper) IteratePacketAcknowledgement(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { +func (k *Keeper) IteratePacketAcknowledgement(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketAckPrefix)) k.iterateHashes(ctx, iterator, cb) } // GetAllPacketAcks returns all stored PacketAcknowledgements objects. -func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState) { +func (k *Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState) { k.IteratePacketAcknowledgement(ctx, func(portID, channelID string, sequence uint64, ack []byte) bool { packetAck := types.NewPacketState(portID, channelID, sequence, ack) acks = append(acks, packetAck) @@ -388,7 +388,7 @@ func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState) { // IterateChannels provides an iterator over all Channel objects. For each // Channel, cb will be called. If the cb returns true, the iterator will close // and stop. -func (k Keeper) IterateChannels(ctx sdk.Context, cb func(types.IdentifiedChannel) bool) { +func (k *Keeper) IterateChannels(ctx sdk.Context, cb func(types.IdentifiedChannel) bool) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyChannelEndPrefix)) @@ -407,7 +407,7 @@ func (k Keeper) IterateChannels(ctx sdk.Context, cb func(types.IdentifiedChannel // GetAllChannelsWithPortPrefix returns all channels with the specified port prefix. If an empty prefix is provided // all channels will be returned. -func (k Keeper) GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) []types.IdentifiedChannel { +func (k *Keeper) GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) []types.IdentifiedChannel { if strings.TrimSpace(portPrefix) == "" { return k.GetAllChannels(ctx) } @@ -428,7 +428,7 @@ func (k Keeper) GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) } // GetAllChannels returns all stored Channel objects. -func (k Keeper) GetAllChannels(ctx sdk.Context) (channels []types.IdentifiedChannel) { +func (k *Keeper) GetAllChannels(ctx sdk.Context) (channels []types.IdentifiedChannel) { k.IterateChannels(ctx, func(channel types.IdentifiedChannel) bool { channels = append(channels, channel) return false @@ -437,7 +437,7 @@ func (k Keeper) GetAllChannels(ctx sdk.Context) (channels []types.IdentifiedChan } // GetChannelClientState returns the associated client state with its ID, from a port and channel identifier. -func (k Keeper) GetChannelClientState(ctx sdk.Context, portID, channelID string) (string, exported.ClientState, error) { +func (k *Keeper) GetChannelClientState(ctx sdk.Context, portID, channelID string) (string, exported.ClientState, error) { channel, found := k.GetChannel(ctx, portID, channelID) if !found { return "", nil, errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id: %s", portID, channelID) @@ -457,7 +457,7 @@ func (k Keeper) GetChannelClientState(ctx sdk.Context, portID, channelID string) } // GetConnection wraps the connection keeper's GetConnection function. -func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, error) { +func (k *Keeper) GetConnection(ctx sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, error) { connection, found := k.connectionKeeper.GetConnection(ctx, connectionID) if !found { return connectiontypes.ConnectionEnd{}, errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection-id: %s", connectionID) @@ -467,7 +467,7 @@ func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (connectiont } // GetChannelConnection returns the connection ID and state associated with the given port and channel identifier. -func (k Keeper) GetChannelConnection(ctx sdk.Context, portID, channelID string) (string, connectiontypes.ConnectionEnd, error) { +func (k *Keeper) GetChannelConnection(ctx sdk.Context, portID, channelID string) (string, connectiontypes.ConnectionEnd, error) { channel, found := k.GetChannel(ctx, portID, channelID) if !found { return "", connectiontypes.ConnectionEnd{}, errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id: %s", portID, channelID) @@ -484,7 +484,7 @@ func (k Keeper) GetChannelConnection(ctx sdk.Context, portID, channelID string) } // LookupModuleByChannel will return the IBCModule along with the capability associated with a given channel defined by its portID and channelID -func (k Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string) (string, *capabilitytypes.Capability, error) { +func (k *Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string) (string, *capabilitytypes.Capability, error) { modules, capability, err := k.scopedKeeper.LookupModules(ctx, host.ChannelCapabilityPath(portID, channelID)) if err != nil { return "", nil, err @@ -494,7 +494,7 @@ func (k Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string) } // GetUpgradeErrorReceipt returns the upgrade error receipt for the provided port and channel identifiers. -func (k Keeper) GetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string) (types.ErrorReceipt, bool) { +func (k *Keeper) GetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string) (types.ErrorReceipt, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.ChannelUpgradeErrorKey(portID, channelID)) if bz == nil { @@ -508,20 +508,20 @@ func (k Keeper) GetUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string } // setUpgradeErrorReceipt sets the provided error receipt in store using the port and channel identifiers. -func (k Keeper) setUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt) { +func (k *Keeper) setUpgradeErrorReceipt(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&errorReceipt) store.Set(host.ChannelUpgradeErrorKey(portID, channelID), bz) } // hasUpgrade returns true if a proposed upgrade exists in store -func (k Keeper) hasUpgrade(ctx sdk.Context, portID, channelID string) bool { +func (k *Keeper) hasUpgrade(ctx sdk.Context, portID, channelID string) bool { store := ctx.KVStore(k.storeKey) return store.Has(host.ChannelUpgradeKey(portID, channelID)) } // GetUpgrade returns the proposed upgrade for the provided port and channel identifiers. -func (k Keeper) GetUpgrade(ctx sdk.Context, portID, channelID string) (types.Upgrade, bool) { +func (k *Keeper) GetUpgrade(ctx sdk.Context, portID, channelID string) (types.Upgrade, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.ChannelUpgradeKey(portID, channelID)) if bz == nil { @@ -535,26 +535,26 @@ func (k Keeper) GetUpgrade(ctx sdk.Context, portID, channelID string) (types.Upg } // SetUpgrade sets the proposed upgrade using the provided port and channel identifiers. -func (k Keeper) SetUpgrade(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade) { +func (k *Keeper) SetUpgrade(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&upgrade) store.Set(host.ChannelUpgradeKey(portID, channelID), bz) } // deleteUpgrade deletes the upgrade for the provided port and channel identifiers. -func (k Keeper) deleteUpgrade(ctx sdk.Context, portID, channelID string) { +func (k *Keeper) deleteUpgrade(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) store.Delete(host.ChannelUpgradeKey(portID, channelID)) } // hasCounterpartyUpgrade returns true if a counterparty upgrade exists in store -func (k Keeper) hasCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) bool { +func (k *Keeper) hasCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) bool { store := ctx.KVStore(k.storeKey) return store.Has(host.ChannelCounterpartyUpgradeKey(portID, channelID)) } // GetCounterpartyUpgrade gets the counterparty upgrade from the store. -func (k Keeper) GetCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) (types.Upgrade, bool) { +func (k *Keeper) GetCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) (types.Upgrade, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.ChannelCounterpartyUpgradeKey(portID, channelID)) if bz == nil { @@ -568,33 +568,33 @@ func (k Keeper) GetCounterpartyUpgrade(ctx sdk.Context, portID, channelID string } // SetCounterpartyUpgrade sets the counterparty upgrade in the store. -func (k Keeper) SetCounterpartyUpgrade(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade) { +func (k *Keeper) SetCounterpartyUpgrade(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&upgrade) store.Set(host.ChannelCounterpartyUpgradeKey(portID, channelID), bz) } // deleteCounterpartyUpgrade deletes the counterparty upgrade in the store. -func (k Keeper) deleteCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) { +func (k *Keeper) deleteCounterpartyUpgrade(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) store.Delete(host.ChannelCounterpartyUpgradeKey(portID, channelID)) } // deleteUpgradeInfo deletes all auxiliary upgrade information. -func (k Keeper) deleteUpgradeInfo(ctx sdk.Context, portID, channelID string) { +func (k *Keeper) deleteUpgradeInfo(ctx sdk.Context, portID, channelID string) { k.deleteUpgrade(ctx, portID, channelID) k.deleteCounterpartyUpgrade(ctx, portID, channelID) } // SetParams sets the channel parameters. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(¶ms) store.Set([]byte(types.ParamsKey), bz) } // GetParams returns the total set of the channel parameters. -func (k Keeper) GetParams(ctx sdk.Context) types.Params { +func (k *Keeper) GetParams(ctx sdk.Context) types.Params { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.ParamsKey)) if bz == nil { // only panic on unset params and not on empty params @@ -628,7 +628,7 @@ func (Keeper) iterateHashes(ctx sdk.Context, iterator db.Iterator, cb func(portI // HasInflightPackets returns true if there are packet commitments stored at the specified // port and channel, and false otherwise. -func (k Keeper) HasInflightPackets(ctx sdk.Context, portID, channelID string) bool { +func (k *Keeper) HasInflightPackets(ctx sdk.Context, portID, channelID string) bool { iterator := storetypes.KVStorePrefixIterator(ctx.KVStore(k.storeKey), []byte(host.PacketCommitmentPrefixPath(portID, channelID))) defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() }) @@ -636,7 +636,7 @@ func (k Keeper) HasInflightPackets(ctx sdk.Context, portID, channelID string) bo } // setRecvStartSequence sets the channel's recv start sequence to the store. -func (k Keeper) setRecvStartSequence(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) setRecvStartSequence(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set(host.RecvStartSequenceKey(portID, channelID), bz) @@ -646,7 +646,7 @@ func (k Keeper) setRecvStartSequence(ctx sdk.Context, portID, channelID string, // The recv start sequence will be set to the counterparty's next sequence send // upon a successful channel upgrade. It will be used for replay protection of // historical packets and as the upper bound for pruning stale packet receives. -func (k Keeper) GetRecvStartSequence(ctx sdk.Context, portID, channelID string) (uint64, bool) { +func (k *Keeper) GetRecvStartSequence(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.RecvStartSequenceKey(portID, channelID)) if len(bz) == 0 { @@ -657,14 +657,14 @@ func (k Keeper) GetRecvStartSequence(ctx sdk.Context, portID, channelID string) } // SetPruningSequenceStart sets a channel's pruning sequence start to the store. -func (k Keeper) SetPruningSequenceStart(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) SetPruningSequenceStart(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) store.Set(host.PruningSequenceStartKey(portID, channelID), bz) } // GetPruningSequenceStart gets a channel's pruning sequence start from the store. -func (k Keeper) GetPruningSequenceStart(ctx sdk.Context, portID, channelID string) (uint64, bool) { +func (k *Keeper) GetPruningSequenceStart(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(host.PruningSequenceStartKey(portID, channelID)) if len(bz) == 0 { @@ -675,7 +675,7 @@ func (k Keeper) GetPruningSequenceStart(ctx sdk.Context, portID, channelID strin } // HasPruningSequenceStart returns true if the pruning sequence start is set for the specified channel. -func (k Keeper) HasPruningSequenceStart(ctx sdk.Context, portID, channelID string) bool { +func (k *Keeper) HasPruningSequenceStart(ctx sdk.Context, portID, channelID string) bool { store := ctx.KVStore(k.storeKey) return store.Has(host.PruningSequenceStartKey(portID, channelID)) } @@ -685,7 +685,7 @@ func (k Keeper) HasPruningSequenceStart(ctx sdk.Context, portID, channelID strin // // Pruning sequence start keeps track of the packet ack/receipt that can be pruned next. When it reaches pruningSequenceEnd, // pruning is complete. -func (k Keeper) PruneAcknowledgements(ctx sdk.Context, portID, channelID string, limit uint64) (uint64, uint64, error) { +func (k *Keeper) PruneAcknowledgements(ctx sdk.Context, portID, channelID string, limit uint64) (uint64, uint64, error) { pruningSequenceStart, found := k.GetPruningSequenceStart(ctx, portID, channelID) if !found { return 0, 0, errorsmod.Wrapf(types.ErrPruningSequenceStartNotFound, "port ID (%s) channel ID (%s)", portID, channelID) diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 3a8928a2044..08d1d678538 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -20,7 +20,7 @@ import ( // SendPacket is called by a module in order to send an IBC packet on a channel. // The packet sequence generated for the packet to be sent is returned. An error // is returned if one occurs. -func (k Keeper) SendPacket( +func (k *Keeper) SendPacket( ctx sdk.Context, channelCap *capabilitytypes.Capability, sourcePort string, @@ -105,7 +105,7 @@ func (k Keeper) SendPacket( // RecvPacket is called by a module in order to receive & process an IBC packet // sent on the corresponding channel end on the counterparty chain. -func (k Keeper) RecvPacket( +func (k *Keeper) RecvPacket( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet types.Packet, @@ -280,7 +280,7 @@ func (k Keeper) RecvPacket( // // 2) Assumes that packet receipt has been written (unordered), or nextSeqRecv was incremented (ordered) // previously by RecvPacket. -func (k Keeper) WriteAcknowledgement( +func (k *Keeper) WriteAcknowledgement( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet exported.PacketI, @@ -357,7 +357,7 @@ func (k Keeper) WriteAcknowledgement( // handler. AcknowledgePacket will clean up the packet commitment, // which is no longer necessary since the packet has been received and acted upon. // It will also increment NextSequenceAck in case of ORDERED channels. -func (k Keeper) AcknowledgePacket( +func (k *Keeper) AcknowledgePacket( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet types.Packet, diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index ed83e25b13a..8d7fdf892ff 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -22,7 +22,7 @@ import ( // packet can no longer be executed and to allow the calling module to safely // perform appropriate state transitions. Its intended usage is within the // ante handler. -func (k Keeper) TimeoutPacket( +func (k *Keeper) TimeoutPacket( ctx sdk.Context, packet types.Packet, proof []byte, @@ -130,7 +130,7 @@ func (k Keeper) TimeoutPacket( // then the channel will be set to the FLUSHCOMPLETE state. // // CONTRACT: this function must be called in the IBC handler -func (k Keeper) TimeoutExecuted( +func (k *Keeper) TimeoutExecuted( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet types.Packet, @@ -208,7 +208,7 @@ func (k Keeper) TimeoutExecuted( // TimeoutOnClose is called by a module in order to prove that the channel to // which an unreceived packet was addressed has been closed, so the packet will // never be received (even if the timeoutHeight has not yet been reached). -func (k Keeper) TimeoutOnClose( +func (k *Keeper) TimeoutOnClose( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet types.Packet, diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index 51f114dd457..955eed7f2d3 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -19,7 +19,7 @@ import ( // ChanUpgradeInit is called by a module to initiate a channel upgrade handshake with // a module on another chain. -func (k Keeper) ChanUpgradeInit( +func (k *Keeper) ChanUpgradeInit( ctx sdk.Context, portID string, channelID string, @@ -45,7 +45,7 @@ func (k Keeper) ChanUpgradeInit( // WriteUpgradeInitChannel writes a channel which has successfully passed the UpgradeInit handshake step. // An event is emitted for the handshake step. -func (k Keeper) WriteUpgradeInitChannel(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade, upgradeVersion string) (types.Channel, types.Upgrade) { +func (k *Keeper) WriteUpgradeInitChannel(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade, upgradeVersion string) (types.Channel, types.Upgrade) { defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-init") channel, found := k.GetChannel(ctx, portID, channelID) @@ -73,7 +73,7 @@ func (k Keeper) WriteUpgradeInitChannel(ctx sdk.Context, portID, channelID strin // ChanUpgradeTry is called by a module to accept the first step of a channel upgrade handshake initiated by // a module on another chain. If this function is successful, the proposed upgrade will be returned. If the upgrade fails, the upgrade sequence will still be incremented but an error will be returned. -func (k Keeper) ChanUpgradeTry( +func (k *Keeper) ChanUpgradeTry( ctx sdk.Context, portID, channelID string, @@ -223,7 +223,7 @@ func (k Keeper) ChanUpgradeTry( // WriteUpgradeTryChannel writes the channel end and upgrade to state after successfully passing the UpgradeTry handshake step. // An event is emitted for the handshake step. -func (k Keeper) WriteUpgradeTryChannel(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade, upgradeVersion string) (types.Channel, types.Upgrade) { +func (k *Keeper) WriteUpgradeTryChannel(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade, upgradeVersion string) (types.Channel, types.Upgrade) { defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-try") channel, found := k.GetChannel(ctx, portID, channelID) @@ -251,7 +251,7 @@ func (k Keeper) WriteUpgradeTryChannel(ctx sdk.Context, portID, channelID string // The channel may be in FLUSHING if we are in a crossing hellos situation. // // A -> Init (OPEN), B -> Init (OPEN) -> A -> Try (FLUSHING), B -> Try (FLUSHING), A -> Ack (begins in FLUSHING) -func (k Keeper) ChanUpgradeAck( +func (k *Keeper) ChanUpgradeAck( ctx sdk.Context, portID, channelID string, @@ -352,7 +352,7 @@ func (k Keeper) ChanUpgradeAck( // WriteUpgradeAckChannel writes a channel which has successfully passed the UpgradeAck handshake step as well as // setting the upgrade for that channel. // An event is emitted for the handshake step. -func (k Keeper) WriteUpgradeAckChannel(ctx sdk.Context, portID, channelID string, counterpartyUpgrade types.Upgrade) (types.Channel, types.Upgrade) { +func (k *Keeper) WriteUpgradeAckChannel(ctx sdk.Context, portID, channelID string, counterpartyUpgrade types.Upgrade) (types.Channel, types.Upgrade) { defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-ack") channel, found := k.GetChannel(ctx, portID, channelID) @@ -382,7 +382,7 @@ func (k Keeper) WriteUpgradeAckChannel(ctx sdk.Context, portID, channelID string // ChanUpgradeConfirm is called on the chain which is on FLUSHING after chanUpgradeAck is called on the counterparty. // This will inform the TRY chain of the timeout set on ACK by the counterparty. If the timeout has already exceeded, we will write an error receipt and restore. -func (k Keeper) ChanUpgradeConfirm( +func (k *Keeper) ChanUpgradeConfirm( ctx sdk.Context, portID, channelID string, @@ -460,7 +460,7 @@ func (k Keeper) ChanUpgradeConfirm( // If the channel has no in-flight packets, its state is updated to indicate that flushing has completed. Otherwise, the counterparty upgrade is set // and the channel state is left unchanged. // An event is emitted for the handshake step. -func (k Keeper) WriteUpgradeConfirmChannel(ctx sdk.Context, portID, channelID string, counterpartyUpgrade types.Upgrade) types.Channel { +func (k *Keeper) WriteUpgradeConfirmChannel(ctx sdk.Context, portID, channelID string, counterpartyUpgrade types.Upgrade) types.Channel { defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-confirm") channel, found := k.GetChannel(ctx, portID, channelID) @@ -482,7 +482,7 @@ func (k Keeper) WriteUpgradeConfirmChannel(ctx sdk.Context, portID, channelID st // ChanUpgradeOpen is called by a module to complete the channel upgrade handshake and move the channel back to an OPEN state. // This method should only be called after both channels have flushed any in-flight packets. // This method should only be called directly by the core IBC message server. -func (k Keeper) ChanUpgradeOpen( +func (k *Keeper) ChanUpgradeOpen( ctx sdk.Context, portID, channelID string, @@ -574,7 +574,7 @@ func (k Keeper) ChanUpgradeOpen( // WriteUpgradeOpenChannel writes the agreed upon upgrade fields to the channel, and sets the channel state back to OPEN. This can be called in one of two cases: // - In the UpgradeConfirm step of the handshake if both sides have already flushed all in-flight packets. // - In the UpgradeOpen step of the handshake. -func (k Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID string) types.Channel { +func (k *Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID string) types.Channel { channel, found := k.GetChannel(ctx, portID, channelID) if !found { panic(fmt.Errorf("could not find existing channel when updating channel state, channelID: %s, portID: %s", channelID, portID)) @@ -636,7 +636,7 @@ func (k Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID strin // ChanUpgradeCancel is called by the msg server to prove that an error receipt was written on the counterparty // which constitutes a valid situation where the upgrade should be cancelled. An error is returned if sufficient evidence // for cancelling the upgrade has not been provided. -func (k Keeper) ChanUpgradeCancel(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt, errorReceiptProof []byte, proofHeight clienttypes.Height) error { +func (k *Keeper) ChanUpgradeCancel(ctx sdk.Context, portID, channelID string, errorReceipt types.ErrorReceipt, errorReceiptProof []byte, proofHeight clienttypes.Height) error { channel, found := k.GetChannel(ctx, portID, channelID) if !found { return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) @@ -694,7 +694,7 @@ func (k Keeper) ChanUpgradeCancel(ctx sdk.Context, portID, channelID string, err // WriteUpgradeCancelChannel writes a channel which has canceled the upgrade process.Auxiliary upgrade state is // also deleted. -func (k Keeper) WriteUpgradeCancelChannel(ctx sdk.Context, portID, channelID string, sequence uint64) { +func (k *Keeper) WriteUpgradeCancelChannel(ctx sdk.Context, portID, channelID string, sequence uint64) { defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-cancel") channel, found := k.GetChannel(ctx, portID, channelID) @@ -712,7 +712,7 @@ func (k Keeper) WriteUpgradeCancelChannel(ctx sdk.Context, portID, channelID str // ChanUpgradeTimeout times out an outstanding upgrade. // This should be used by the initialising chain when the counterparty chain has not responded to an upgrade proposal within the specified timeout period. -func (k Keeper) ChanUpgradeTimeout( +func (k *Keeper) ChanUpgradeTimeout( ctx sdk.Context, portID, channelID string, counterpartyChannel types.Channel, @@ -808,7 +808,7 @@ func (k Keeper) ChanUpgradeTimeout( // WriteUpgradeTimeoutChannel restores the channel state of an initialising chain in the event that the counterparty chain has passed the timeout set in ChanUpgradeInit to the state before the upgrade was proposed. // Auxiliary upgrade state is also deleted. // An event is emitted for the handshake step. -func (k Keeper) WriteUpgradeTimeoutChannel( +func (k *Keeper) WriteUpgradeTimeoutChannel( ctx sdk.Context, portID, channelID string, ) (types.Channel, types.Upgrade) { @@ -834,7 +834,7 @@ func (k Keeper) WriteUpgradeTimeoutChannel( // startFlushing will set the upgrade last packet send and continue blocking the upgrade from continuing until all // in-flight packets have been flushed. -func (k Keeper) startFlushing(ctx sdk.Context, portID, channelID string, upgrade *types.Upgrade) error { +func (k *Keeper) startFlushing(ctx sdk.Context, portID, channelID string, upgrade *types.Upgrade) error { channel, found := k.GetChannel(ctx, portID, channelID) if !found { return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) @@ -865,13 +865,13 @@ func (k Keeper) startFlushing(ctx sdk.Context, portID, channelID string, upgrade } // getAbsoluteUpgradeTimeout returns the absolute timeout for the given upgrade. -func (k Keeper) getAbsoluteUpgradeTimeout(ctx sdk.Context) types.Timeout { +func (k *Keeper) getAbsoluteUpgradeTimeout(ctx sdk.Context) types.Timeout { upgradeTimeout := k.GetParams(ctx).UpgradeTimeout return types.NewTimeout(clienttypes.ZeroHeight(), uint64(ctx.BlockTime().UnixNano())+upgradeTimeout.Timestamp) } // checkForUpgradeCompatibility checks performs stateful validation of self upgrade fields relative to counterparty upgrade. -func (k Keeper) checkForUpgradeCompatibility(ctx sdk.Context, upgradeFields, counterpartyUpgradeFields types.UpgradeFields) error { +func (k *Keeper) checkForUpgradeCompatibility(ctx sdk.Context, upgradeFields, counterpartyUpgradeFields types.UpgradeFields) error { // assert that both sides propose the same channel ordering if upgradeFields.Ordering != counterpartyUpgradeFields.Ordering { return errorsmod.Wrapf(types.ErrIncompatibleCounterpartyUpgrade, "expected upgrade ordering (%s) to match counterparty upgrade ordering (%s)", upgradeFields.Ordering, counterpartyUpgradeFields.Ordering) @@ -909,7 +909,7 @@ func (k Keeper) checkForUpgradeCompatibility(ctx sdk.Context, upgradeFields, cou // - the proposed connection hops do not exist // - the proposed version is non-empty (checked in UpgradeFields.ValidateBasic()) // - the proposed connection hops are not open -func (k Keeper) validateSelfUpgradeFields(ctx sdk.Context, proposedUpgrade types.UpgradeFields, channel types.Channel) error { +func (k *Keeper) validateSelfUpgradeFields(ctx sdk.Context, proposedUpgrade types.UpgradeFields, channel types.Channel) error { currentFields := extractUpgradeFields(channel) if reflect.DeepEqual(proposedUpgrade, currentFields) { @@ -958,7 +958,7 @@ func extractUpgradeFields(channel types.Channel) types.UpgradeFields { // MustAbortUpgrade will restore the channel state to its pre-upgrade state so that upgrade is aborted. // Any unnecessary state is deleted and an error receipt is written. // This function is expected to always succeed, a panic will occur if an error occurs. -func (k Keeper) MustAbortUpgrade(ctx sdk.Context, portID, channelID string, err error) { +func (k *Keeper) MustAbortUpgrade(ctx sdk.Context, portID, channelID string, err error) { if err := k.abortUpgrade(ctx, portID, channelID, err); err != nil { panic(err) } @@ -968,7 +968,7 @@ func (k Keeper) MustAbortUpgrade(ctx sdk.Context, portID, channelID string, err // All upgrade information associated with the upgrade attempt is deleted and an upgrade error // receipt is written for that upgrade attempt. This prevents the upgrade handshake from continuing // on our side and provides proof for the counterparty to safely abort the upgrade. -func (k Keeper) abortUpgrade(ctx sdk.Context, portID, channelID string, err error) error { +func (k *Keeper) abortUpgrade(ctx sdk.Context, portID, channelID string, err error) error { if err == nil { return errorsmod.Wrap(types.ErrInvalidUpgradeError, "cannot abort upgrade handshake with nil error") } @@ -996,7 +996,7 @@ func (k Keeper) abortUpgrade(ctx sdk.Context, portID, channelID string, err erro // restoreChannel will restore the channel state to its pre-upgrade state so that upgrade is aborted. // When an upgrade attempt is aborted, the upgrade information must be deleted. This prevents us // from continuing an upgrade handshake after we cancel an upgrade attempt. -func (k Keeper) restoreChannel(ctx sdk.Context, portID, channelID string, upgradeSequence uint64, channel types.Channel) types.Channel { +func (k *Keeper) restoreChannel(ctx sdk.Context, portID, channelID string, upgradeSequence uint64, channel types.Channel) types.Channel { channel.State = types.OPEN channel.UpgradeSequence = upgradeSequence @@ -1009,7 +1009,7 @@ func (k Keeper) restoreChannel(ctx sdk.Context, portID, channelID string, upgrad } // WriteErrorReceipt will write an error receipt from the provided UpgradeError. -func (k Keeper) WriteErrorReceipt(ctx sdk.Context, portID, channelID string, upgradeError *types.UpgradeError) { +func (k *Keeper) WriteErrorReceipt(ctx sdk.Context, portID, channelID string, upgradeError *types.UpgradeError) { channel, found := k.GetChannel(ctx, portID, channelID) if !found { panic(errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID)) diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index a7475a95fa0..2e0d1416a23 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -33,7 +33,7 @@ func (Keeper) Logger(ctx sdk.Context) log.Logger { } // IsBound checks a given port ID is already bounded. -func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { +func (k *Keeper) IsBound(ctx sdk.Context, portID string) bool { _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) return ok } @@ -64,7 +64,7 @@ func (k *Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capab // by checking if the memory address of the capability was previously // generated and bound to the port (provided as a parameter) which the capability // is being authenticated against. -func (k Keeper) Authenticate(ctx sdk.Context, key *capabilitytypes.Capability, portID string) bool { +func (k *Keeper) Authenticate(ctx sdk.Context, key *capabilitytypes.Capability, portID string) bool { if err := host.PortIdentifierValidator(portID); err != nil { panic(err.Error()) } @@ -73,7 +73,7 @@ func (k Keeper) Authenticate(ctx sdk.Context, key *capabilitytypes.Capability, p } // LookupModuleByPort will return the IBCModule along with the capability associated with a given portID -func (k Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *capabilitytypes.Capability, error) { +func (k *Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *capabilitytypes.Capability, error) { modules, capability, err := k.scopedKeeper.LookupModules(ctx, host.PortPath(portID)) if err != nil { return "", nil, err diff --git a/modules/core/keeper/grpc_query.go b/modules/core/keeper/grpc_query.go index 259fb55e7d2..2a589738eea 100644 --- a/modules/core/keeper/grpc_query.go +++ b/modules/core/keeper/grpc_query.go @@ -9,166 +9,166 @@ import ( ) // ClientState implements the IBC QueryServer interface -func (k Keeper) ClientState(c context.Context, req *clienttypes.QueryClientStateRequest) (*clienttypes.QueryClientStateResponse, error) { +func (k *Keeper) ClientState(c context.Context, req *clienttypes.QueryClientStateRequest) (*clienttypes.QueryClientStateResponse, error) { return k.ClientKeeper.ClientState(c, req) } // ClientStates implements the IBC QueryServer interface -func (k Keeper) ClientStates(c context.Context, req *clienttypes.QueryClientStatesRequest) (*clienttypes.QueryClientStatesResponse, error) { +func (k *Keeper) ClientStates(c context.Context, req *clienttypes.QueryClientStatesRequest) (*clienttypes.QueryClientStatesResponse, error) { return k.ClientKeeper.ClientStates(c, req) } // ConsensusState implements the IBC QueryServer interface -func (k Keeper) ConsensusState(c context.Context, req *clienttypes.QueryConsensusStateRequest) (*clienttypes.QueryConsensusStateResponse, error) { +func (k *Keeper) ConsensusState(c context.Context, req *clienttypes.QueryConsensusStateRequest) (*clienttypes.QueryConsensusStateResponse, error) { return k.ClientKeeper.ConsensusState(c, req) } // ConsensusStates implements the IBC QueryServer interface -func (k Keeper) ConsensusStates(c context.Context, req *clienttypes.QueryConsensusStatesRequest) (*clienttypes.QueryConsensusStatesResponse, error) { +func (k *Keeper) ConsensusStates(c context.Context, req *clienttypes.QueryConsensusStatesRequest) (*clienttypes.QueryConsensusStatesResponse, error) { return k.ClientKeeper.ConsensusStates(c, req) } // ConsensusStateHeights implements the IBC QueryServer interface -func (k Keeper) ConsensusStateHeights(c context.Context, req *clienttypes.QueryConsensusStateHeightsRequest) (*clienttypes.QueryConsensusStateHeightsResponse, error) { +func (k *Keeper) ConsensusStateHeights(c context.Context, req *clienttypes.QueryConsensusStateHeightsRequest) (*clienttypes.QueryConsensusStateHeightsResponse, error) { return k.ClientKeeper.ConsensusStateHeights(c, req) } // ClientStatus implements the IBC QueryServer interface -func (k Keeper) ClientStatus(c context.Context, req *clienttypes.QueryClientStatusRequest) (*clienttypes.QueryClientStatusResponse, error) { +func (k *Keeper) ClientStatus(c context.Context, req *clienttypes.QueryClientStatusRequest) (*clienttypes.QueryClientStatusResponse, error) { return k.ClientKeeper.ClientStatus(c, req) } // ClientParams implements the IBC QueryServer interface -func (k Keeper) ClientParams(c context.Context, req *clienttypes.QueryClientParamsRequest) (*clienttypes.QueryClientParamsResponse, error) { +func (k *Keeper) ClientParams(c context.Context, req *clienttypes.QueryClientParamsRequest) (*clienttypes.QueryClientParamsResponse, error) { return k.ClientKeeper.ClientParams(c, req) } // UpgradedClientState implements the IBC QueryServer interface -func (k Keeper) UpgradedClientState(c context.Context, req *clienttypes.QueryUpgradedClientStateRequest) (*clienttypes.QueryUpgradedClientStateResponse, error) { +func (k *Keeper) UpgradedClientState(c context.Context, req *clienttypes.QueryUpgradedClientStateRequest) (*clienttypes.QueryUpgradedClientStateResponse, error) { return k.ClientKeeper.UpgradedClientState(c, req) } // UpgradedConsensusState implements the IBC QueryServer interface -func (k Keeper) UpgradedConsensusState(c context.Context, req *clienttypes.QueryUpgradedConsensusStateRequest) (*clienttypes.QueryUpgradedConsensusStateResponse, error) { +func (k *Keeper) UpgradedConsensusState(c context.Context, req *clienttypes.QueryUpgradedConsensusStateRequest) (*clienttypes.QueryUpgradedConsensusStateResponse, error) { return k.ClientKeeper.UpgradedConsensusState(c, req) } // VerifyMembership implements the IBC QueryServer interface. -func (k Keeper) VerifyMembership(c context.Context, req *clienttypes.QueryVerifyMembershipRequest) (*clienttypes.QueryVerifyMembershipResponse, error) { +func (k *Keeper) VerifyMembership(c context.Context, req *clienttypes.QueryVerifyMembershipRequest) (*clienttypes.QueryVerifyMembershipResponse, error) { return k.ClientKeeper.VerifyMembership(c, req) } // Connection implements the IBC QueryServer interface -func (k Keeper) Connection(c context.Context, req *connectiontypes.QueryConnectionRequest) (*connectiontypes.QueryConnectionResponse, error) { +func (k *Keeper) Connection(c context.Context, req *connectiontypes.QueryConnectionRequest) (*connectiontypes.QueryConnectionResponse, error) { return k.ConnectionKeeper.Connection(c, req) } // Connections implements the IBC QueryServer interface -func (k Keeper) Connections(c context.Context, req *connectiontypes.QueryConnectionsRequest) (*connectiontypes.QueryConnectionsResponse, error) { +func (k *Keeper) Connections(c context.Context, req *connectiontypes.QueryConnectionsRequest) (*connectiontypes.QueryConnectionsResponse, error) { return k.ConnectionKeeper.Connections(c, req) } // ClientConnections implements the IBC QueryServer interface -func (k Keeper) ClientConnections(c context.Context, req *connectiontypes.QueryClientConnectionsRequest) (*connectiontypes.QueryClientConnectionsResponse, error) { +func (k *Keeper) ClientConnections(c context.Context, req *connectiontypes.QueryClientConnectionsRequest) (*connectiontypes.QueryClientConnectionsResponse, error) { return k.ConnectionKeeper.ClientConnections(c, req) } // ConnectionClientState implements the IBC QueryServer interface -func (k Keeper) ConnectionClientState(c context.Context, req *connectiontypes.QueryConnectionClientStateRequest) (*connectiontypes.QueryConnectionClientStateResponse, error) { +func (k *Keeper) ConnectionClientState(c context.Context, req *connectiontypes.QueryConnectionClientStateRequest) (*connectiontypes.QueryConnectionClientStateResponse, error) { return k.ConnectionKeeper.ConnectionClientState(c, req) } // ConnectionConsensusState implements the IBC QueryServer interface -func (k Keeper) ConnectionConsensusState(c context.Context, req *connectiontypes.QueryConnectionConsensusStateRequest) (*connectiontypes.QueryConnectionConsensusStateResponse, error) { +func (k *Keeper) ConnectionConsensusState(c context.Context, req *connectiontypes.QueryConnectionConsensusStateRequest) (*connectiontypes.QueryConnectionConsensusStateResponse, error) { return k.ConnectionKeeper.ConnectionConsensusState(c, req) } // ConnectionParams implements the IBC QueryServer interface -func (k Keeper) ConnectionParams(c context.Context, req *connectiontypes.QueryConnectionParamsRequest) (*connectiontypes.QueryConnectionParamsResponse, error) { +func (k *Keeper) ConnectionParams(c context.Context, req *connectiontypes.QueryConnectionParamsRequest) (*connectiontypes.QueryConnectionParamsResponse, error) { return k.ConnectionKeeper.ConnectionParams(c, req) } // Channel implements the IBC QueryServer interface -func (k Keeper) Channel(c context.Context, req *channeltypes.QueryChannelRequest) (*channeltypes.QueryChannelResponse, error) { +func (k *Keeper) Channel(c context.Context, req *channeltypes.QueryChannelRequest) (*channeltypes.QueryChannelResponse, error) { return k.ChannelKeeper.Channel(c, req) } // Channels implements the IBC QueryServer interface -func (k Keeper) Channels(c context.Context, req *channeltypes.QueryChannelsRequest) (*channeltypes.QueryChannelsResponse, error) { +func (k *Keeper) Channels(c context.Context, req *channeltypes.QueryChannelsRequest) (*channeltypes.QueryChannelsResponse, error) { return k.ChannelKeeper.Channels(c, req) } // ConnectionChannels implements the IBC QueryServer interface -func (k Keeper) ConnectionChannels(c context.Context, req *channeltypes.QueryConnectionChannelsRequest) (*channeltypes.QueryConnectionChannelsResponse, error) { +func (k *Keeper) ConnectionChannels(c context.Context, req *channeltypes.QueryConnectionChannelsRequest) (*channeltypes.QueryConnectionChannelsResponse, error) { return k.ChannelKeeper.ConnectionChannels(c, req) } // ChannelClientState implements the IBC QueryServer interface -func (k Keeper) ChannelClientState(c context.Context, req *channeltypes.QueryChannelClientStateRequest) (*channeltypes.QueryChannelClientStateResponse, error) { +func (k *Keeper) ChannelClientState(c context.Context, req *channeltypes.QueryChannelClientStateRequest) (*channeltypes.QueryChannelClientStateResponse, error) { return k.ChannelKeeper.ChannelClientState(c, req) } // ChannelConsensusState implements the IBC QueryServer interface -func (k Keeper) ChannelConsensusState(c context.Context, req *channeltypes.QueryChannelConsensusStateRequest) (*channeltypes.QueryChannelConsensusStateResponse, error) { +func (k *Keeper) ChannelConsensusState(c context.Context, req *channeltypes.QueryChannelConsensusStateRequest) (*channeltypes.QueryChannelConsensusStateResponse, error) { return k.ChannelKeeper.ChannelConsensusState(c, req) } // PacketCommitment implements the IBC QueryServer interface -func (k Keeper) PacketCommitment(c context.Context, req *channeltypes.QueryPacketCommitmentRequest) (*channeltypes.QueryPacketCommitmentResponse, error) { +func (k *Keeper) PacketCommitment(c context.Context, req *channeltypes.QueryPacketCommitmentRequest) (*channeltypes.QueryPacketCommitmentResponse, error) { return k.ChannelKeeper.PacketCommitment(c, req) } // PacketCommitments implements the IBC QueryServer interface -func (k Keeper) PacketCommitments(c context.Context, req *channeltypes.QueryPacketCommitmentsRequest) (*channeltypes.QueryPacketCommitmentsResponse, error) { +func (k *Keeper) PacketCommitments(c context.Context, req *channeltypes.QueryPacketCommitmentsRequest) (*channeltypes.QueryPacketCommitmentsResponse, error) { return k.ChannelKeeper.PacketCommitments(c, req) } // PacketReceipt implements the IBC QueryServer interface -func (k Keeper) PacketReceipt(c context.Context, req *channeltypes.QueryPacketReceiptRequest) (*channeltypes.QueryPacketReceiptResponse, error) { +func (k *Keeper) PacketReceipt(c context.Context, req *channeltypes.QueryPacketReceiptRequest) (*channeltypes.QueryPacketReceiptResponse, error) { return k.ChannelKeeper.PacketReceipt(c, req) } // PacketAcknowledgement implements the IBC QueryServer interface -func (k Keeper) PacketAcknowledgement(c context.Context, req *channeltypes.QueryPacketAcknowledgementRequest) (*channeltypes.QueryPacketAcknowledgementResponse, error) { +func (k *Keeper) PacketAcknowledgement(c context.Context, req *channeltypes.QueryPacketAcknowledgementRequest) (*channeltypes.QueryPacketAcknowledgementResponse, error) { return k.ChannelKeeper.PacketAcknowledgement(c, req) } // PacketAcknowledgements implements the IBC QueryServer interface -func (k Keeper) PacketAcknowledgements(c context.Context, req *channeltypes.QueryPacketAcknowledgementsRequest) (*channeltypes.QueryPacketAcknowledgementsResponse, error) { +func (k *Keeper) PacketAcknowledgements(c context.Context, req *channeltypes.QueryPacketAcknowledgementsRequest) (*channeltypes.QueryPacketAcknowledgementsResponse, error) { return k.ChannelKeeper.PacketAcknowledgements(c, req) } // UnreceivedPackets implements the IBC QueryServer interface -func (k Keeper) UnreceivedPackets(c context.Context, req *channeltypes.QueryUnreceivedPacketsRequest) (*channeltypes.QueryUnreceivedPacketsResponse, error) { +func (k *Keeper) UnreceivedPackets(c context.Context, req *channeltypes.QueryUnreceivedPacketsRequest) (*channeltypes.QueryUnreceivedPacketsResponse, error) { return k.ChannelKeeper.UnreceivedPackets(c, req) } // UnreceivedAcks implements the IBC QueryServer interface -func (k Keeper) UnreceivedAcks(c context.Context, req *channeltypes.QueryUnreceivedAcksRequest) (*channeltypes.QueryUnreceivedAcksResponse, error) { +func (k *Keeper) UnreceivedAcks(c context.Context, req *channeltypes.QueryUnreceivedAcksRequest) (*channeltypes.QueryUnreceivedAcksResponse, error) { return k.ChannelKeeper.UnreceivedAcks(c, req) } // NextSequenceReceive implements the IBC QueryServer interface -func (k Keeper) NextSequenceReceive(c context.Context, req *channeltypes.QueryNextSequenceReceiveRequest) (*channeltypes.QueryNextSequenceReceiveResponse, error) { +func (k *Keeper) NextSequenceReceive(c context.Context, req *channeltypes.QueryNextSequenceReceiveRequest) (*channeltypes.QueryNextSequenceReceiveResponse, error) { return k.ChannelKeeper.NextSequenceReceive(c, req) } // NextSequenceSend implements the IBC QueryServer interface -func (k Keeper) NextSequenceSend(c context.Context, req *channeltypes.QueryNextSequenceSendRequest) (*channeltypes.QueryNextSequenceSendResponse, error) { +func (k *Keeper) NextSequenceSend(c context.Context, req *channeltypes.QueryNextSequenceSendRequest) (*channeltypes.QueryNextSequenceSendResponse, error) { return k.ChannelKeeper.NextSequenceSend(c, req) } // UpgradeError implements the IBC QueryServer interface -func (k Keeper) UpgradeError(c context.Context, req *channeltypes.QueryUpgradeErrorRequest) (*channeltypes.QueryUpgradeErrorResponse, error) { +func (k *Keeper) UpgradeError(c context.Context, req *channeltypes.QueryUpgradeErrorRequest) (*channeltypes.QueryUpgradeErrorResponse, error) { return k.ChannelKeeper.UpgradeErrorReceipt(c, req) } // Upgrade implements the IBC QueryServer interface -func (k Keeper) Upgrade(c context.Context, req *channeltypes.QueryUpgradeRequest) (*channeltypes.QueryUpgradeResponse, error) { +func (k *Keeper) Upgrade(c context.Context, req *channeltypes.QueryUpgradeRequest) (*channeltypes.QueryUpgradeResponse, error) { return k.ChannelKeeper.Upgrade(c, req) } // ChannelParams implements the IBC QueryServer interface -func (k Keeper) ChannelParams(c context.Context, req *channeltypes.QueryChannelParamsRequest) (*channeltypes.QueryChannelParamsResponse, error) { +func (k *Keeper) ChannelParams(c context.Context, req *channeltypes.QueryChannelParamsRequest) (*channeltypes.QueryChannelParamsResponse, error) { return k.ChannelKeeper.ChannelParams(c, req) } diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 42a778f1665..04d85ab099e 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -77,7 +77,7 @@ func NewKeeper( } // Codec returns the IBC module codec. -func (k Keeper) Codec() codec.BinaryCodec { +func (k *Keeper) Codec() codec.BinaryCodec { return k.cdc } @@ -103,7 +103,7 @@ func (k *Keeper) SetRouter(rtr *porttypes.Router) { } // GetAuthority returns the ibc module's authority. -func (k Keeper) GetAuthority() string { +func (k *Keeper) GetAuthority() string { return k.authority } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index b213a35b85e..a2628ecb7ea 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -32,7 +32,7 @@ var ( // of the light client module to unmarshal and interpret the proto encoded bytes. // Backwards compatibility with older versions of ibc-go is maintained through the light client module reconstructing and encoding // the expected concrete type to the protobuf.Any for proof verification. -func (k Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) { +func (k *Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) clientState, err := clienttypes.UnpackClientState(msg.ClientState) @@ -48,7 +48,7 @@ func (k Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateCl } // UpdateClient defines a rpc handler method for MsgUpdateClient. -func (k Keeper) UpdateClient(goCtx context.Context, msg *clienttypes.MsgUpdateClient) (*clienttypes.MsgUpdateClientResponse, error) { +func (k *Keeper) UpdateClient(goCtx context.Context, msg *clienttypes.MsgUpdateClient) (*clienttypes.MsgUpdateClientResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) clientMsg, err := clienttypes.UnpackClientMessage(msg.ClientMessage) @@ -69,7 +69,7 @@ func (k Keeper) UpdateClient(goCtx context.Context, msg *clienttypes.MsgUpdateCl // of the light client module to unmarshal and interpret the proto encoded bytes. // Backwards compatibility with older versions of ibc-go is maintained through the light client module reconstructing and encoding // the expected concrete type to the protobuf.Any for proof verification. -func (k Keeper) UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgradeClient) (*clienttypes.MsgUpgradeClientResponse, error) { +func (k *Keeper) UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgradeClient) (*clienttypes.MsgUpgradeClientResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := k.ClientKeeper.UpgradeClient( @@ -88,7 +88,7 @@ func (k Keeper) UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgrade // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. // Warning: DEPRECATED // This handler is redundant as `MsgUpdateClient` is now capable of handling both a Header and a Misbehaviour -func (k Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { //nolint:staticcheck // for now, we're using msgsubmitmisbehaviour. +func (k *Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { //nolint:staticcheck // for now, we're using msgsubmitmisbehaviour. ctx := sdk.UnwrapSDKContext(goCtx) misbehaviour, err := clienttypes.UnpackClientMessage(msg.Misbehaviour) @@ -104,7 +104,7 @@ func (k Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSu } // RecoverClient defines a rpc handler method for MsgRecoverClient. -func (k Keeper) RecoverClient(goCtx context.Context, msg *clienttypes.MsgRecoverClient) (*clienttypes.MsgRecoverClientResponse, error) { +func (k *Keeper) RecoverClient(goCtx context.Context, msg *clienttypes.MsgRecoverClient) (*clienttypes.MsgRecoverClientResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } @@ -118,7 +118,7 @@ func (k Keeper) RecoverClient(goCtx context.Context, msg *clienttypes.MsgRecover } // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. -func (k Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgIBCSoftwareUpgrade) (*clienttypes.MsgIBCSoftwareUpgradeResponse, error) { +func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgIBCSoftwareUpgrade) (*clienttypes.MsgIBCSoftwareUpgradeResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } @@ -137,7 +137,7 @@ func (k Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgIB } // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. -func (k Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error) { +func (k *Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if _, err := k.ConnectionKeeper.ConnOpenInit(ctx, msg.ClientId, msg.Counterparty, msg.Version, msg.DelayPeriod); err != nil { @@ -148,7 +148,7 @@ func (k Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.M } // ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. -func (k Keeper) ConnectionOpenTry(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenTry) (*connectiontypes.MsgConnectionOpenTryResponse, error) { +func (k *Keeper) ConnectionOpenTry(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenTry) (*connectiontypes.MsgConnectionOpenTryResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) targetClient, err := clienttypes.UnpackClientState(msg.ClientState) @@ -168,7 +168,7 @@ func (k Keeper) ConnectionOpenTry(goCtx context.Context, msg *connectiontypes.Ms } // ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. -func (k Keeper) ConnectionOpenAck(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenAck) (*connectiontypes.MsgConnectionOpenAckResponse, error) { +func (k *Keeper) ConnectionOpenAck(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenAck) (*connectiontypes.MsgConnectionOpenAckResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) targetClient, err := clienttypes.UnpackClientState(msg.ClientState) @@ -188,7 +188,7 @@ func (k Keeper) ConnectionOpenAck(goCtx context.Context, msg *connectiontypes.Ms } // ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. -func (k Keeper) ConnectionOpenConfirm(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenConfirm) (*connectiontypes.MsgConnectionOpenConfirmResponse, error) { +func (k *Keeper) ConnectionOpenConfirm(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenConfirm) (*connectiontypes.MsgConnectionOpenConfirmResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := k.ConnectionKeeper.ConnOpenConfirm( @@ -203,7 +203,7 @@ func (k Keeper) ConnectionOpenConfirm(goCtx context.Context, msg *connectiontype // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. // ChannelOpenInit will perform 04-channel checks, route to the application // callback, and write an OpenInit channel into state upon successful execution. -func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChannelOpenInit) (*channeltypes.MsgChannelOpenInitResponse, error) { +func (k *Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChannelOpenInit) (*channeltypes.MsgChannelOpenInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by port capability @@ -251,7 +251,7 @@ func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChan // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. // ChannelOpenTry will perform 04-channel checks, route to the application // callback, and write an OpenTry channel into state upon successful execution. -func (k Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChannelOpenTry) (*channeltypes.MsgChannelOpenTryResponse, error) { +func (k *Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChannelOpenTry) (*channeltypes.MsgChannelOpenTryResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by port capability @@ -298,7 +298,7 @@ func (k Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChann // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. // ChannelOpenAck will perform 04-channel checks, route to the application // callback, and write an OpenAck channel into state upon successful execution. -func (k Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChannelOpenAck) (*channeltypes.MsgChannelOpenAckResponse, error) { +func (k *Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChannelOpenAck) (*channeltypes.MsgChannelOpenAckResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability @@ -340,7 +340,7 @@ func (k Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChann // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. // ChannelOpenConfirm will perform 04-channel checks, route to the application // callback, and write an OpenConfirm channel into state upon successful execution. -func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgChannelOpenConfirm) (*channeltypes.MsgChannelOpenConfirmResponse, error) { +func (k *Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgChannelOpenConfirm) (*channeltypes.MsgChannelOpenConfirmResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability @@ -378,7 +378,7 @@ func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgC } // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. -func (k Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgChannelCloseInit) (*channeltypes.MsgChannelCloseInitResponse, error) { +func (k *Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgChannelCloseInit) (*channeltypes.MsgChannelCloseInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability @@ -412,7 +412,7 @@ func (k Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgCha } // ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm. -func (k Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.MsgChannelCloseConfirm) (*channeltypes.MsgChannelCloseConfirmResponse, error) { +func (k *Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.MsgChannelCloseConfirm) (*channeltypes.MsgChannelCloseConfirmResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability @@ -446,7 +446,7 @@ func (k Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Msg } // RecvPacket defines a rpc handler method for MsgRecvPacket. -func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacket) (*channeltypes.MsgRecvPacketResponse, error) { +func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacket) (*channeltypes.MsgRecvPacketResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -527,7 +527,7 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke } // Timeout defines a rpc handler method for MsgTimeout. -func (k Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { +func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -599,7 +599,7 @@ func (k Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*c } // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. -func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeoutOnClose) (*channeltypes.MsgTimeoutOnCloseResponse, error) { +func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeoutOnClose) (*channeltypes.MsgTimeoutOnCloseResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -674,7 +674,7 @@ func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeo } // Acknowledgement defines a rpc handler method for MsgAcknowledgement. -func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) { +func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) relayer, err := sdk.AccAddressFromBech32(msg.Signer) @@ -740,7 +740,7 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn } // ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit. -func (k Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeInit) (*channeltypes.MsgChannelUpgradeInitResponse, error) { +func (k *Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeInit) (*channeltypes.MsgChannelUpgradeInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if k.GetAuthority() != msg.Signer { @@ -792,7 +792,7 @@ func (k Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.MsgC } // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. -func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTry) (*channeltypes.MsgChannelUpgradeTryResponse, error) { +func (k *Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTry) (*channeltypes.MsgChannelUpgradeTryResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) @@ -853,7 +853,7 @@ func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgCh } // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. -func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeAck) (*channeltypes.MsgChannelUpgradeAckResponse, error) { +func (k *Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeAck) (*channeltypes.MsgChannelUpgradeAckResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) @@ -919,7 +919,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh } // ChannelUpgradeConfirm defines a rpc handler method for MsgChannelUpgradeConfirm. -func (k Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeConfirm) (*channeltypes.MsgChannelUpgradeConfirmResponse, error) { +func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeConfirm) (*channeltypes.MsgChannelUpgradeConfirmResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) @@ -980,7 +980,7 @@ func (k Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.M } // ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. -func (k Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeOpen) (*channeltypes.MsgChannelUpgradeOpenResponse, error) { +func (k *Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeOpen) (*channeltypes.MsgChannelUpgradeOpenResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) @@ -1023,7 +1023,7 @@ func (k Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgC } // ChannelUpgradeTimeout defines a rpc handler method for MsgChannelUpgradeTimeout. -func (k Keeper) ChannelUpgradeTimeout(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTimeout) (*channeltypes.MsgChannelUpgradeTimeoutResponse, error) { +func (k *Keeper) ChannelUpgradeTimeout(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTimeout) (*channeltypes.MsgChannelUpgradeTimeoutResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := k.ChannelKeeper.ChanUpgradeTimeout(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannel, msg.ProofChannel, msg.ProofHeight); err != nil { @@ -1039,7 +1039,7 @@ func (k Keeper) ChannelUpgradeTimeout(goCtx context.Context, msg *channeltypes.M } // ChannelUpgradeCancel defines a rpc handler method for MsgChannelUpgradeCancel. -func (k Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeCancel) (*channeltypes.MsgChannelUpgradeCancelResponse, error) { +func (k *Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeCancel) (*channeltypes.MsgChannelUpgradeCancelResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) channel, found := k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId) @@ -1091,7 +1091,7 @@ func (k Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.Ms } // PruneAcknowledgements defines a rpc handler method for MsgPruneAcknowledgements. -func (k Keeper) PruneAcknowledgements(goCtx context.Context, msg *channeltypes.MsgPruneAcknowledgements) (*channeltypes.MsgPruneAcknowledgementsResponse, error) { +func (k *Keeper) PruneAcknowledgements(goCtx context.Context, msg *channeltypes.MsgPruneAcknowledgements) (*channeltypes.MsgPruneAcknowledgementsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) pruned, remaining, err := k.ChannelKeeper.PruneAcknowledgements(ctx, msg.PortId, msg.ChannelId, msg.Limit) @@ -1106,7 +1106,7 @@ func (k Keeper) PruneAcknowledgements(goCtx context.Context, msg *channeltypes.M } // UpdateClientParams defines a rpc handler method for MsgUpdateParams. -func (k Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUpdateParams) (*clienttypes.MsgUpdateParamsResponse, error) { +func (k *Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUpdateParams) (*clienttypes.MsgUpdateParamsResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } @@ -1118,7 +1118,7 @@ func (k Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUp } // UpdateConnectionParams defines a rpc handler method for MsgUpdateParams for the 03-connection submodule. -func (k Keeper) UpdateConnectionParams(goCtx context.Context, msg *connectiontypes.MsgUpdateParams) (*connectiontypes.MsgUpdateParamsResponse, error) { +func (k *Keeper) UpdateConnectionParams(goCtx context.Context, msg *connectiontypes.MsgUpdateParams) (*connectiontypes.MsgUpdateParamsResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } @@ -1130,7 +1130,7 @@ func (k Keeper) UpdateConnectionParams(goCtx context.Context, msg *connectiontyp } // UpdateChannelParams defines a rpc handler method for MsgUpdateParams. -func (k Keeper) UpdateChannelParams(goCtx context.Context, msg *channeltypes.MsgUpdateParams) (*channeltypes.MsgUpdateParamsResponse, error) { +func (k *Keeper) UpdateChannelParams(goCtx context.Context, msg *channeltypes.MsgUpdateParams) (*channeltypes.MsgUpdateParamsResponse, error) { if k.GetAuthority() != msg.Authority { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) } diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index a6855b0b6a9..b213c22fa13 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress().String()) ctx := suite.chainB.GetContext() - _, err := keeper.Keeper.RecvPacket(*suite.chainB.App.GetIBCKeeper(), ctx, msg) + _, err := suite.chainB.App.GetIBCKeeper().RecvPacket(ctx, msg) events := ctx.EventManager().Events() @@ -180,7 +180,7 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { suite.Require().NoError(err) // replay should not fail since it will be treated as a no-op - _, err := keeper.Keeper.RecvPacket(*suite.chainB.App.GetIBCKeeper(), suite.chainB.GetContext(), msg) + _, err := suite.chainB.App.GetIBCKeeper().RecvPacket(suite.chainB.GetContext(), msg) suite.Require().NoError(err) // check that callback state was handled correctly @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestRecoverClient() { tc.malleate() - _, err = keeper.Keeper.RecoverClient(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg) + _, err = suite.chainA.App.GetIBCKeeper().RecoverClient(suite.chainA.GetContext(), msg) expPass := tc.expErr == nil if expPass { @@ -426,7 +426,7 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement.Acknowledgement(), proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) ctx := suite.chainA.GetContext() - _, err := keeper.Keeper.Acknowledgement(*suite.chainA.App.GetIBCKeeper(), ctx, msg) + _, err := suite.chainA.App.GetIBCKeeper().Acknowledgement(ctx, msg) events := ctx.EventManager().Events() @@ -438,7 +438,7 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { suite.Require().False(has) // replay should not error as it is treated as a no-op - _, err := keeper.Keeper.Acknowledgement(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg) + _, err := suite.chainA.App.GetIBCKeeper().Acknowledgement(suite.chainA.GetContext(), msg) suite.Require().NoError(err) if tc.replay { @@ -583,7 +583,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { msg := channeltypes.NewMsgTimeout(packet, 1, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) ctx := suite.chainA.GetContext() - _, err := keeper.Keeper.Timeout(*suite.chainA.App.GetIBCKeeper(), ctx, msg) + _, err := suite.chainA.App.GetIBCKeeper().Timeout(ctx, msg) events := ctx.EventManager().Events() @@ -591,7 +591,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { suite.Require().NoError(err) // replay should not return an error as it is treated as a no-op - _, err := keeper.Keeper.Timeout(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg) + _, err := suite.chainA.App.GetIBCKeeper().Timeout(suite.chainA.GetContext(), msg) suite.Require().NoError(err) // verify packet commitment was deleted on source chain @@ -757,13 +757,13 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { msg := channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, closedProof, proofHeight, suite.chainA.SenderAccount.GetAddress().String(), counterpartyUpgradeSequence) - _, err := keeper.Keeper.TimeoutOnClose(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg) + _, err := suite.chainA.App.GetIBCKeeper().TimeoutOnClose(suite.chainA.GetContext(), msg) if tc.expPass { suite.Require().NoError(err) // replay should not return an error as it will be treated as a no-op - _, err := keeper.Keeper.TimeoutOnClose(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg) + _, err := suite.chainA.App.GetIBCKeeper().TimeoutOnClose(suite.chainA.GetContext(), msg) suite.Require().NoError(err) // verify packet commitment was deleted on source chain @@ -2532,7 +2532,7 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() { tc.malleate() - _, err = keeper.Keeper.IBCSoftwareUpgrade(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg) + _, err = suite.chainA.App.GetIBCKeeper().IBCSoftwareUpgrade(suite.chainA.GetContext(), msg) if tc.expError == nil { suite.Require().NoError(err) @@ -2593,7 +2593,7 @@ func (suite *KeeperTestSuite) TestUpdateClientParams() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - _, err := keeper.Keeper.UpdateClientParams(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), tc.msg) + _, err := suite.chainA.App.GetIBCKeeper().UpdateClientParams(suite.chainA.GetContext(), tc.msg) if tc.expPass { suite.Require().NoError(err) p := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetParams(suite.chainA.GetContext()) @@ -2644,7 +2644,7 @@ func (suite *KeeperTestSuite) TestUpdateConnectionParams() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - _, err := keeper.Keeper.UpdateConnectionParams(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), tc.msg) + _, err := suite.chainA.App.GetIBCKeeper().UpdateConnectionParams(suite.chainA.GetContext(), tc.msg) if tc.expPass { suite.Require().NoError(err) p := suite.chainA.App.GetIBCKeeper().ConnectionKeeper.GetParams(suite.chainA.GetContext()) @@ -2695,7 +2695,7 @@ func (suite *KeeperTestSuite) TestUpdateChannelParams() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - resp, err := keeper.Keeper.UpdateChannelParams(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), tc.msg) + resp, err := suite.chainA.App.GetIBCKeeper().UpdateChannelParams(suite.chainA.GetContext(), tc.msg) expPass := tc.expError == nil if expPass { suite.Require().NoError(err)