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

chore: adding basic Msg service and SubmitTx rpc boilerplate #2086

Merged
merged 28 commits into from
Aug 30, 2022

Conversation

charleenfei
Copy link
Contributor

@charleenfei charleenfei commented Aug 23, 2022

Description

Please review #2133 first!

NOTE: i updated the tx name to be SubmitTx in order to avoid name collision with the current SendTx method in the ICA controller keeper. Open to other suggestions!

closes: #2052


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@charleenfei charleenfei changed the title chore: adding basic Msg service and SubmitTx rpc boilerplate #2051 chore: adding basic Msg service and SubmitTx rpc boilerplate Aug 24, 2022
| ----- | ---- | ----- | ----------- |
| `owner` | [string](#string) | | |
| `connection_id` | [string](#string) | | |
| `timeout` | [string](#string) | | |
Copy link
Contributor Author

@charleenfei charleenfei Aug 24, 2022

Choose a reason for hiding this comment

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

should timeout be Height or uint64 Timestamp here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should support both. Should be similar to MsgTransfer

Copy link
Member

Choose a reason for hiding this comment

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

I agree, I think we should support both going forward but the current implementation uses clienttypes.ZeroHeight.
I think we can only support the timeout height via the new execution path - i.e. existing auth modules using the SendTx go API directly won't be able to specify a height, right?

For SubmitTx we can use uint64 for timeout_timestamp and ibc.core.client.v1.Height for timeout_height like MsgTransfer as @colin-axner suggests! :)

string owner = 1;
string connection_id = 2 [(gogoproto.moretags) = "yaml:\"connection_id\""];
string timeout = 3;
repeated google.protobuf.Any msg = 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

@damiannolan what's the reason for using Anys here? Shouldn't we just be taking in the ics27 packet data

Copy link
Member

Choose a reason for hiding this comment

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

I think if an end user wants to use x/group or x/gov they can't really construct the packet data type as it expects a proto encoded []byte of message data. If we use Any it can be defined in JSON and submitted for proposal execution. Essentially like it's done here. We would have a proto-JSON encoded MsgSubmitTx which has a nested array of ICA messages to be executed on the host.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay so this is an any which is decoded into packet data?

We cannot assume the counterparty uses any's for message delivery (this is SDK behaviour). I also suspect folks will want to make use of the memo field (it allows for a short term hack of enabling top level middleware for application handling, ie memo field: "swap:lp" would indicate, swap tokens then lp)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be problematic to use Any to represent the messages delivered to the counterparty chain. These messages would need to be registered on the controller chain since the SDK will verify the Any URL is registered on the interface registry. Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

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

Okay so this is an any which is decoded into packet data?

I was thinking that this would be an array Anys which would be encoded into packet data using SerializeCosmosTx.

These messages would need to be registered on the controller chain since the SDK will verify the Any URL is registered on the interface registry. Does that make sense?

This does make a lot of sense! It's a good point, do you know where in the SDK this would fail if for example you tried to provide an osmosis specific message type (swap) via a cosmos-hub(controller) group proposal?
I think this may be kind of problematic from a ux perspective...

Copy link
Contributor

@colin-axner colin-axner Aug 24, 2022

Choose a reason for hiding this comment

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

I believe the issue occurs because UnpackAny will call UnpackInterfaces which will try to unpackany the nested Any, but this will fail to resolve. This is why the migration code has the mock solo machine client state/consensus state

@colin-axner
Copy link
Contributor

NOTE: i updated the tx name to be SubmitTx in order to avoid name collision with the SendTx method in the transfer app. Open to other suggestions!

I like SubmitTx. As a side note, I don't think the name would conflict with ics20 since a user would submit a MsgTransfer and calling the ics20 function directly (it really should be private) would be transferkeeper.SendTx() compared to icacontrollerkeeper.SendTx()

@charleenfei
Copy link
Contributor Author

charleenfei commented Aug 24, 2022

ah sorry, i misread the error, there is already a SendTx in the controller keeper. If i understand this function correctly, this functionality is actually what should now be triggered by the new SubmitTx msg_server handler right? except we would take the Msg and parse the messages from that rather than the InterchainAccountPacketData

@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2022

Codecov Report

Merging #2086 (864cbfb) into main (f8f879b) will decrease coverage by 0.12%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2086      +/-   ##
==========================================
- Coverage   79.40%   79.28%   -0.13%     
==========================================
  Files         170      170              
  Lines       11837    11855      +18     
==========================================
  Hits         9399     9399              
- Misses       2022     2040      +18     
  Partials      416      416              
Impacted Files Coverage Δ
...nterchain-accounts/controller/keeper/msg_server.go 83.33% <0.00%> (-16.67%) ⬇️
...s/27-interchain-accounts/controller/types/codec.go 0.00% <0.00%> (ø)
...ps/27-interchain-accounts/controller/types/msgs.go 58.82% <0.00%> (-32.09%) ⬇️

@charleenfei charleenfei force-pushed the charly/2052_sendtx_rpc_msgs branch from 5a65a82 to aa6ce16 Compare August 24, 2022 13:58
@colin-axner
Copy link
Contributor

ah sorry, i misread the error, there is already a SendTx in the controller keeper. If i understand this function correctly, this functionality is actually what should now be triggered by the new SubmitTx msg_server handler right? except we would take the Msg and parse the messages from that rather than the InterchainAccountPacketData

Ah yea, those names will collide as two functions for the same keeper. We want to leave the old function for backwards compatibility purposes. The new msg handler should perform the same functionality as the existing function but take in the arguments in form of MsgSubmitTx

@charleenfei charleenfei force-pushed the charly/2052_sendtx_rpc_msgs branch from bf8e21d to fee8080 Compare August 26, 2022 13:37
Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

It's ok to have owner be an address on the controller chain. It also needs to be a signer, so that user-controlled ICAs are secure

func NewMsgSubmitTx(connectionID, owner string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, msgs []*icatypes.InterchainAccountPacketData) *MsgSubmitTx {
return &MsgSubmitTx{
ConnectionId: connectionID,
Owner: owner,
Copy link
Member

Choose a reason for hiding this comment

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

This should be an AccAddress I believe because it is on the controller chain, we know it should be a valid address

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it better to cast it in the proto or check if its a valid addr in ValidateBasic?


// GetSigners implements sdk.Msg
func (msg MsgSubmitTx) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return []sdk.AccAddress{}
return []sdk.AccAddress{owner}

This needs to be authenticated by owner signature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea i would fill out this function in the next PR along with validate basic :)

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string owner = 1;
Copy link
Member

Choose a reason for hiding this comment

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

This can also be cast to sdk.Address

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it better to cast it in the proto or check if its a valid addr in ValidateBasic?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is fine to leave as is, primarily because the owner is also the signer and all of our Msg types have the signer as an uncasted string (albeit I'm not sure why)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense just to apply the casting change to all our messages at once. The SDK does some different things nowadays anyways

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked into this some more. Looks like the SDK intentionally chose to go with a string in 2020 (during amino -> proto migration). Might have been some concern with the gRPC gateway, nevertheless there's talk about removing reliance on the global bech32 config and moving it to be a param of the auth keeper, so you'd need access to the auth keeper to get the acc address (they want to change get signers to return a string instead of an address)

Lets keep with what we have. It'll be easier to deal with everything uniformly

@AdityaSripal
Copy link
Member

Realize my requests are addressed in #2135 . Ignore the above!

@AdityaSripal AdityaSripal self-requested a review August 29, 2022 13:32
@charleenfei charleenfei force-pushed the charly/2052_sendtx_rpc_msgs branch from 788b4b4 to a9e44a1 Compare August 29, 2022 14:59
Copy link
Contributor

@seantking seantking left a comment

Choose a reason for hiding this comment

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

🚀 🚀

// Timeout timestamp in absolute nanoseconds since unix epoch.
// The timeout is disabled when set to 0.
uint64 timeout_timestamp = 4 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
ibc.applications.interchain_accounts.v1.InterchainAccountPacketData packet_data = 5;
Copy link
Member

Choose a reason for hiding this comment

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

We should add yaml tags and I think we can probs make this a value type instead of a pointer:
(gogoproto.nullable) = false

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

LGTM, left minor suggestions


string owner = 1;
string connection_id = 2 [(gogoproto.moretags) = "yaml:\"connection_id\""];
// Timeout height relative to the current block height.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should be taking in a relative height here (especially since the timestamp is labeled as absolute). I think I'd prefer external UX to just figure out the correct timeout height

Is there a specific use case we can think of which needs a relative timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just grabbed the timeout parameters from the transfer app -- i guess the relative height might make sense if you want a time limit on the action relative to when you've submitted the tx (ie: you want to trigger a swap only within the next 24 hours)

@colin-axner colin-axner dismissed AdityaSripal’s stale review August 30, 2022 10:01

see followup discussion

@charleenfei charleenfei enabled auto-merge (squash) August 30, 2022 10:10
@charleenfei charleenfei merged commit f263794 into main Aug 30, 2022
@charleenfei charleenfei deleted the charly/2052_sendtx_rpc_msgs branch August 30, 2022 10:40
mergify bot pushed a commit that referenced this pull request Aug 30, 2022
* add protos/rpcs, boilerplate

(cherry picked from commit f263794)
colin-axner pushed a commit that referenced this pull request Aug 31, 2022
…2142)

* add protos/rpcs, boilerplate

(cherry picked from commit f263794)

Co-authored-by: Charly <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SendTx rpc and proto message definitions
7 participants