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

fix: multisig for assigning consumer key, use json #916

Merged
merged 5 commits into from
May 4, 2023

Conversation

shaspitz
Copy link
Contributor

@shaspitz shaspitz commented May 3, 2023

Description

Fixes multisig errors seen by informal staking, by removing amino decoding in favor of passing json strings to the message handler and parsing what's needed there.

This PR was also designed to not change API at all. Ie. you still provide the consumer key as {"@type":"/cosmos.crypto.ed25519.PubKey","key":"ujY14AgopV907IYgPAk/5x8c9267S4fQf89nyeCPTes="} for example

Error previously seen:

panic: unable to resolve type URL /cosmos.crypto.ed25519.PubKey

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/codec.(*ProtoCodec).MustMarshalJSON(...)
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/codec/proto_codec.go:147
github.com/cosmos/interchain-security/x/ccv/provider/types.MsgAssignConsumerKey.GetSignBytes({{0xc000517618, 0x8}, {0xc00129e7c0, 0x34}, 0xc0001ab800})
	github.com/cosmos/interchain-security@v1.1.0/x/ccv/provider/types/msg.go:62 +0xd8
github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx.StdSignBytes({0x7ffc8fcc927c, 0x8}, 0x175, 0x0, 0x0, {{0x362ba70?, 0x1f?, 0xc00159e4d0?}, 0x45a5bc?}, {0xc00154b5f0, ...}, ...)
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/x/auth/legacy/legacytx/stdsign.go:61 +0x284
github.com/cosmos/cosmos-sdk/x/auth/tx.signModeLegacyAminoJSONHandler.GetSignBytes({}, 0x45a130?, {{0x7ffc8fcc927c?, 0xc00159e5d8?}, 0x414045?, 0xc00159e598?}, {0x2751518?, 0xc0001093c0?})
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/x/auth/tx/legacy_amino_json.go:49 +0x1a7
github.com/cosmos/cosmos-sdk/x/auth/signing.SignModeHandlerMap.GetSignBytes({0x1, {0xc0010693f8, 0x2, 0x2}, 0xc0010a81b0}, 0x27647f0?, {{0x7ffc8fcc927c, 0x8}, 0x175, 0x0}, ...)
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/x/auth/signing/handler_map.go:59 +0xa2
github.com/cosmos/cosmos-sdk/client/tx.Sign({{0x2776450, 0xc000521740}, {0x276f2c0, 0xc000e4b0c0}, {0x2766638, 0x362ba70}, 0x175, 0x0, 0x30d40, 0x0, ...}, ...)
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/client/tx/tx.go:388 +0x389
github.com/cosmos/cosmos-sdk/x/auth/client.SignTxWithSignerAddress({{0x2776450, 0xc000521740}, {0x276f2c0, 0xc000e4b0c0}, {0x2766638, 0x362ba70}, 0x175, 0x0, 0x30d40, 0x0, ...}, ...)
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/x/auth/client/tx.go:92 +0x2a6
github.com/cosmos/cosmos-sdk/x/auth/client/cli.makeSignCmd.func1(0xc001144c00?, {0xc000e495f0, 0x1, 0x9?})
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/x/auth/client/cli/tx_sign.go:246 +0x745
github.com/spf13/cobra.(*Command).execute(0xc001144c00, {0xc000e49560, 0x9, 0x9})
	github.com/spf13/cobra@v1.6.1/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc000f78c00)
	github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.6.1/command.go:968
github.com/spf13/cobra.(*Command).ExecuteContext(...)
	github.com/spf13/cobra@v1.6.1/command.go:961
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x0?, {0xc000dd55a8, 0x11})
	github.com/cosmos/cosmos-sdk@v0.45.13-ics/server/cmd/execute.go:36 +0x1eb
main.main()
	github.com/cosmos/gaia/v9/cmd/gaiad/main.go:16 +0x2c

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 SDK 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

@shaspitz shaspitz marked this pull request as ready for review May 4, 2023 14:58

// For now, only accept ed25519.
// TODO: decide what types should be supported.
if pkType != "/cosmos.crypto.ed25519.PubKey" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't all user account keys ed25519 in cosmos-sdk?

@@ -44,12 +43,8 @@ func NewAssignConsumerKeyCmd() *cobra.Command {
WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)

providerValAddr := clientCtx.GetFromAddress()
var consumerPubKey cryptotypes.PubKey
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The entire point of this PR is removing this code. We could unmarshal into a concrete type, but that'd change API

Copy link
Contributor

@MSalopek MSalopek left a comment

Choose a reason for hiding this comment

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

Tested locally, works!

Approval!

Copy link
Contributor

@jtremback jtremback left a comment

Choose a reason for hiding this comment

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

LGTM

@jtremback jtremback merged commit 504811d into main May 4, 2023
@jtremback jtremback deleted the shawn/fix-multisig-json branch May 4, 2023 20:55
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.

3 participants