Skip to content

Conversation

kocubinski
Copy link
Contributor

@kocubinski kocubinski commented Apr 21, 2023

Description

Removes double decoding in SigVerificationAnteHandler which was introduced in #15822.

Introduces an adapter on the wrapper struct in tx builder to return a x/tx/signing.TxData struct for interoperability with x/tx.

Background

The idealized version of the SDK doesn't need this because the entire transaction stack is powered by x/tx instead of x/auth/tx. However this would be a giant refactor and diff, and I think it's OK to depend on both modules for a period of transition time. I propose that shipping smaller, incremental changes, even if they include throw away code like this, will move the SDK to that idealized state faster than a large "all at once" refactor.


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)

@github-actions github-actions bot added the C:CLI label Apr 24, 2023
@github-actions github-actions bot added the C:Rosetta Issues and PR related to Rosetta label Apr 24, 2023
@kocubinski kocubinski marked this pull request as ready for review April 24, 2023 17:37
@kocubinski kocubinski requested a review from a team April 24, 2023 17:37
@github-prbot github-prbot requested review from a team, mark-rushakoff and samricotta and removed request for a team April 24, 2023 17:37
Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

This seems like a somewhat convoluted way to deal with this. What's the alternative?

@kocubinski
Copy link
Contributor Author

This seems like a somewhat convoluted way to deal with this. What's the alternative?

What about this seems convoluted? I don't have an alternative right now. Can you suggest one or make a specific criticism?

@aaronc
Copy link
Member

aaronc commented Apr 24, 2023

This seems like a somewhat convoluted way to deal with this. What's the alternative?

What about this seems convoluted? I don't have an alternative right now. Can you suggest one or make a specific criticism?

It's just the fact that we need to pull things out with an interface - a lot of indirection when there's really only one concrete type that can implement this interface. I guess it's okay for now. But does seem like evidence of the point I was making earlier today about ante handler/sdk.Tx convolution

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

utACK

@kocubinski
Copy link
Contributor Author

Thanks. I agree with the points you made about how things look now and I think we should consider them as we move towards x/tx away from x/auth/tx. I updated the PR with some more background.

// GetSignBytesAdapter returns the sign bytes for a given transaction and sign mode. It accepts the arguments expected
// for signing in x/auth/tx and converts them to the arguments expected by the txsigning.HandlerMap, then applies
// HandlerMap.GetSignBytes to get the sign bytes.
func GetSignBytesAdapter(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: changelog for public api break

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was introduced in https://github.com/cosmos/cosmos-sdk/pull/15822/files#diff-0100bcd16617d3f0e0a8eadcbdf052dfec465cb61c23daea4d201c95c2e20004 so still Unreleased, do we still need a Changelog entry?

Copy link
Member

Choose a reason for hiding this comment

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

No, just make sure we update any previous CHANGELOG entry referring to this

@kocubinski kocubinski added this pull request to the merge queue Apr 26, 2023
Merged via the queue into main with commit 00b78fa Apr 26, 2023
@kocubinski kocubinski deleted the kocubinski/adpatable-tx branch April 26, 2023 19:59
Comment on lines +70 to +83
txSignerInfos := make([]*txv1beta1.SignerInfo, len(authInfo.SignerInfos))
for i, signerInfo := range authInfo.SignerInfos {
modeInfo := &txv1beta1.ModeInfo{}
adaptModeInfo(signerInfo.ModeInfo, modeInfo)
txSignerInfo := &txv1beta1.SignerInfo{
PublicKey: &anypb.Any{
TypeUrl: signerInfo.PublicKey.TypeUrl,
Value: signerInfo.PublicKey.Value,
},
Sequence: signerInfo.Sequence,
ModeInfo: modeInfo,
}
txSignerInfos[i] = txSignerInfo
}

Choose a reason for hiding this comment

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

did we purposefully want to disable being able to submit a transaction without a public key here @tac0turtle or what this just a simple mistake?

Copy link
Contributor

Choose a reason for hiding this comment

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

quickly reading the pr as i dont have context for work done two years ago it seems its needed.

Choose a reason for hiding this comment

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

apologies and makes sense

the thing we ran into was that signerInfo.PublicKey will panic as there's a nil public key. Since this comment I've dug a bit deeper and I'm guessing this is just a simple mistake.

#19651

we can't change now since it would be consensus breaking, but its a very small optimization so I was more just curious if we were moving towards requiring the public key be included in each tx instead of using the state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:Rosetta Issues and PR related to Rosetta C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants