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(x/tx): add basic handler types + sign mode direct #14787

Merged
merged 13 commits into from
Feb 9, 2023

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Jan 25, 2023

Description

Closes: #XXXX

Work is currently proceeding on sign mode textual in the new x/tx module, we are starting to look into #10993, and autocli/hubl will soon want tx support. The intention of this PR is to introduce a bit more structure to x/tx in terms of how sign modes are added and also to introduce the very basic sign mode direct as a building block.


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)

@aaronc aaronc changed the title feat(x/tx): add basic sign mode direct support feat(x/tx): add basic handler types + sign mode direct Jan 25, 2023
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.

I prefer this SignModeHandler interface over the old one (with Modes and DefaultMode).

My only doubt about merging this now, is how long the 2 sign mode handlers will co-exist. Tx and signing stuff is already confusing, and this adds more complexity. For example, Evmos has their own handler, and I guess for hubl to work on their chain, they also need to add a new x/tx sign mode handler.

I would feel more comfortable if e.g. we did a spike to see if removing the old sign mode handler and replacing with this one right now would be viable (no unknown surprises). We would at least have the peace of mind that if we prioritized it, we could make the switch asap.

@@ -0,0 +1,28 @@
package std
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does std mean here? Could we put it in signing directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

std just means standard or default. default is a reserved keyword but I wanted to do that
We can't put it in signing because this depends on all the other sign modes and all sign modes depend on signing.

x/tx/signing/std/handler_map.go Show resolved Hide resolved
Comment on lines +20 to +22
if s.CoinMetadataQueryFn == nil {
return nil, fmt.Errorf("missing %T needed for SIGN_MODE_TEXTUAL", s.CoinMetadataQueryFn)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go in textual.NewSignModeHandler. I believe in tests there are a couple of textual.NewSignModeHandler(nil), which should simply be replaced by textual.SignModeHandler{}.

I can do that in a follow-up if you want to keep this PR focused on tx signing structure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you do that in a follow-up @AmauryM ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure

x/tx/signing/tx_data.go Outdated Show resolved Hide resolved
// BodyHasUnknownNonCriticals should be set to true if the transaction has been
// decoded and found to have unknown non-critical fields. This is only needed
// for amino JSON signing.
BodyHasUnknownNonCriticals bool
Copy link
Contributor

Choose a reason for hiding this comment

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

What should the amino handler do if this is true? Currently we just ignore right?

Copy link
Member Author

@aaronc aaronc Jan 26, 2023

Choose a reason for hiding this comment

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

I think we reject but we should check

// to specific value renderers for SIGN_MODE_TEXTUAL.
type Textual struct {
type SignModeHandler struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Renaming makes sense 👍

@aaronc
Copy link
Member Author

aaronc commented Jan 26, 2023

I think we should consider this tx semantic version 2 - it's not duplication it's the next version. We can deprecate and remove the existing sign mode handler stuff once we can support amino JSON with protoreflect which hopefully will be ready soon

@amaury1093
Copy link
Contributor

I understand this is the next version. I think it's better to do it in this order:

  1. protoreflect amino json encoder
  2. this pr
  3. remove old sign mode handler

rather than doing 2, 1, 3. Or more precisely, 2+3 should be done close to each other, this way the co-existence phase is as short as possible. BTW 1 can be shipped without 2+3, i.e. plugged into the old system, that's why I'm proposing to do it first.

If we decide that these 3 pieces will be merged atomically for the next release v048, then it's fine to merge this PR now.

@aaronc
Copy link
Member Author

aaronc commented Jan 26, 2023

The reason I'd prefer to do this sooner is because it gives a structure to implement the amino JSON support and to start migrating the other stuff. For instance, we can start migrating aux and ante handler stuff if we have this

@aaronc
Copy link
Member Author

aaronc commented Feb 6, 2023

Okay to move forward with this @AmauryM ? #14877 is moving forward and I think we can make pretty quick progress on other things

@amaury1093
Copy link
Contributor

Sure, let's fix the last couple of comments and merge this

@aaronc aaronc marked this pull request as ready for review February 6, 2023 16:31
@aaronc aaronc requested a review from a team as a code owner February 6, 2023 16:31
@aaronc
Copy link
Member Author

aaronc commented Feb 6, 2023

I did the one refactoring you suggested @AmauryM. There's another part that you said could be dealt with in a follow-up and then the one question about the SignModeOptions API.

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

x/tx/signing/std/handler_map.go Show resolved Hide resolved
@aaronc
Copy link
Member Author

aaronc commented Feb 8, 2023

This needs a review from someone in @cosmos/sdk-core-dev

@amaury1093 amaury1093 enabled auto-merge (squash) February 9, 2023 14:54
@amaury1093 amaury1093 merged commit 8bd9288 into main Feb 9, 2023
@amaury1093 amaury1093 deleted the aaronc/tx-direct branch February 9, 2023 15:01
tsenart pushed a commit to meka-dev/cosmos-sdk that referenced this pull request Apr 12, 2023
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants