Skip to content

Commit

Permalink
chore: renaming API fns (cosmos#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
seantking authored Jan 27, 2022
1 parent 8dfbc9c commit 3e6464b
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 43 deletions.
12 changes: 6 additions & 6 deletions docs/app-modules/interchain-accounts/auth-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,21 @@ func (im IBCModule) OnRecvPacket(
}
```

## `InitInterchainAccount`
## `RegisterInterchainAccount`

The authentication module can begin registering interchain accounts by calling `InitInterchainAccount`:
The authentication module can begin registering interchain accounts by calling `RegisterInterchainAccount`:

```go
if err := keeper.icaControllerKeeper.InitInterchainAccount(ctx, connectionID, owner.String()); err != nil {
if err := keeper.icaControllerKeeper.RegisterInterchainAccount(ctx, connectionID, owner.String()); err != nil {
return err
}

return nil
```

## `TrySendTx`
## `SendTx`

The authentication module can attempt to send a packet by calling `TrySendTx`:
The authentication module can attempt to send a packet by calling `SendTx`:
```go

// Authenticate owner
Expand Down Expand Up @@ -204,7 +204,7 @@ packetData := icatypes.InterchainAccountPacketData{
timeoutTimestamp := obtainTimeoutTimestamp()

// Send the interchain accounts packet, returning the packet sequence
seq, err = keeper.icaControllerKeeper.TrySendTx(ctx, chanCap, portID, packetData, timeoutTimestamp)
seq, err = keeper.icaControllerKeeper.SendTx(ctx, chanCap, portID, packetData, timeoutTimestamp)
```

The data within an `InterchainAccountPacketData` must be serialized using a format supported by the host chain.
Expand Down
4 changes: 2 additions & 2 deletions docs/app-modules/interchain-accounts/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Learn about Interchain Accounts transaction execution {synopsis}

As described in [Authentication Modules](./auth-modules.md#trysendtx) transactions are executed using the interchain accounts controller API and require a `Base Application` as outlined in [ICS30 IBC Middleware](https://github.com/cosmos/ibc/tree/master/spec/app/ics-030-middleware) to facilitate authentication. The method of authentication remains unspecified to provide flexibility for the authentication module developer.

Transactions are executed via the ICS27 [`TrySendTx` API](./auth-modules.md#trysendtx). This must be invoked through an Interchain Accounts authentication module and follows the outlined path of execution below. Packet relaying semantics provided by the IBC core transport, authentication, and ordering (IBC/TAO) layer are omitted for brevity.
Transactions are executed via the ICS27 [`SendTx` API](./auth-modules.md#trysendtx). This must be invoked through an Interchain Accounts authentication module and follows the outlined path of execution below. Packet relaying semantics provided by the IBC core transport, authentication, and ordering (IBC/TAO) layer are omitted for brevity.

![send-tx-flow](../../assets/send-interchain-tx.png "Transaction Execution")

## Atomicity

As the Interchain Accounts module supports the execution of multiple transactions using the Cosmos SDK `Msg` interface, it provides the same atomicity guarantees as Cosmos SDK-based applications, leveraging the [`CacheMultiStore`](https://docs.cosmos.network/master/core/store.html#cachemultistore) architecture provided by the [`Context`](https://docs.cosmos.network/master/core/context.html) type.

This provides atomic execution of transactions when using Interchain Accounts, where state changes are only committed if all `Msg`s succeed.
This provides atomic execution of transactions when using Interchain Accounts, where state changes are only committed if all `Msg`s succeed.
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
return path
}

func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
portID, err := icatypes.NewControllerPortID(owner)
if err != nil {
return err
}

channelSequence := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextChannelSequence(endpoint.Chain.GetContext())

if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.InitInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.RegisterInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
return err
}

Expand All @@ -95,7 +95,7 @@ func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {

// SetupICAPath invokes the InterchainAccounts entrypoint and subsequent channel handshake handlers
func SetupICAPath(path *ibctesting.Path, owner string) error {
if err := InitInterchainAccount(path.EndpointA, owner); err != nil {
if err := RegisterInterchainAccount(path.EndpointA, owner); err != nil {
return err
}

Expand Down Expand Up @@ -216,11 +216,11 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() {
path := NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

// chainB also creates a controller port
err = InitInterchainAccount(path.EndpointB, TestOwnerAddress)
err = RegisterInterchainAccount(path.EndpointB, TestOwnerAddress)
suite.Require().NoError(err)

path.EndpointA.UpdateClient()
Expand Down Expand Up @@ -297,7 +297,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() {
path = NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

err = path.EndpointB.ChanOpenTry()
Expand Down Expand Up @@ -334,7 +334,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() {
path := NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

err = path.EndpointB.ChanOpenTry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
)

// InitInterchainAccount is the entry point to registering an interchain account.
// RegisterInterchainAccount is the entry point to registering an interchain account.
// It generates a new port identifier using the owner address, connection identifier,
// and counterparty connection identifier. It will bind to the port identifier and
// call 04-channel 'ChanOpenInit'. An error is returned if the port identifier is
// already in use. Gaining access to interchain accounts whose channels have closed
// cannot be done with this function. A regular MsgChanOpenInit must be used.
func (k Keeper) InitInterchainAccount(ctx sdk.Context, connectionID, owner string) error {
func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, connectionID, owner string) error {
portID, err := icatypes.NewControllerPortID(owner)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
ibctesting "github.com/cosmos/ibc-go/v3/testing"
)

func (suite *KeeperTestSuite) TestInitInterchainAccount() {
func (suite *KeeperTestSuite) TestRegisterInterchainAccount() {
var (
owner string
path *ibctesting.Path
Expand Down Expand Up @@ -70,7 +70,7 @@ func (suite *KeeperTestSuite) TestInitInterchainAccount() {

tc.malleate() // malleate mutates test data

err = suite.chainA.GetSimApp().ICAControllerKeeper.InitInterchainAccount(suite.chainA.GetContext(), path.EndpointA.ConnectionID, owner)
err = suite.chainA.GetSimApp().ICAControllerKeeper.RegisterInterchainAccount(suite.chainA.GetContext(), path.EndpointA.ConnectionID, owner)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenAck() {
path = NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

err = path.EndpointB.ChanOpenTry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {

// SetupICAPath invokes the InterchainAccounts entrypoint and subsequent channel handshake handlers
func SetupICAPath(path *ibctesting.Path, owner string) error {
if err := InitInterchainAccount(path.EndpointA, owner); err != nil {
if err := RegisterInterchainAccount(path.EndpointA, owner); err != nil {
return err
}

Expand All @@ -85,16 +85,16 @@ func SetupICAPath(path *ibctesting.Path, owner string) error {
return nil
}

// InitInterchainAccount is a helper function for starting the channel handshake
func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
// RegisterInterchainAccount is a helper function for starting the channel handshake
func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
portID, err := icatypes.NewControllerPortID(owner)
if err != nil {
return err
}

channelSequence := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextChannelSequence(endpoint.Chain.GetContext())

if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.InitInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.RegisterInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
)

// TrySendTx takes pre-built packet data containing messages to be executed on the host chain from an authentication module and attempts to send the packet.
// 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
// 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.
func (k Keeper) TrySendTx(ctx sdk.Context, chanCap *capabilitytypes.Capability, portID string, icaPacketData icatypes.InterchainAccountPacketData, timeoutTimestamp uint64) (uint64, error) {
func (k Keeper) SendTx(ctx sdk.Context, chanCap *capabilitytypes.Capability, portID string, icaPacketData icatypes.InterchainAccountPacketData, timeoutTimestamp uint64) (uint64, error) {
// Check for the active channel
activeChannelID, found := k.GetActiveChannelID(ctx, portID)
if !found {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
ibctesting "github.com/cosmos/ibc-go/v3/testing"
)

func (suite *KeeperTestSuite) TestTrySendTx() {
func (suite *KeeperTestSuite) TestSendTx() {
var (
path *ibctesting.Path
packetData icatypes.InterchainAccountPacketData
Expand Down Expand Up @@ -160,7 +160,7 @@ func (suite *KeeperTestSuite) TestTrySendTx() {

tc.malleate() // malleate mutates test data

_, err = suite.chainA.GetSimApp().ICAControllerKeeper.TrySendTx(suite.chainA.GetContext(), chanCap, path.EndpointA.ChannelConfig.PortID, packetData, timeoutTimestamp)
_, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), chanCap, path.EndpointA.ChannelConfig.PortID, packetData, timeoutTimestamp)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
16 changes: 8 additions & 8 deletions modules/apps/27-interchain-accounts/host/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {
return path
}

func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
portID, err := icatypes.NewControllerPortID(owner)
if err != nil {
return err
}

channelSequence := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextChannelSequence(endpoint.Chain.GetContext())

if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.InitInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.RegisterInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
return err
}

Expand All @@ -97,7 +97,7 @@ func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {

// SetupICAPath invokes the InterchainAccounts entrypoint and subsequent channel handshake handlers
func SetupICAPath(path *ibctesting.Path, owner string) error {
if err := InitInterchainAccount(path.EndpointA, owner); err != nil {
if err := RegisterInterchainAccount(path.EndpointA, owner); err != nil {
return err
}

Expand Down Expand Up @@ -179,7 +179,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() {
path = NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)
path.EndpointB.ChannelID = ibctesting.FirstChannelID

Expand Down Expand Up @@ -230,7 +230,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenAck() {
path := NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

err = path.EndpointB.ChanOpenTry()
Expand Down Expand Up @@ -294,7 +294,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() {
path := NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

err = path.EndpointB.ChanOpenTry()
Expand Down Expand Up @@ -641,7 +641,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose()
chanCap, ok := suite.chainA.GetSimApp().ScopedICAMockKeeper.GetCapability(path.EndpointA.Chain.GetContext(), host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID))
suite.Require().True(ok)

_, err = suite.chainA.GetSimApp().ICAControllerKeeper.TrySendTx(suite.chainA.GetContext(), chanCap, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0))
_, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), chanCap, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0))
suite.Require().NoError(err)
path.EndpointB.UpdateClient()

Expand Down Expand Up @@ -673,7 +673,7 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose()
chanCap, ok = suite.chainA.GetSimApp().ScopedICAMockKeeper.GetCapability(path.EndpointA.Chain.GetContext(), host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID))
suite.Require().True(ok)

_, err = suite.chainA.GetSimApp().ICAControllerKeeper.TrySendTx(suite.chainA.GetContext(), chanCap, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0))
_, err = suite.chainA.GetSimApp().ICAControllerKeeper.SendTx(suite.chainA.GetContext(), chanCap, path.EndpointA.ChannelConfig.PortID, icaPacketData, ^uint64(0))
suite.Require().NoError(err)
path.EndpointB.UpdateClient()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount() {
path := NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

// InitInterchainAccount
//RegisterInterchainAccount
err := SetupICAPath(path, TestOwnerAddress)
suite.Require().NoError(err)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() {
path = NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

// set the channel id on host
Expand Down Expand Up @@ -187,7 +187,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenConfirm() {
path = NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)

err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
err := RegisterInterchainAccount(path.EndpointA, TestOwnerAddress)
suite.Require().NoError(err)

err = path.EndpointB.ChanOpenTry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path {

// SetupICAPath invokes the InterchainAccounts entrypoint and subsequent channel handshake handlers
func SetupICAPath(path *ibctesting.Path, owner string) error {
if err := InitInterchainAccount(path.EndpointA, owner); err != nil {
if err := RegisterInterchainAccount(path.EndpointA, owner); err != nil {
return err
}

Expand All @@ -85,16 +85,16 @@ func SetupICAPath(path *ibctesting.Path, owner string) error {
return nil
}

// InitInterchainAccount is a helper function for starting the channel handshake
func InitInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
// RegisterInterchainAccount is a helper function for starting the channel handshake
func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error {
portID, err := icatypes.NewControllerPortID(owner)
if err != nil {
return err
}

channelSequence := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextChannelSequence(endpoint.Chain.GetContext())

if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.InitInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
if err := endpoint.Chain.GetSimApp().ICAControllerKeeper.RegisterInterchainAccount(endpoint.Chain.GetContext(), endpoint.ConnectionID, owner); err != nil {
return err
}

Expand Down

0 comments on commit 3e6464b

Please sign in to comment.