Skip to content

Commit

Permalink
chore: remove references to capabilities in comments, plus unused met…
Browse files Browse the repository at this point in the history
…hods
  • Loading branch information
bznein committed Sep 10, 2024
1 parent 59ca335 commit 7fb6543
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 90 deletions.
7 changes: 0 additions & 7 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
10 changes: 1 addition & 9 deletions modules/apps/callbacks/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions modules/core/04-channel/keeper/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 10 additions & 12 deletions modules/core/04-channel/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 0 additions & 17 deletions modules/core/05-port/types/utils.go

This file was deleted.

13 changes: 6 additions & 7 deletions modules/core/24-host/channel_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions modules/core/24-host/port_keys.go
Original file line number Diff line number Diff line change
@@ -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)
}
10 changes: 1 addition & 9 deletions modules/light-clients/08-wasm/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7fb6543

Please sign in to comment.