Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed icatypes.PortPrefix to icatypes.ControllerPortPrefix #2450

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (light-clients/06-solomachine) Moving `verifyMisbehaviour` function from update.go to misbehaviour_handle.go.
* (apps/27-interchain-accounts) [\#2297](https://github.com/cosmos/ibc-go/pull/2297) Adding cli command to generate ICS27 packet data.
* (modules/core/keeper) [\#1728](https://github.com/cosmos/ibc-go/pull/2399) Updated channel callback errors to include portID & channelID for better identification of errors.
* (modules/apps/27-interchain-accounts) [\#2433](https://github.com/cosmos/ibc-go/pull/2450) Renamed icatypes.PortPrefix to icatypes.ControllerPortPrefix & icatypes.PortID to icatypes.HostPortID
alizahidraja marked this conversation as resolved.
Show resolved Hide resolved

### Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func (suite *InterchainAccountsTestSuite) SetupTest() {

func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = icatypes.PortID
path.EndpointB.ChannelConfig.PortID = icatypes.PortID
path.EndpointA.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointA.ChannelConfig.Version = TestVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (k Keeper) registerInterchainAccount(ctx sdk.Context, connectionID, portID,
}
}

msg := channeltypes.NewMsgChannelOpenInit(portID, version, channeltypes.ORDERED, []string{connectionID}, icatypes.PortID, icatypes.ModuleName)
msg := channeltypes.NewMsgChannelOpenInit(portID, version, channeltypes.ORDERED, []string{connectionID}, icatypes.HostPortID, icatypes.ModuleName)
handler := k.msgRouter.Handler(msg)
res, err := handler(ctx, msg)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func (k Keeper) OnChanOpenInit(
return "", sdkerrors.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order)
}

if !strings.HasPrefix(portID, icatypes.PortPrefix) {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "expected %s{owner-account-address}, got %s", icatypes.PortPrefix, portID)
if !strings.HasPrefix(portID, icatypes.ControllerPortPrefix) {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "expected %s{owner-account-address}, got %s", icatypes.ControllerPortPrefix, portID)
}

if counterparty.PortId != icatypes.PortID {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidHostPort, "expected %s, got %s", icatypes.PortID, counterparty.PortId)
if counterparty.PortId != icatypes.HostPortID {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidHostPort, "expected %s, got %s", icatypes.HostPortID, counterparty.PortId)
}

var metadata icatypes.Metadata
Expand Down Expand Up @@ -91,12 +91,12 @@ func (k Keeper) OnChanOpenAck(
channelID string,
counterpartyVersion string,
) error {
if portID == icatypes.PortID {
return sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "portID cannot be host chain port ID: %s", icatypes.PortID)
if portID == icatypes.HostPortID {
return sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "portID cannot be host chain port ID: %s", icatypes.HostPortID)
}

if !strings.HasPrefix(portID, icatypes.PortPrefix) {
return sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "expected %s{owner-account-address}, got %s", icatypes.PortPrefix, portID)
if !strings.HasPrefix(portID, icatypes.ControllerPortPrefix) {
return sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "expected %s{owner-account-address}, got %s", icatypes.ControllerPortPrefix, portID)
}

var metadata icatypes.Metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenAck() {
{
"invalid port ID - host chain",
func() {
path.EndpointA.ChannelConfig.PortID = icatypes.PortID
path.EndpointA.ChannelConfig.PortID = icatypes.HostPortID
},
false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (suite *KeeperTestSuite) SetupTest() {

func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = icatypes.PortID
path.EndpointB.ChannelConfig.PortID = icatypes.PortID
path.EndpointA.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointA.ChannelConfig.Version = TestVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewMigrator(keeper *Keeper) Migrator {
// are owned by the controller submodule and ibc.
func (m Migrator) AssertChannelCapabilityMigrations(ctx sdk.Context) error {
if m.keeper != nil {
filteredChannels := m.keeper.channelKeeper.GetAllChannelsWithPortPrefix(ctx, icatypes.PortPrefix)
filteredChannels := m.keeper.channelKeeper.GetAllChannelsWithPortPrefix(ctx, icatypes.ControllerPortPrefix)
for _, ch := range filteredChannels {
name := host.ChannelCapabilityPath(ch.PortId, ch.ChannelId)
capability, found := m.keeper.scopedKeeper.GetCapability(ctx, name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (suite *KeeperTestSuite) TestAssertChannelCapabilityMigrations() {
{
"capability not found",
func() {
portIDWithPrefix := fmt.Sprintf("%s%s", icatypes.PortPrefix, "port-without-capability")
portIDWithPrefix := fmt.Sprintf("%s%s", icatypes.ControllerPortPrefix, "port-without-capability")
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), portIDWithPrefix, ibctesting.FirstChannelID, channeltypes.Channel{
ConnectionHops: []string{ibctesting.FirstConnectionID},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func (suite *MigrationsTestSuite) SetupTest() {
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2))

suite.path = ibctesting.NewPath(suite.chainA, suite.chainB)
suite.path.EndpointA.ChannelConfig.PortID = icatypes.PortID
suite.path.EndpointB.ChannelConfig.PortID = icatypes.PortID
suite.path.EndpointA.ChannelConfig.PortID = icatypes.HostPortID
suite.path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID
suite.path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED
suite.path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED
suite.path.EndpointA.ChannelConfig.Version = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (gs ControllerGenesisState) Validate() error {
// DefaultHostGenesis creates and returns the default interchain accounts HostGenesisState
func DefaultHostGenesis() HostGenesisState {
return HostGenesisState{
Port: icatypes.PortID,
Port: icatypes.HostPortID,
Params: hosttypes.DefaultParams(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() {
},
}

genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.PortID, hosttypes.DefaultParams())
genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.HostPortID, hosttypes.DefaultParams())
},
false,
},
Expand All @@ -235,7 +235,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() {
},
}

genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.PortID, hosttypes.DefaultParams())
genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.HostPortID, hosttypes.DefaultParams())
},
false,
},
Expand All @@ -256,7 +256,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() {
},
}

genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.PortID, hosttypes.DefaultParams())
genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.HostPortID, hosttypes.DefaultParams())
},
false,
},
Expand All @@ -277,7 +277,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() {
},
}

genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.PortID, hosttypes.DefaultParams())
genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.HostPortID, hosttypes.DefaultParams())
},
false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func GetCmdPacketEvents() *cobra.Command {
return err
}

channelID, portID := args[0], icatypes.PortID
channelID, portID := args[0], icatypes.HostPortID
if err := host.ChannelIdentifierValidator(channelID); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/host/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (suite *InterchainAccountsTestSuite) SetupTest() {

func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = icatypes.PortID
path.EndpointB.ChannelConfig.PortID = icatypes.PortID
path.EndpointA.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointA.ChannelConfig.Version = TestVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) genesistypes.HostGenesisState
return genesistypes.NewHostGenesisState(
keeper.GetAllActiveChannels(ctx),
keeper.GetAllInterchainAccounts(ctx),
icatypes.PortID,
icatypes.HostPortID,
keeper.GetParams(ctx),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
AccountAddress: interchainAccAddr.String(),
},
},
Port: icatypes.PortID,
Port: icatypes.HostPortID,
}

keeper.InitGenesis(suite.chainA.GetContext(), suite.chainA.GetSimApp().ICAHostKeeper, genesisState)
Expand Down Expand Up @@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() {
suite.Require().Equal(interchainAccAddr, genesisState.InterchainAccounts[0].AccountAddress)
suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.InterchainAccounts[0].PortId)

suite.Require().Equal(icatypes.PortID, genesisState.GetPort())
suite.Require().Equal(icatypes.HostPortID, genesisState.GetPort())

expParams := types.DefaultParams()
suite.Require().Equal(expParams, genesisState.GetParams())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func (k Keeper) OnChanOpenTry(
return "", sdkerrors.Wrapf(channeltypes.ErrInvalidChannelOrdering, "expected %s channel, got %s", channeltypes.ORDERED, order)
}

if portID != icatypes.PortID {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidHostPort, "expected %s, got %s", icatypes.PortID, portID)
if portID != icatypes.HostPortID {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidHostPort, "expected %s, got %s", icatypes.HostPortID, portID)
}

if !strings.HasPrefix(counterparty.PortId, icatypes.PortPrefix) {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "expected %s{owner-account-address}, got %s", icatypes.PortPrefix, counterparty.PortId)
if !strings.HasPrefix(counterparty.PortId, icatypes.ControllerPortPrefix) {
return "", sdkerrors.Wrapf(icatypes.ErrInvalidControllerPort, "expected %s{owner-account-address}, got %s", icatypes.ControllerPortPrefix, counterparty.PortId)
}

