Skip to content

Commit ab7efcb

Browse files
agouinmergify[bot]
authored andcommitted
MsgTransferResponse add sequence (#2377)
## Description Returns sequence from `sendTransfer`, and returns it with the `MsgTransferResponse`. This is not an API breaking change. Retrieving the sequence at the time of creating the transfer is necessary in the packet forward middleware for correlation with multihop packet flows. strangelove-ventures/packet-forward-middleware#33 strangelove-ventures/interchaintest#306 Closes #1969 --- - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [x] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [x] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) Existing test coverage exercises this new method due to the re-routing of `SendTransfer` through `SendPacketTransfer` - [x] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [x] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [x] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [x] Re-reviewed `Files changed` in the Github PR explorer - [x] Review `Codecov Report` in the comment section below once CI passes (cherry picked from commit 3363917) # Conflicts: # CHANGELOG.md # modules/apps/transfer/keeper/msg_server.go # modules/apps/transfer/keeper/relay.go # modules/apps/transfer/types/tx.pb.go
1 parent 96464aa commit ab7efcb

File tree

7 files changed

+233
-12
lines changed

7 files changed

+233
-12
lines changed

CHANGELOG.md

+103
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,109 @@ Ref: https://keepachangelog.com/en/1.0.0/
3838

3939
### Dependencies
4040

41+
<<<<<<< HEAD
42+
=======
43+
* [\#2458](https://github.com/cosmos/ibc-go/pull/2458) Bump Cosmos SDK to v0.46.2
44+
45+
### API Breaking
46+
47+
* (apps/29-fee) [\#2395](https://github.com/cosmos/ibc-go/pull/2395) Remove param space from ics29 NewKeeper function. The field was unused.
48+
* (apps/27-interchain-accounts) [\#2133](https://github.com/cosmos/ibc-go/pull/2133) Generates genesis protos in a separate directory to avoid circular import errors. The protobuf package name has changed for the genesis types.
49+
* (light-clients/tendermint)[\#1768](https://github.com/cosmos/ibc-go/pull/1768) Removed `AllowUpdateAfterExpiry`, `AllowUpdateAfterMisbehaviour` booleans as they are deprecated (see ADR026)
50+
* (06-solomachine) [\#1679](https://github.com/cosmos/ibc-go/pull/1679) Remove `types` sub-package from `06-solomachine` lightclient directory.
51+
* (07-tendermint) [\#1677](https://github.com/cosmos/ibc-go/pull/1677) Remove `types` sub-package from `07-tendermint` lightclient directory.
52+
* (06-solomachine) [\#1687](https://github.com/cosmos/ibc-go/pull/1687) Bump `06-solomachine` protobuf version from `v2` to `v3`.
53+
* (06-solomachine) [\#1687](https://github.com/cosmos/ibc-go/pull/1687) Removed `DataType` enum and associated message types from `06-solomachine`. `DataType` has been removed from `SignBytes` and `SignatureAndData` in favour of `path`.
54+
* (02-client) [\#598](https://github.com/cosmos/ibc-go/pull/598) The client state and consensus state return value has been removed from `VerifyUpgradeAndUpdateState`. Light client implementations must update the client state and consensus state after verifying a valid client upgrade.
55+
* (06-solomachine) [\#1100](https://github.com/cosmos/ibc-go/pull/1100) Remove `GetClientID` function from 06-solomachine `Misbehaviour` type.
56+
* (06-solomachine) [\#1100](https://github.com/cosmos/ibc-go/pull/1100) Deprecate `ClientId` field in 06-solomachine `Misbehaviour` type.
57+
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Remove `GetClientID` function from 07-tendermint `Misbehaviour` type.
58+
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Deprecate `ClientId` field in 07-tendermint `Misbehaviour` type.
59+
* (modules/core/exported) [\#1107](https://github.com/cosmos/ibc-go/pull/1107) Merging the `Header` and `Misbehaviour` interfaces into a single `ClientMessage` type.
60+
* (06-solomachine)[\#1906](https://github.com/cosmos/ibc-go/pull/1906/files) Removed `AllowUpdateAfterProposal` boolean as it has been deprecated (see 01_concepts of the solo machine spec for more details).
61+
* (07-tendermint) [\#1896](https://github.com/cosmos/ibc-go/pull/1896) Remove error return from `IterateConsensusStateAscending` in `07-tendermint`.
62+
* (apps/27-interchain-accounts) [\#2035](https://github.com/cosmos/ibc-go/pull/2035) Interchain accounts host and controller Keepers now expects a keeper which fulfills the expected `ScopedKeeper` interface for the capability keeper.
63+
* (transfer) [\#2034](https://github.com/cosmos/ibc-go/pull/2034) Transfer Keeper now expects a keeper which fulfills the expected `ScopedKeeper` interface for the capability keeper.
64+
* (05-port) [\#2025](https://github.com/cosmos/ibc-go/pull/2025) Port Keeper now expects a keeper which fulfills the expected `ScopedKeeper` interface for the capability keeper.
65+
* (04-channel) [\#2024](https://github.com/cosmos/ibc-go/pull/2024) Channel Keeper now expects a keeper which fulfills the expected `ScopedKeeper` interface for the capability keeper.
66+
* (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
67+
68+
### State Machine Breaking
69+
70+
* (transfer) [\#2377](https://github.com/cosmos/ibc-go/pull/2377) Adding `sequence` to `MsgTransferResponse`.
71+
72+
### Improvements
73+
74+
* (modules/light-clients/07-tendermint) [\#1713](https://github.com/cosmos/ibc-go/pull/1713) Allow client upgrade proposals to update `TrustingPeriod`. See ADR-026 for context.
75+
* (modules/core/02-client) [\#1188](https://github.com/cosmos/ibc-go/pull/1188/files) Routing `MsgSubmitMisbehaviour` to `UpdateClient` keeper function. Deprecating `SubmitMisbehaviour` endpoint.
76+
* (modules/core/02-client) [\#1208](https://github.com/cosmos/ibc-go/pull/1208) Replace `CheckHeaderAndUpdateState` usage in 02-client with calls to `VerifyClientMessage`, `CheckForMisbehaviour`, `UpdateStateOnMisbehaviour` and `UpdateState`.
77+
* (modules/light-clients/09-localhost) [\#1187](https://github.com/cosmos/ibc-go/pull/1187/) Removing localhost light client implementation as it is not functional. An upgrade handler is provided in `modules/migrations/v5` to prune `09-localhost` clients and consensus states from the store.
78+
* [\#1186](https://github.com/cosmos/ibc-go/pull/1186/files) Removing `GetRoot` function from ConsensusState interface in `02-client`. `GetRoot` is unused by core IBC.
79+
* (modules/core/02-client) [\#1196](https://github.com/cosmos/ibc-go/pull/1196) Adding VerifyClientMessage to ClientState interface.
80+
* (modules/core/02-client) [\#1198](https://github.com/cosmos/ibc-go/pull/1198) Adding UpdateStateOnMisbehaviour to ClientState interface.
81+
* (modules/core/02-client) [\#1170](https://github.com/cosmos/ibc-go/pull/1170) Updating `ClientUpdateProposal` to set client state in lightclient implementations `CheckSubstituteAndUpdateState` methods.
82+
* (modules/core/02-client) [\#1197](https://github.com/cosmos/ibc-go/pull/1197) Adding `CheckForMisbehaviour` to `ClientState` interface.
83+
* (modules/core/02-client) [\#1195](https://github.com/cosmos/ibc-go/pull/1210) Removing `CheckHeaderAndUpdateState` from `ClientState` interface & associated light client implementations.
84+
* (modules/core/02-client) [\#1189](https://github.com/cosmos/ibc-go/pull/1212) Removing `CheckMisbehaviourAndUpdateState` from `ClientState` interface & associated light client implementations.
85+
* (modules/core/exported) [\#1206](https://github.com/cosmos/ibc-go/pull/1206) Adding new method `UpdateState` to `ClientState` interface.
86+
* (modules/core/02-client) [\#1741](https://github.com/cosmos/ibc-go/pull/1741) Emitting a new `upgrade_chain` event upon setting upgrade consensus state.
87+
* (client) [\#724](https://github.com/cosmos/ibc-go/pull/724) `IsRevisionFormat` and `IsClientIDFormat` have been updated to disallow newlines before the dash used to separate the chainID and revision number, and the client type and client sequence.
88+
* (02-client/cli) [\#897](https://github.com/cosmos/ibc-go/pull/897) Remove `GetClientID()` from `Misbehaviour` interface. Submit client misbehaviour cli command requires an explicit client id now.
89+
* (06-solomachine) [\#1972](https://github.com/cosmos/ibc-go/pull/1972) Solo machine implementation of `ZeroCustomFields` fn now panics as the fn is only used for upgrades which solo machine does not support.
90+
* (apps/27-interchain-accounts) [\#2102](https://github.com/cosmos/ibc-go/pull/2102) ICS27 controller middleware now supports a nil underlying application. This allows chains to make use of interchain accounts with existing auth mechanisms such as x/group and x/gov.
91+
* (apps/27-interchain-accounts) [\#2146](https://github.com/cosmos/ibc-go/pull/2146) ICS27 controller now claims the channel capability passed via ibc core, and passes `nil` to the underlying app callback. The channel capability arg in `SendTx` is now ignored and looked up internally.
92+
* (apps/27-interchain-accounts) [\#2134](https://github.com/cosmos/ibc-go/pull/2134) Adding upgrade handler to ICS27 `controller` submodule for migration of channel capabilities. This upgrade handler migrates ownership of channel capabilities from the underlying application to the ICS27 `controller` submodule.
93+
* (apps/27-interchain-accounts) [\#2157](https://github.com/cosmos/ibc-go/pull/2157) Adding `IsMiddlewareEnabled` functionality to enforce calls to ICS27 msg server to *not* route to the underlying application.
94+
* (apps/27-interchain-accounts) [\#2177](https://github.com/cosmos/ibc-go/pull/2177) Adding `IsMiddlewareEnabled` flag to interchain accounts `ActiveChannel` genesis type.
95+
* (apps/27-interchain-accounts) [\#2140](https://github.com/cosmos/ibc-go/pull/2140) Adding migration handler to ICS27 `controller` submodule to assert ownership of channel capabilities and set middleware enabled flag for existing channels. The ICS27 module consensus version has been bumped from 1 to 2.
96+
* (core/04-channel) [\#2304](https://github.com/cosmos/ibc-go/pull/2304) Adding `GetAllChannelsWithPortPrefix` function which filters channels based on a provided port prefix.
97+
* (apps/27-interchain-accounts) [\#2290](https://github.com/cosmos/ibc-go/pull/2290) Changed `DefaultParams` function in `host` submodule to allow all messages by default. Defined a constant named `AllowAllHostMsgs` for `host` module to keep wildcard "*" string which allows all messages.
98+
* (apps/27-interchain-accounts) [\#2248](https://github.com/cosmos/ibc-go/pull/2248) Adding call to underlying app in `OnChanCloseConfirm` callback of the controller submodule and adding relevant unit tests.
99+
* (apps/27-interchain-accounts) [\#2251](https://github.com/cosmos/ibc-go/pull/2251) Adding `msgServer` struct to controller submodule that embeds the `Keeper` struct.
100+
* (light-clients/06-solomachine) Moving `verifyMisbehaviour` function from update.go to misbehaviour_handle.go.
101+
* (apps/27-interchain-accounts) [\#2297](https://github.com/cosmos/ibc-go/pull/2297) Adding cli command to generate ICS27 packet data.
102+
* (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.
103+
104+
### Features
105+
106+
* (apps/27-interchain-accounts) [\#2147](https://github.com/cosmos/ibc-go/pull/2147) Adding a `SubmitTx` gRPC endpoint for the ICS27 Controller module which allows owners of interchain accounts to submit transactions. This replaces the previously existing need for authentication modules to implement this standard functionality.
107+
* (testing/simapp) [\#2190](https://github.com/cosmos/ibc-go/pull/2190) Adding the new `x/group` cosmos-sdk module to simapp.
108+
109+
### Bug Fixes
110+
111+
* (light-clients/solomachine) [#1839](https://github.com/cosmos/ibc-go/issues/1839) Fixed usage of the new diversifier in validation of changing diversifiers for the solo machine. The current diversifier must sign over the new diversifier.
112+
* (light-clients/07-tendermint) [\#1674](https://github.com/cosmos/ibc-go/pull/1674) Submitted ClientState is zeroed out before checking the proof in order to prevent the proposal from containing information governance is not actually voting on.
113+
* (modules/core/02-client)[\#1676](https://github.com/cosmos/ibc-go/pull/1676) ClientState must be zeroed out for `UpgradeProposals` to pass validation. This prevents a proposal containing information governance is not actually voting on.
114+
* (modules/core/keeper) [\#2403](https://github.com/cosmos/ibc-go/pull/2403) Added a function in keeper to cater for blank pointers.
115+
116+
## [v4.1.0](https://github.com/cosmos/ibc-go/releases/tag/v4.1.0) - 2022-09-20
117+
118+
### Dependencies
119+
120+
* [\#2288](https://github.com/cosmos/ibc-go/pull/2288) Bump SDK version to v0.45.8 and Tendermint to v0.34.21.
121+
122+
### Features
123+
124+
* (apps/27-interchain-accounts) [\#2193](https://github.com/cosmos/ibc-go/pull/2193) Adding `InterchainAccount` gRPC query endpont to ICS27 `controller` submodule to allow users to retrieve registered interchain account addresses.
125+
126+
### Bug Fixes
127+
128+
* (27-interchain-accounts) [\#2308](https://github.com/cosmos/ibc-go/pull/2308) Nil checks have been added to ensure services are not registered for nil host or controller keepers.
129+
130+
## [v4.0.1](https://github.com/cosmos/ibc-go/releases/tag/v4.0.1) - 2022-09-15
131+
132+
### Dependencies
133+
134+
* [\#2287](https://github.com/cosmos/ibc-go/pull/2287) Bump SDK version to v0.45.8 and Tendermint to v0.34.21.
135+
136+
## [v4.0.0](https://github.com/cosmos/ibc-go/releases/tag/v4.0.0) - 2022-08-12
137+
138+
### Dependencies
139+
140+
* [\#1627](https://github.com/cosmos/ibc-go/pull/1627) Bump Go version to 1.18
141+
* [\#1905](https://github.com/cosmos/ibc-go/pull/1905) Bump SDK version to v0.45.7
142+
143+
>>>>>>> 3363917 (MsgTransferResponse add sequence (#2377))
41144
### API Breaking
42145

43146
### State Machine Breaking

docs/ibc/proto-docs.md

+5
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,11 @@ state as a commitment, acknowledgement, or a receipt.
897897
| `data` | [bytes](#bytes) | | embedded data that represents packet state. |
898898

899899

900+
| Field | Type | Label | Description |
901+
| ----- | ---- | ----- | ----------- |
902+
| `sequence` | [uint64](#uint64) | | sequence number of the packet on the channel. |
903+
904+
900905

901906

902907

modules/apps/transfer/keeper/msg_server.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.
1818
return nil, err
1919
}
2020

21+
<<<<<<< HEAD
2122
if err := k.SendTransfer(
23+
=======
24+
sequence, err := k.sendTransfer(
25+
>>>>>>> 3363917 (MsgTransferResponse add sequence (#2377))
2226
ctx, msg.SourcePort, msg.SourceChannel, msg.Token, sender, msg.Receiver, msg.TimeoutHeight, msg.TimeoutTimestamp,
23-
); err != nil {
27+
)
28+
if err != nil {
2429
return nil, err
2530
}
2631

@@ -38,5 +43,5 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.
3843
),
3944
})
4045

41-
return &types.MsgTransferResponse{}, nil
46+
return &types.MsgTransferResponse{Sequence: sequence}, nil
4247
}

modules/apps/transfer/keeper/msg_server_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() {
6161
res, err := suite.chainA.GetSimApp().TransferKeeper.Transfer(sdk.WrapSDKContext(suite.chainA.GetContext()), msg)
6262

6363
if tc.expPass {
64+
suite.Require().NotEqual(res.Sequence, uint64(0))
6465
suite.Require().NoError(err)
6566
suite.Require().NotNil(res)
6667
} else {

modules/apps/transfer/keeper/relay.go

+41-9
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,45 @@ func (k Keeper) SendTransfer(
6060
timeoutHeight clienttypes.Height,
6161
timeoutTimestamp uint64,
6262
) error {
63+
<<<<<<< HEAD
6364

65+
=======
66+
_, err := k.sendTransfer(
67+
ctx,
68+
sourcePort,
69+
sourceChannel,
70+
token,
71+
sender,
72+
receiver,
73+
timeoutHeight,
74+
timeoutTimestamp,
75+
)
76+
return err
77+
}
78+
79+
// sendTransfer handles transfer sending logic.
80+
func (k Keeper) sendTransfer(
81+
ctx sdk.Context,
82+
sourcePort,
83+
sourceChannel string,
84+
token sdk.Coin,
85+
sender sdk.AccAddress,
86+
receiver string,
87+
timeoutHeight clienttypes.Height,
88+
timeoutTimestamp uint64,
89+
) (uint64, error) {
90+
>>>>>>> 3363917 (MsgTransferResponse add sequence (#2377))
6491
if !k.GetSendEnabled(ctx) {
65-
return types.ErrSendDisabled
92+
return 0, types.ErrSendDisabled
6693
}
6794

6895
if k.bankKeeper.BlockedAddr(sender) {
69-
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to send funds", sender)
96+
return 0, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to send funds", sender)
7097
}
7198

7299
sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel)
73100
if !found {
74-
return sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel)
101+
return 0, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel)
75102
}
76103

77104
destinationPort := sourceChannelEnd.GetCounterparty().GetPortID()
@@ -80,7 +107,7 @@ func (k Keeper) SendTransfer(
80107
// get the next sequence
81108
sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel)
82109
if !found {
83-
return sdkerrors.Wrapf(
110+
return 0, sdkerrors.Wrapf(
84111
channeltypes.ErrSequenceSendNotFound,
85112
"source port: %s, source channel: %s", sourcePort, sourceChannel,
86113
)
@@ -90,7 +117,7 @@ func (k Keeper) SendTransfer(
90117
// See spec for this logic: https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#packet-relay
91118
channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePort, sourceChannel))
92119
if !ok {
93-
return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
120+
return 0, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
94121
}
95122

96123
// NOTE: denomination and hex hash correctness checked during msg.ValidateBasic
@@ -103,7 +130,7 @@ func (k Keeper) SendTransfer(
103130
if strings.HasPrefix(token.Denom, "ibc/") {
104131
fullDenomPath, err = k.DenomPathFromHash(ctx, token.Denom)
105132
if err != nil {
106-
return err
133+
return 0, err
107134
}
108135
}
109136

@@ -126,7 +153,7 @@ func (k Keeper) SendTransfer(
126153
if err := k.bankKeeper.SendCoins(
127154
ctx, sender, escrowAddress, sdk.NewCoins(token),
128155
); err != nil {
129-
return err
156+
return 0, err
130157
}
131158

132159
} else {
@@ -136,7 +163,7 @@ func (k Keeper) SendTransfer(
136163
if err := k.bankKeeper.SendCoinsFromAccountToModule(
137164
ctx, sender, types.ModuleName, sdk.NewCoins(token),
138165
); err != nil {
139-
return err
166+
return 0, err
140167
}
141168

142169
if err := k.bankKeeper.BurnCoins(
@@ -164,8 +191,13 @@ func (k Keeper) SendTransfer(
164191
timeoutTimestamp,
165192
)
166193

194+
<<<<<<< HEAD
167195
if err := k.channelKeeper.SendPacket(ctx, channelCap, packet); err != nil {
168196
return err
197+
=======
198+
if err := k.ics4Wrapper.SendPacket(ctx, channelCap, packet); err != nil {
199+
return 0, err
200+
>>>>>>> 3363917 (MsgTransferResponse add sequence (#2377))
169201
}
170202

171203
defer func() {
@@ -184,7 +216,7 @@ func (k Keeper) SendTransfer(
184216
)
185217
}()
186218

187-
return nil
219+
return sequence, nil
188220
}
189221

190222
// OnRecvPacket processes a cross chain fungible token transfer. If the

0 commit comments

Comments
 (0)