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

feat: Add tx encode and decode endpoints #13789

Merged
merged 25 commits into from
Nov 15, 2022
Merged

Conversation

likhita-809
Copy link
Contributor

@likhita-809 likhita-809 commented Nov 8, 2022

Description

ref: #13085
ref: #10856


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Nov 8, 2022

Codecov Report

Merging #13789 (53da8b1) into main (ec27c53) will increase coverage by 0.18%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13789      +/-   ##
==========================================
+ Coverage   56.46%   56.64%   +0.18%     
==========================================
  Files         648      647       -1     
  Lines       56221    55289     -932     
==========================================
- Hits        31747    31321     -426     
+ Misses      21909    21414     -495     
+ Partials     2565     2554      -11     
Impacted Files Coverage Δ
x/auth/tx/service.go 0.00% <0.00%> (ø)
x/distribution/simulation/operations.go 80.64% <0.00%> (-9.68%) ⬇️
simapp/upgrades.go
simapp/genesis.go
simapp/genesis_account.go
simapp/simd/cmd/genaccounts.go
simapp/app.go
simapp/state.go
simapp/simd/cmd/testnet.go
simapp/test_helpers.go
... and 12 more

@kocubinski kocubinski marked this pull request as ready for review November 9, 2022 15:35
@kocubinski kocubinski requested a review from a team as a code owner November 9, 2022 15:35
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

We should document this only works with proto encoded txs, secondly is there a way we can add an amino way of encoding txs to the rest api? It could be something we attach to 1317 like before. Then we would support both tax types.

cc @ValarDragon for visibility on this

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Great work @likhita-809. We need a changelog here as well.

proto/cosmos/tx/v1beta1/service.proto Show resolved Hide resolved
tests/e2e/tx/service_test.go Outdated Show resolved Hide resolved
tests/e2e/tx/service_test.go Outdated Show resolved Hide resolved
tests/e2e/tx/service_test.go Outdated Show resolved Hide resolved
x/auth/tx/service.go Outdated Show resolved Hide resolved
x/auth/tx/service.go Outdated Show resolved Hide resolved
x/auth/tx/service.go Show resolved Hide resolved
@tac0turtle
Copy link
Member

Before the merge could we add amino encoding. this would help users quite a lot

@amaury1093
Copy link
Contributor

@tac0turtle amino in which direction? We cannot convert an Amino-encoded Tx into a proto Tx. We can convert a proto Tx to an amino-encoded Tx though. But is there a use case for the latter?

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

LGTM overall, I'm proposing an optimized way of doing encoding below

proto/cosmos/tx/v1beta1/service.proto Show resolved Hide resolved
x/auth/tx/service.go Outdated Show resolved Hide resolved
tests/e2e/tx/service_test.go Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

LGTM

@tac0turtle
Copy link
Member

@tac0turtle amino in which direction? We cannot convert an Amino-encoded Tx into a proto Tx. We can convert a proto Tx to an amino-encoded Tx though. But is there a use case for the latter?

can we expose an endpoint allowing users to encode amino txs? I would think the use case is multisigs and any sort of ledger support

@amaury1093
Copy link
Contributor

Just to be clear, you are asking to encode a proto Tx to amino Tx? This won't help any of the 2 use cases you mentioned:

ledger support

What ledger receives is a StdSignDoc. We can add an endpoint from unsigned proto Tx to StdSignDoc if that's useful, but it's not an amino-encoded tx.

multisig

Amino is used in multisigs to get the address. Not sure how a proto Tx to amino Tx encoder would help.

@tac0turtle
Copy link
Member

what Im thinking is not related to proto tx. if someone would like to encode a amino tx they cant use this endpoint, so can we offer an endpoint to help them?

@amaury1093
Copy link
Contributor

I'm still not understanding what you mean by "encode a amino tx". Maybe you can write the request and response types of the endpoint?

Also, how about we merge this PR, and discuss this additional endpoint in an issue?

@tac0turtle
Copy link
Member

tac0turtle commented Nov 11, 2022

#10856 (comment)

This issue asked about adding an endpoint to encode all versions, proto and amino. Right now this is only supporting proto.

@amaury1093
Copy link
Contributor

Ah ok, so it's an endpoint that encodes/decodes amino JSON <-> amino binary?

@julienrbrt julienrbrt added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Nov 11, 2022
@alexanderbez
Copy link
Contributor

Ah ok, so it's an endpoint that encodes/decodes amino JSON <-> amino binary?

Do we want to block this PR on that or create a new separate PR for those endpoints?

@tac0turtle
Copy link
Member

lets create a new pr for that, but lets leave the same issue opened

@tac0turtle tac0turtle enabled auto-merge (squash) November 14, 2022 16:48
@amaury1093
Copy link
Contributor

SGTM. @likhita-809 are you okay to work on that new PR too?

@likhita-809
Copy link
Contributor Author

SGTM. @likhita-809 are you okay to work on that new PR too?

yeah, sure

@tac0turtle tac0turtle merged commit bcff22a into main Nov 15, 2022
@tac0turtle tac0turtle deleted the likhita/add-tx/encode-endpoint branch November 15, 2022 04:55
mergify bot pushed a commit that referenced this pull request Nov 15, 2022
* add grpc endpoint for encoding proto tx's

(cherry picked from commit bcff22a)
tac0turtle pushed a commit that referenced this pull request Nov 15, 2022
* add grpc endpoint for encoding proto tx's

(cherry picked from commit bcff22a)

Co-authored-by: Likhita Polavarapu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants