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

docs: ica tx encoding documentation added #4169

Merged
merged 15 commits into from
Jul 27, 2023

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented Jul 24, 2023

Description

Adds documentation for ica transaction encoding

closes: #4047

Commit Message / Changelog Entry

docs: ica tx encoding documentation added 

see the guidelines for commit messages. (view raw markdown for examples)


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 and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Nice work, @srdtrk. I just have some nits, otherwise looks good to me.

We should also update this line here:

Note the data field is a base64 encoded byte string as per the [proto3 JSON encoding specification](https://developers.google.com/protocol-buffers/docs/proto3#json).

(I just realised that the text is wrong and it mentions proto3 JSON 😓).

docs/apps/interchain-accounts/tx-encoding.md Show resolved Hide resolved
}
```

The encoding method for `CosmosTx` is determined during the channel handshake process. If the channel version [metadata's encoding field](https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/interchain_accounts/v1/metadata.proto#L22) is marked as `proto3`, `CosmosTx` undergoes protobuf encoding. Conversely, if the field is set to `proto3json`, pbjson encoding takes place, which generates a JSON representation of the protobuf message.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The encoding method for `CosmosTx` is determined during the channel handshake process. If the channel version [metadata's encoding field](https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/interchain_accounts/v1/metadata.proto#L22) is marked as `proto3`, `CosmosTx` undergoes protobuf encoding. Conversely, if the field is set to `proto3json`, pbjson encoding takes place, which generates a JSON representation of the protobuf message.
The encoding method for `CosmosTx` is determined during the channel handshake process. If the channel version [metadata's `encoding` field](https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/interchain_accounts/v1/metadata.proto#L22) is marked as `proto3`, `CosmosTx` undergoes protobuf encoding. Conversely, if the field is set to `proto3json`, pbjson encoding takes place, which generates a JSON representation of the protobuf message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I should look into the differences myself between all these packages, but is pbjson encoding here or protojson encoding?

Copy link
Member Author

Choose a reason for hiding this comment

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

The SDK uses jsonpb. So I'll use this term instead

docs/apps/interchain-accounts/tx-encoding.md Outdated Show resolved Hide resolved
docs/apps/interchain-accounts/tx-encoding.md Outdated Show resolved Hide resolved
docs/apps/interchain-accounts/tx-encoding.md Outdated Show resolved Hide resolved
Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

lgtm, only single observation that could in theory be fixed in a tiny separate PR

@@ -84,7 +84,7 @@ simd tx interchain-accounts host --help

##### `generate-packet-data`

The `generate-packet-data` command allows users to generate interchain accounts packet data for input message(s). The packet data can then be used with the controller submodule's [`send-tx` command](#send-tx).
The `generate-packet-data` command allows users to generate protobuf encoded interchain accounts packet data for input message(s). The packet data can then be used with the controller submodule's [`send-tx` command](#send-tx).
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth it to tweak the inline docs on this too, I don't see us mentioning the encoding there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added it to the cobra command. There is another issue for more general encoding in those commands #3974

Copy link
Member Author

Choose a reason for hiding this comment

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

I need more approvals now that I modified ica with inline docs haha

@codecov-commenter
Copy link

codecov-commenter commented Jul 27, 2023

Codecov Report

Merging #4169 (d42e4ef) into main (e827534) will not change coverage.
Report is 1 commits behind head on main.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4169   +/-   ##
=======================================
  Coverage   78.86%   78.86%           
=======================================
  Files         188      188           
  Lines       12994    12994           
=======================================
  Hits        10248    10248           
  Misses       2317     2317           
  Partials      429      429           
Files Changed Coverage Δ
.../apps/27-interchain-accounts/host/client/cli/tx.go 29.70% <0.00%> (ø)

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! See minor suggestions


## (Protobuf) JSON Encoding

Protojson encoding presents an alternative encoding technique for `CosmosTx`. It is selected if the channel handshake begins with the channel version metadata `encoding` field labeled as `proto3json`. In Golang, protojson encoding employs the `"github.com/cosmos/gogoproto/jsonpb"` package. Within Cosmos SDK, the `ProtoCodec` structure implements the `JSONCodec` interface, leveraging the `jsonpb` package. This method generates a JSON format as follows:
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 nice to reference the proto3json mapping in defining the expected encoding formats

Copy link
Member Author

Choose a reason for hiding this comment

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

done

}
```

The encoding method for `CosmosTx` is determined during the channel handshake process. If the channel version [metadata's `encoding` field](https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/interchain_accounts/v1/metadata.proto#L22) is marked as `proto3`, `CosmosTx` undergoes protobuf encoding. Conversely, if the field is set to `proto3json`, jsonpb encoding takes place, which generates a JSON representation of the protobuf message.
Copy link
Contributor

Choose a reason for hiding this comment

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

jsonpb needs a link

Copy link
Member Author

Choose a reason for hiding this comment

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

done


## (Protobuf) JSON Encoding

Protojson encoding presents an alternative encoding technique for `CosmosTx`. It is selected if the channel handshake begins with the channel version metadata `encoding` field labeled as `proto3json`. In Golang, protojson encoding employs the `"github.com/cosmos/gogoproto/jsonpb"` package. Within Cosmos SDK, the `ProtoCodec` structure implements the `JSONCodec` interface, leveraging the `jsonpb` package. This method generates a JSON format as follows:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Protojson encoding presents an alternative encoding technique for `CosmosTx`. It is selected if the channel handshake begins with the channel version metadata `encoding` field labeled as `proto3json`. In Golang, protojson encoding employs the `"github.com/cosmos/gogoproto/jsonpb"` package. Within Cosmos SDK, the `ProtoCodec` structure implements the `JSONCodec` interface, leveraging the `jsonpb` package. This method generates a JSON format as follows:
The proto3 JSON encoding presents an alternative encoding technique for `CosmosTx`. It is selected if the channel handshake begins with the channel version metadata `encoding` field labeled as `proto3json`. In Golang, the Proto3 canonical encoding in JSON is implemented by the `"github.com/cosmos/gogoproto/jsonpb"` package. Within Cosmos SDK, the `ProtoCodec` structure implements the `JSONCodec` interface, leveraging the `jsonpb` package. This method generates a JSON format as follows:

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@srdtrk srdtrk merged commit 585e56b into main Jul 27, 2023
53 checks passed
@srdtrk srdtrk deleted the serdar/issue#4047-ica-encoding-docs branch July 27, 2023 15:03
mergify bot pushed a commit that referenced this pull request Jul 27, 2023
* docs: added 'tx-encoding.md' file to docs

* feat: added tx encoding to frontend

* docs: improved tx encoding docs

* style(docs): moved tx encoding to bottom

* docs: improved tx encoding

* docs: improved ica tx encoding docs

* docs: in ica tx encoding, added small code blocks around some interface names

* docs: improved ica client docs + reordered tx encoding in sidebar

* docs(ica/cmd): updated docs of 'generate-packet-data'

* docs: improved ica tx encoding docs

(cherry picked from commit 585e56b)
crodriguezvega pushed a commit that referenced this pull request Jul 27, 2023
* docs: added 'tx-encoding.md' file to docs

* feat: added tx encoding to frontend

* docs: improved tx encoding docs

* style(docs): moved tx encoding to bottom

* docs: improved tx encoding

* docs: improved ica tx encoding docs

* docs: in ica tx encoding, added small code blocks around some interface names

* docs: improved ica client docs + reordered tx encoding in sidebar

* docs(ica/cmd): updated docs of 'generate-packet-data'

* docs: improved ica tx encoding docs

(cherry picked from commit 585e56b)

Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
27-interchain-accounts docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update documentation to explain ICA transactions can be serialised with protobuf or proto3 json
5 participants