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

Modify MsgSendTx fields based on audit #2280

Merged
merged 21 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
55390f4
chore: modify MsgSendTx fields based on audiit
chatton Sep 13, 2022
be2c7b3
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 16, 2022
42396d0
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 19, 2022
a869217
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 20, 2022
5cf2181
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 21, 2022
f700a84
chore: addressing PR feedback and updating cli flag to be relative pa…
chatton Sep 21, 2022
493176d
Merge branch 'cian/issue#2232-modify-msgsendtx-fields' of https://git…
chatton Sep 21, 2022
0d94865
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 21, 2022
db32911
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 21, 2022
626f347
chore: merge main
chatton Sep 22, 2022
f6a4686
chore: changing error from regular error to sdk typed error
chatton Sep 22, 2022
e8bacdf
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 22, 2022
55f2737
chore: merge main
chatton Sep 23, 2022
c9eed42
chore: updating testcase for relative timeout
chatton Sep 23, 2022
11e626f
chore: addressing PR feedback
chatton Sep 27, 2022
296cf80
chore: updating comment in proto file
chatton Sep 28, 2022
a900851
Merge branch 'main' into cian/issue#2232-modify-msgsendtx-fields
chatton Sep 28, 2022
a16e555
chrore: using sdk error instead of regular error
chatton Sep 28, 2022
f92a5de
Update modules/apps/27-interchain-accounts/controller/types/msgs.go
chatton Sep 28, 2022
0d3279f
chore: running go mod tidy
chatton Sep 28, 2022
f8dd87d
Merge branch 'cian/issue#2232-modify-msgsendtx-fields' of https://git…
chatton Sep 28, 2022
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
5 changes: 2 additions & 3 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,8 @@ MsgSendTx defines the payload for Msg/SendTx
| ----- | ---- | ----- | ----------- |
| `owner` | [string](#string) | | |
| `connection_id` | [string](#string) | | |
| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. |
| `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp in absolute nanoseconds since unix epoch. The timeout is disabled when set to 0. |
| `packet_data` | [ibc.applications.interchain_accounts.v1.InterchainAccountPacketData](#ibc.applications.interchain_accounts.v1.InterchainAccountPacketData) | | |
| `packet_data` | [ibc.applications.interchain_accounts.v1.InterchainAccountPacketData](#ibc.applications.interchain_accounts.v1.InterchainAccountPacketData) | | Timeout timestamp in absolute nanoseconds since unix epoch. The timeout is disabled when set to 0. |
| `relative_timeout` | [uint64](#uint64) | | |



Expand Down
17 changes: 3 additions & 14 deletions modules/apps/27-interchain-accounts/controller/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
)

const (
Expand Down Expand Up @@ -65,8 +64,7 @@ func newSendTxCmd() *cobra.Command {
Short: "Send an interchain account tx on the provided connection.",
Long: strings.TrimSpace(`Submits pre-built packet data containing messages to be executed on the host chain
and attempts to send the packet. Packet data is provided as json, file or string. An
appropriate relative timeoutTimestamp must be provided with flag {packet-timeout-timestamp}, along with a timeoutHeight
via {packet-timeout-timestamp}`),
appropriate relative timeoutTimestamp must be provided with flag {packet-timeout-timestamp}`),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
Expand Down Expand Up @@ -94,21 +92,12 @@ via {packet-timeout-timestamp}`),
}
}

timeoutHeightStr, err := cmd.Flags().GetString(flagPacketTimeoutHeight)
if err != nil {
return err
}
timeoutHeight, err := clienttypes.ParseHeight(timeoutHeightStr)
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}

timeoutTimestamp, err := cmd.Flags().GetUint64(flagPacketTimeoutTimestamp)
relativeTimeoutTimestamp, err := cmd.Flags().GetUint64(flagPacketTimeoutTimestamp)
if err != nil {
return err
}

msg := types.NewMsgSendTx(owner, connectionID, timeoutHeight, timeoutTimestamp, icaMsgData)
msg := types.NewMsgSendTx(owner, connectionID, relativeTimeoutTimestamp, icaMsgData)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s msgServer) SendTx(goCtx context.Context, msg *types.MsgSendTx) (*types.M
}

// explicitly passing nil as the argument is discarded as the channel capability is retrieved in SendTx.
seq, err := s.Keeper.SendTx(ctx, nil, msg.ConnectionId, portID, msg.PacketData, msg.TimeoutTimestamp)
seq, err := s.Keeper.SendTx(ctx, nil, msg.ConnectionId, portID, msg.PacketData, msg.RelativeTimeout)
Copy link
Contributor Author

@chatton chatton Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value will be passed correctly in #2257

if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/keeper"
"github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v5/modules/core/24-host"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
Expand Down Expand Up @@ -180,7 +179,7 @@ func (suite *KeeperTestSuite) TestSubmitTx() {
timeoutTimestamp := uint64(suite.chainA.GetContext().BlockTime().Add(time.Minute).UnixNano())
connectionID := path.EndpointA.ConnectionID

msg = types.NewMsgSendTx(owner, connectionID, clienttypes.ZeroHeight(), timeoutTimestamp, packetData)
msg = types.NewMsgSendTx(owner, connectionID, timeoutTimestamp, packetData)

tc.malleate() // malleate mutates test data

Expand Down
17 changes: 5 additions & 12 deletions modules/apps/27-interchain-accounts/controller/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
channelerrors "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v5/modules/core/24-host"
)

Expand Down Expand Up @@ -51,13 +49,12 @@ func (msg MsgRegisterInterchainAccount) GetSigners() []sdk.AccAddress {
}

// NewMsgSendTx creates a new instance of MsgSendTx
func NewMsgSendTx(owner, connectionID string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, packetData icatypes.InterchainAccountPacketData) *MsgSendTx {
func NewMsgSendTx(owner, connectionID string, relativeTimeoutTimestamp uint64, packetData icatypes.InterchainAccountPacketData) *MsgSendTx {
return &MsgSendTx{
ConnectionId: connectionID,
Owner: owner,
TimeoutHeight: timeoutHeight,
TimeoutTimestamp: timeoutTimestamp,
PacketData: packetData,
ConnectionId: connectionID,
Owner: owner,
RelativeTimeout: relativeTimeoutTimestamp,
PacketData: packetData,
}
}

Expand All @@ -75,10 +72,6 @@ func (msg MsgSendTx) ValidateBasic() error {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "failed to parse owner address: %s", msg.Owner)
}

if msg.TimeoutHeight.IsZero() && msg.TimeoutTimestamp == 0 {
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
return sdkerrors.Wrap(channelerrors.ErrInvalidTimeout, "msg timeout height and msg timeout timestamp cannot both be 0")
}

if err := msg.PacketData.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "invalid interchain account packet data")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
feetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
"github.com/cosmos/ibc-go/v5/testing/simapp"
)
Expand Down Expand Up @@ -133,11 +132,11 @@ func TestMsgSendTxValidateBasic(t *testing.T) {
false,
},
{
"timeout height and timestamp are both not set",
"relative timeout is not set",
func() {
msg.TimeoutTimestamp = 0
msg.RelativeTimeout = 0
},
false,
true,
},
{
"messages array is empty",
Expand Down Expand Up @@ -167,7 +166,6 @@ func TestMsgSendTxValidateBasic(t *testing.T) {
msg = types.NewMsgSendTx(
ibctesting.TestAccAddress,
ibctesting.FirstConnectionID,
clienttypes.ZeroHeight(),
100000,
packetData,
)
Expand Down Expand Up @@ -204,7 +202,6 @@ func TestMsgSendTxGetSigners(t *testing.T) {
msg := types.NewMsgSendTx(
ibctesting.TestAccAddress,
ibctesting.FirstConnectionID,
clienttypes.ZeroHeight(),
100000,
packetData,
)
Expand Down
152 changes: 50 additions & 102 deletions modules/apps/27-interchain-accounts/controller/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading