From f9e8b323dc7d7d1c900583d76a37ba821c2feda3 Mon Sep 17 00:00:00 2001 From: Sean King Date: Fri, 17 Sep 2021 18:26:38 +0200 Subject: [PATCH 1/5] refactor: making IsBound a public function --- modules/core/05-port/keeper/keeper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index d864e60456c..0ef9850a709 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -31,8 +31,8 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+host.ModuleName+"/"+types.SubModuleName) } -// isBounded checks a given port ID is already bounded. -func (k Keeper) isBound(ctx sdk.Context, portID string) bool { +// IsBound checks a given port ID is already bounded. +func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) return ok } @@ -46,7 +46,7 @@ func (k *Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capab panic(err.Error()) } - if k.isBound(ctx, portID) { + if k.IsBound(ctx, portID) { panic(fmt.Sprintf("port %s is already bound", portID)) } From fcd69a6c62e0260538eb5fb86f8ec350ab849245 Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 22 Sep 2021 15:02:19 +0200 Subject: [PATCH 2/5] chore: make 05-port keeper function IsBound public --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81eac3c769c..ac1c643da3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -135,6 +135,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (modules/light-clients/07-tendermint) [\#125](https://github.com/cosmos/ibc-go/pull/125) Implement efficient iteration of consensus states and pruning of earliest expired consensus state on UpdateClient. * (modules/light-clients/07-tendermint) [\#141](https://github.com/cosmos/ibc-go/pull/141) Return early in case there's a duplicate update call to save Gas. * (modules/core/ante) [\#235](https://github.com/cosmos/ibc-go/pull/235) Introduces a new IBC Antedecorator that will reject transactions that only contain redundant packet messages (and accompany UpdateClient msgs). This will prevent relayers from wasting fees by submitting messages for packets that have already been processed by previous relayer(s). The Antedecorator is only applied on CheckTx and RecheckTx and is therefore optional for each node. +* (modules/core/05-port) [\#288](https://github.com/cosmos/ibc-go/issues/288) Making the keeper function IsBound public. The IsBound function checks if the provided portID is already binded to a module. ### Features From de76051602d1b07db497f864c31487c6ca327c8b Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 22 Sep 2021 15:19:24 +0200 Subject: [PATCH 3/5] test: adding test for IsBound --- modules/core/05-port/keeper/keeper_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/core/05-port/keeper/keeper_test.go b/modules/core/05-port/keeper/keeper_test.go index 1bfc7428f19..2222517c05a 100644 --- a/modules/core/05-port/keeper/keeper_test.go +++ b/modules/core/05-port/keeper/keeper_test.go @@ -44,6 +44,12 @@ func (suite *KeeperTestSuite) TestBind() { capKey := suite.keeper.BindPort(suite.ctx, validPort) require.NotNil(suite.T(), capKey, "capabilityKey is nil on valid BindPort") + isBound := suite.keeper.IsBound(suite.ctx, validPort) + require.True(suite.T(), isBound, "port is bound successfully") + + isNotBound := suite.keeper.IsBound(suite.ctx, "not-a-port") + require.False(suite.T(), isNotBound, "port is not bound") + // Test that rebinding the same portid causes panic require.Panics(suite.T(), func() { suite.keeper.BindPort(suite.ctx, validPort) }, "did not panic on re-binding the same port") } From 38490c74eceaa80d34a584c92aab7352b63c72c3 Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 22 Sep 2021 15:21:26 +0200 Subject: [PATCH 4/5] chore: updating changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac1c643da3a..85595d11a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -135,7 +135,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (modules/light-clients/07-tendermint) [\#125](https://github.com/cosmos/ibc-go/pull/125) Implement efficient iteration of consensus states and pruning of earliest expired consensus state on UpdateClient. * (modules/light-clients/07-tendermint) [\#141](https://github.com/cosmos/ibc-go/pull/141) Return early in case there's a duplicate update call to save Gas. * (modules/core/ante) [\#235](https://github.com/cosmos/ibc-go/pull/235) Introduces a new IBC Antedecorator that will reject transactions that only contain redundant packet messages (and accompany UpdateClient msgs). This will prevent relayers from wasting fees by submitting messages for packets that have already been processed by previous relayer(s). The Antedecorator is only applied on CheckTx and RecheckTx and is therefore optional for each node. -* (modules/core/05-port) [\#288](https://github.com/cosmos/ibc-go/issues/288) Making the keeper function IsBound public. The IsBound function checks if the provided portID is already binded to a module. +* (modules/core/05-port) [\#288](https://github.com/cosmos/ibc-go/issues/288) Making the 05-port keeper function IsBound public. The IsBound function checks if the provided portID is already binded to a module. ### Features From 2f2885707ba2d49d694cb63e97a69b21a7093655 Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 22 Sep 2021 16:07:50 +0200 Subject: [PATCH 5/5] fix: changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85595d11a3e..f246be20c62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * [\#383](https://github.com/cosmos/ibc-go/pull/383) Adds helper functions for merging and splitting middleware versions from the underlying app version. +* (modules/core/05-port) [\#288](https://github.com/cosmos/ibc-go/issues/288) Making the 05-port keeper function IsBound public. The IsBound function checks if the provided portID is already binded to a module. ### Features @@ -135,7 +136,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (modules/light-clients/07-tendermint) [\#125](https://github.com/cosmos/ibc-go/pull/125) Implement efficient iteration of consensus states and pruning of earliest expired consensus state on UpdateClient. * (modules/light-clients/07-tendermint) [\#141](https://github.com/cosmos/ibc-go/pull/141) Return early in case there's a duplicate update call to save Gas. * (modules/core/ante) [\#235](https://github.com/cosmos/ibc-go/pull/235) Introduces a new IBC Antedecorator that will reject transactions that only contain redundant packet messages (and accompany UpdateClient msgs). This will prevent relayers from wasting fees by submitting messages for packets that have already been processed by previous relayer(s). The Antedecorator is only applied on CheckTx and RecheckTx and is therefore optional for each node. -* (modules/core/05-port) [\#288](https://github.com/cosmos/ibc-go/issues/288) Making the 05-port keeper function IsBound public. The IsBound function checks if the provided portID is already binded to a module. ### Features