var metadata icatypes.Metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (suite *KeeperTestSuite) SetupTest() {

func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
path := ibctesting.NewPath(chainA, chainB)
path.EndpointA.ChannelConfig.PortID = icatypes.PortID
path.EndpointB.ChannelConfig.PortID = icatypes.PortID
path.EndpointA.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID
path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED
path.EndpointA.ChannelConfig.Version = TestVersion
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func (am AppModule) InitModule(ctx sdk.Context, controllerParams controllertypes
if am.hostKeeper != nil {
am.hostKeeper.SetParams(ctx, hostParams)

cap := am.hostKeeper.BindPort(ctx, types.PortID)
if err := am.hostKeeper.ClaimCapability(ctx, cap, ibchost.PortPath(types.PortID)); err != nil {
cap := am.hostKeeper.BindPort(ctx, types.HostPortID)
if err := am.hostKeeper.ClaimCapability(ctx, cap, ibchost.PortPath(types.HostPortID)); err != nil {
panic(fmt.Sprintf("could not claim port capability: %v", err))
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (suite *InterchainAccountsTestSuite) TestInitModule() {
expAllowMessages := []string{"sdk.Msg"}
hostParams.HostEnabled = true
hostParams.AllowMessages = expAllowMessages
suite.Require().False(app.IBCKeeper.PortKeeper.IsBound(ctx, types.PortID))
suite.Require().False(app.IBCKeeper.PortKeeper.IsBound(ctx, types.HostPortID))

testCases := []struct {
name string
Expand Down Expand Up @@ -123,7 +123,7 @@ func (suite *InterchainAccountsTestSuite) TestInitModule() {
suite.Require().True(hostParams.HostEnabled)
suite.Require().Equal(expAllowMessages, hostParams.AllowMessages)

suite.Require().True(app.IBCKeeper.PortKeeper.IsBound(ctx, types.PortID))
suite.Require().True(app.IBCKeeper.PortKeeper.IsBound(ctx, types.HostPortID))
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestDecodeStore(t *testing.T) {
Pairs: []kv.Pair{
{
Key: []byte(types.PortKeyPrefix),
Value: []byte(types.PortID),
Value: []byte(types.HostPortID),
},
{
Key: []byte(types.OwnerKeyPrefix),
Expand All @@ -44,7 +44,7 @@ func TestDecodeStore(t *testing.T) {
name string
expectedLog string
}{
{"PortID", fmt.Sprintf("Port A: %s\nPort B: %s", types.PortID, types.PortID)},
{"PortID", fmt.Sprintf("Port A: %s\nPort B: %s", types.HostPortID, types.HostPortID)},
{"Owner", fmt.Sprintf("Owner A: %s\nOwner B: %s", owner, owner)},
{"ActiveChannel", fmt.Sprintf("ActiveChannel A: %s\nActiveChannel B: %s", channelID, channelID)},
{"IsMiddlewareEnabled", fmt.Sprintf("IsMiddlewareEnabled A: %s\nIsMiddlewareEnabled B: %s", "false", "false")},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func RandomizedGenState(simState *module.SimulationState) {
hostGenesisState := genesistypes.HostGenesisState{
ActiveChannels: nil,
InterchainAccounts: nil,
Port: types.PortID,
Port: types.HostPortID,
Params: hostParams,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestRandomizedGenState(t *testing.T) {

require.True(t, icaGenesis.HostGenesisState.Params.HostEnabled)
require.Equal(t, []string{"*"}, icaGenesis.HostGenesisState.Params.AllowMessages)
require.Equal(t, types.PortID, icaGenesis.HostGenesisState.Port)
require.Equal(t, types.HostPortID, icaGenesis.HostGenesisState.Port)
require.Empty(t, icaGenesis.ControllerGenesisState.ActiveChannels)
require.Empty(t, icaGenesis.ControllerGenesisState.InterchainAccounts)
}
8 changes: 4 additions & 4 deletions modules/apps/27-interchain-accounts/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const (
// ModuleName defines the interchain accounts module name
ModuleName = "interchainaccounts"

// PortID is the default port id that the interchain accounts host submodule binds to
PortID = "icahost"
// HostPortID is the default port id that the interchain accounts host submodule binds to
HostPortID = "icahost"

// PortPrefix is the default port prefix that the interchain accounts controller submodule binds to
PortPrefix = "icacontroller-"
// ControllerPortPrefix is the default port prefix that the interchain accounts controller submodule binds to
ControllerPortPrefix = "icacontroller-"

// Version defines the current version for interchain accounts
Version = "ics27-1"
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/types/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ func NewControllerPortID(owner string) (string, error) {
return "", sdkerrors.Wrap(ErrInvalidAccountAddress, "owner address cannot be empty")
}

return fmt.Sprint(PortPrefix, owner), nil
return fmt.Sprint(ControllerPortPrefix, owner), nil
}
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/types/port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (suite *TypesTestSuite) TestNewControllerPortID() {
{
"success",
func() {},
fmt.Sprint(types.PortPrefix, TestOwnerAddress),
fmt.Sprint(types.ControllerPortPrefix, TestOwnerAddress),
true,
},
{
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/ica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewIncentivizedICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Pa
path.EndpointA.ChannelConfig.Version = feeICAVersion
path.EndpointB.ChannelConfig.Version = feeICAVersion
path.EndpointA.ChannelConfig.PortID = defaultPortID
path.EndpointB.ChannelConfig.PortID = icatypes.PortID
path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID

return path
}
Expand Down