From 7fb654350e98f787947b8b91e19528199f0d4c67 Mon Sep 17 00:00:00 2001 From: bznein Date: Tue, 10 Sep 2024 16:04:29 +0100 Subject: [PATCH] chore: remove references to capabilities in comments, plus unused methods --- e2e/tests/transfer/base_test.go | 7 ------ .../controller/client/cli/tx.go | 3 +-- .../controller/keeper/account.go | 2 +- .../controller/keeper/handshake.go | 4 +--- .../controller/keeper/msg_server_test.go | 11 ---------- .../controller/keeper/relay.go | 3 +-- modules/apps/callbacks/testing/simapp/app.go | 10 +-------- modules/core/04-channel/keeper/timeout.go | 3 --- modules/core/04-channel/types/errors.go | 22 +++++++++---------- modules/core/05-port/types/utils.go | 17 -------------- modules/core/24-host/channel_keys.go | 13 +++++------ modules/core/24-host/port_keys.go | 7 ------ .../08-wasm/testing/simapp/app.go | 10 +-------- 13 files changed, 22 insertions(+), 90 deletions(-) delete mode 100644 modules/core/05-port/types/utils.go diff --git a/e2e/tests/transfer/base_test.go b/e2e/tests/transfer/base_test.go index 36d77991b6c..09f20ba1b90 100644 --- a/e2e/tests/transfer/base_test.go +++ b/e2e/tests/transfer/base_test.go @@ -78,13 +78,6 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { chainBAddress := chainBWallet.FormattedAddress() s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") - // TODO: https://github.com/cosmos/ibc-go/issues/6743 - // t.Run("ensure capability module BeginBlock is executed", func(t *testing.T) { - // // by restarting the chain we ensure that the capability module's BeginBlocker is executed. - // s.Require().NoError(chainA.(*cosmos.CosmosChain).StopAllNodes(ctx)) - // s.Require().NoError(chainA.(*cosmos.CosmosChain).StartAllNodes(ctx)) - // s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA), "failed to wait for blocks") - // }) t.Run("native IBC token transfer from chainA to chainB, sender is source of tokens", func(t *testing.T) { transferTxResp := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferCoins(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "", nil) diff --git a/modules/apps/27-interchain-accounts/controller/client/cli/tx.go b/modules/apps/27-interchain-accounts/controller/client/cli/tx.go index b3d9f7b5175..44c4fc6bf22 100644 --- a/modules/apps/27-interchain-accounts/controller/client/cli/tx.go +++ b/modules/apps/27-interchain-accounts/controller/client/cli/tx.go @@ -43,8 +43,7 @@ func newRegisterInterchainAccountCmd() *cobra.Command { connection id from the source chain. Connection identifier should be for the source chain and the interchain account will be created on the counterparty chain. Callers are expected to provide the appropriate application version string via {version} flag and the desired ordering -via the {ordering} flag. Generates a new port identifier using the provided owner string, binds to the port identifier and claims -the associated capability.`), +via the {ordering} flag. Generates a new port identifier using the provided owner string.`), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account.go b/modules/apps/27-interchain-accounts/controller/keeper/account.go index e2a7fe58f8b..ae41c756b4c 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account.go @@ -15,7 +15,7 @@ import ( ) // RegisterInterchainAccount is the entry point to registering an interchain account: -// - It generates a new port identifier using the provided owner string, binds to the port identifier and claims the associated capability. +// - It generates a new port identifier using the provided owner string. // - Callers are expected to provide the appropriate application version string. // - For example, this could be an ICS27 encoded metadata type or an ICS29 encoded metadata type with a nested application version. // - A new MsgChannelOpenInit is routed through the MsgServiceRouter, executing the OnOpenChanInit callback stack as configured. diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index b339997acb6..c7f6d77cf3d 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -15,9 +15,7 @@ import ( // OnChanOpenInit performs basic validation of channel initialization. // The counterparty port identifier must be the host chain representation as defined in the types package, // the channel version must be equal to the version in the types package, -// there must not be an active channel for the specified port identifier, -// and the interchain accounts module must be able to claim the channel -// capability. +// there must not be an active channel for the specified port identifier. func (k Keeper) OnChanOpenInit( ctx context.Context, order channeltypes.Order, diff --git a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go index 6f60a25f88b..6164fc513cb 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go @@ -143,17 +143,6 @@ func (suite *KeeperTestSuite) TestSubmitTx() { }, icatypes.ErrActiveChannelNotFound, }, - { - "failure - controller module does not own capability for this channel", func() { - msg.Owner = "invalid-owner" - portID, err := icatypes.NewControllerPortID(msg.Owner) - suite.Require().NoError(err) - - // set the active channel with the incorrect portID in order to reach the capability check - suite.chainA.GetSimApp().ICAControllerKeeper.SetActiveChannelID(suite.chainA.GetContext(), path.EndpointA.ConnectionID, portID, path.EndpointA.ChannelID) - }, - icatypes.ErrActiveChannelNotFound, - }, } for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay.go b/modules/apps/27-interchain-accounts/controller/keeper/relay.go index ac3ee2da5f2..7b072bdea2f 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay.go @@ -14,8 +14,7 @@ import ( ) // SendTx takes pre-built packet data containing messages to be executed on the host chain from an authentication module and attempts to send the packet. -// The packet sequence for the outgoing packet is returned as a result. -// If the base application has the capability to send on the provided portID. An appropriate +// The packet sequence for the outgoing packet is returned as a result. An appropriate // absolute timeoutTimestamp must be provided. If the packet is timed out, the channel will be closed. // In the case of channel closure, a new channel may be reopened to reconnect to the host chain. // diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index 85d485d21fc..d73bcbcb648 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -158,8 +158,7 @@ var ( ) // SimApp extends an ABCI application, but with most of its parameters exported. -// They are exported for convenience in creating helper functions, as object -// capabilities aren't needed for testing. +// They are exported for convenience in creating helper functions. type SimApp struct { *baseapp.BaseApp legacyAmino *codec.LegacyAmino @@ -510,9 +509,6 @@ func NewSimApp( // Add host, controller & ica auth modules to IBC router ibcRouter. - // the ICA Controller middleware needs to be explicitly added to the IBC Router because the - // ICA controller module owns the port capability for ICA. The ICA authentication module - // owns the channel capability. AddRoute(icacontrollertypes.SubModuleName, icaControllerStack). AddRoute(icahosttypes.SubModuleName, icaHostStack). AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerStack) // ica with mock auth module stack route to ica (top level of middleware stack) @@ -621,7 +617,6 @@ func NewSimApp( // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 - // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) app.ModuleManager.SetOrderBeginBlockers( minttypes.ModuleName, distrtypes.ModuleName, @@ -653,9 +648,6 @@ func NewSimApp( // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. // NOTE: The genutils module must also occur after auth so that it can access the params from auth. - // NOTE: Capability module must occur first so that it can initialize any capabilities - // so that other modules that want to create or claim capabilities afterwards in InitChain - // can do so safely. genesisModuleOrder := []string{ authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 98156a68147..5b548605700 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -34,9 +34,6 @@ func (k *Keeper) TimeoutPacket( ) } - // NOTE: TimeoutPacket is called by the AnteHandler which acts upon the packet.Route(), - // so the capability authentication can be omitted here - if packet.GetDestPort() != channel.Counterparty.PortId { return "", errorsmod.Wrapf( types.ErrInvalidPacket, diff --git a/modules/core/04-channel/types/errors.go b/modules/core/04-channel/types/errors.go index 4af002fe94a..629a074a24d 100644 --- a/modules/core/04-channel/types/errors.go +++ b/modules/core/04-channel/types/errors.go @@ -6,18 +6,16 @@ import ( // IBC channel sentinel errors var ( - ErrChannelExists = errorsmod.Register(SubModuleName, 2, "channel already exists") - ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") - ErrInvalidChannel = errorsmod.Register(SubModuleName, 4, "invalid channel") - ErrInvalidChannelState = errorsmod.Register(SubModuleName, 5, "invalid channel state") - ErrInvalidChannelOrdering = errorsmod.Register(SubModuleName, 6, "invalid channel ordering") - ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 7, "invalid counterparty channel") - ErrInvalidChannelCapability = errorsmod.Register(SubModuleName, 8, "invalid channel capability") - ErrChannelCapabilityNotFound = errorsmod.Register(SubModuleName, 9, "channel capability not found") - ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 10, "sequence send not found") - ErrSequenceReceiveNotFound = errorsmod.Register(SubModuleName, 11, "sequence receive not found") - ErrSequenceAckNotFound = errorsmod.Register(SubModuleName, 12, "sequence acknowledgement not found") - ErrInvalidPacket = errorsmod.Register(SubModuleName, 13, "invalid packet") + ErrChannelExists = errorsmod.Register(SubModuleName, 2, "channel already exists") + ErrChannelNotFound = errorsmod.Register(SubModuleName, 3, "channel not found") + ErrInvalidChannel = errorsmod.Register(SubModuleName, 4, "invalid channel") + ErrInvalidChannelState = errorsmod.Register(SubModuleName, 5, "invalid channel state") + ErrInvalidChannelOrdering = errorsmod.Register(SubModuleName, 6, "invalid channel ordering") + ErrInvalidCounterparty = errorsmod.Register(SubModuleName, 7, "invalid counterparty channel") + ErrSequenceSendNotFound = errorsmod.Register(SubModuleName, 10, "sequence send not found") + ErrSequenceReceiveNotFound = errorsmod.Register(SubModuleName, 11, "sequence receive not found") + ErrSequenceAckNotFound = errorsmod.Register(SubModuleName, 12, "sequence acknowledgement not found") + ErrInvalidPacket = errorsmod.Register(SubModuleName, 13, "invalid packet") // Deprecated: ErrPacketTimeout is deprecated and will be removed in a future release. // Please use ErrTimeoutElapsed instead. diff --git a/modules/core/05-port/types/utils.go b/modules/core/05-port/types/utils.go deleted file mode 100644 index f3c51d3bdf3..00000000000 --- a/modules/core/05-port/types/utils.go +++ /dev/null @@ -1,17 +0,0 @@ -package types - -import "fmt" - -// GetModuleOwner enforces that only IBC and the module bound to port can own the capability -// while future implementations may allow multiple modules to bind to a port, currently we -// only allow one module to be bound to a port at any given time -func GetModuleOwner(modules []string) string { - if len(modules) != 2 { - panic(fmt.Errorf("capability should only be owned by port or channel owner and ibc module, multiple owners currently not supported, owners: %v", modules)) - } - - if modules[0] == "ibc" { - return modules[1] - } - return modules[0] -} diff --git a/modules/core/24-host/channel_keys.go b/modules/core/24-host/channel_keys.go index 3d5dbb524b0..b988601a870 100644 --- a/modules/core/24-host/channel_keys.go +++ b/modules/core/24-host/channel_keys.go @@ -3,13 +3,12 @@ package host import "fmt" const ( - KeyChannelEndPrefix = "channelEnds" - KeyChannelPrefix = "channels" - KeyChannelUpgradePrefix = "channelUpgrades" - KeyUpgradePrefix = "upgrades" - KeyUpgradeErrorPrefix = "upgradeError" - KeyCounterpartyUpgrade = "counterpartyUpgrade" - KeyChannelCapabilityPrefix = "capabilities" + KeyChannelEndPrefix = "channelEnds" + KeyChannelPrefix = "channels" + KeyChannelUpgradePrefix = "channelUpgrades" + KeyUpgradePrefix = "upgrades" + KeyUpgradeErrorPrefix = "upgradeError" + KeyCounterpartyUpgrade = "counterpartyUpgrade" ) // ICS04 diff --git a/modules/core/24-host/port_keys.go b/modules/core/24-host/port_keys.go index 9bd720065c2..22293282d8a 100644 --- a/modules/core/24-host/port_keys.go +++ b/modules/core/24-host/port_keys.go @@ -1,15 +1,8 @@ package host -import "fmt" - const ( KeyPortPrefix = "ports" ) // ICS05 // The following paths are the keys to the store as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-005-port-allocation#store-paths - -// PortPath defines the path under which ports paths are stored on the capability module -func PortPath(portID string) string { - return fmt.Sprintf("%s/%s", KeyPortPrefix, portID) -} diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 1804f057d16..6c63e87e97e 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -166,8 +166,7 @@ var ( ) // SimApp extends an ABCI application, but with most of its parameters exported. -// They are exported for convenience in creating helper functions, as object -// capabilities aren't needed for testing. +// They are exported for convenience in creating helper functions. type SimApp struct { *baseapp.BaseApp legacyAmino *codec.LegacyAmino @@ -536,9 +535,6 @@ func NewSimApp( // Add host, controller & ica auth modules to IBC router ibcRouter. - // the ICA Controller middleware needs to be explicitly added to the IBC Router because the - // ICA controller module owns the port capability for ICA. The ICA authentication module - // owns the channel capability. AddRoute(icacontrollertypes.SubModuleName, icaControllerStack). AddRoute(icahosttypes.SubModuleName, icaHostStack). AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerStack) // ica with mock auth module stack route to ica (top level of middleware stack) @@ -650,7 +646,6 @@ func NewSimApp( // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 - // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) app.ModuleManager.SetOrderBeginBlockers( minttypes.ModuleName, distrtypes.ModuleName, @@ -684,9 +679,6 @@ func NewSimApp( // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. // NOTE: The genutils module must also occur after auth so that it can access the params from auth. - // NOTE: Capability module must occur first so that it can initialize any capabilities - // so that other modules that want to create or claim capabilities afterwards in InitChain - // can do so safely. genesisModuleOrder := []string{ authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,