-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: nested multisig signatures using CLI #20438
Changes from all commits
da2293e
483812c
3d4e5ab
5602a59
9a76694
af33f6d
661eee7
d212cb8
3cab6e8
fb8506f
4ecdd81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,10 @@ If the --offline flag is on, the client will not reach out to an external node. | |
Account number or sequence number lookups are not performed so you must | ||
set these parameters manually. | ||
|
||
If the --skip-signature-verification flag is on, the command will not verify the | ||
signatures in the provided signature files. This is useful when the multisig | ||
account is a signer in a nested multisig scenario. | ||
|
||
The current multisig implementation defaults to amino-json sign mode. | ||
The SIGN_MODE_DIRECT sign mode is not supported.' | ||
`, | ||
|
@@ -57,6 +61,7 @@ The SIGN_MODE_DIRECT sign mode is not supported.' | |
Args: cobra.MinimumNArgs(3), | ||
} | ||
|
||
cmd.Flags().Bool(flagSkipSignatureVerification, false, "Skip signature verification") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add this to some docs somewhere? easy to get lost in the immense amount of code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added docs and changelog 💪 |
||
cmd.Flags().Bool(flagSigOnly, false, "Print only the generated signature, then exit") | ||
cmd.Flags().String(flags.FlagOutputDocument, "", "The document is written to the given file instead of STDOUT") | ||
flags.AddTxFlagsToCmd(cmd) | ||
|
@@ -109,6 +114,10 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { | |
return err | ||
} | ||
|
||
// avoid signature verification if the sender of the tx is different than | ||
// the multisig key (useful for nested multisigs). | ||
skipSigVerify, _ := cmd.Flags().GetBool(flagSkipSignatureVerification) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should describe this flag somewhere in the docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
|
||
multisigPub := pubKey.(*kmultisig.LegacyAminoPubKey) | ||
multisigSig := multisig.NewMultisig(len(multisigPub.PubKeys)) | ||
if !clientCtx.Offline { | ||
|
@@ -153,11 +162,13 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { | |
} | ||
txData := adaptableTx.GetSigningTxData() | ||
|
||
err = signing.VerifySignature(cmd.Context(), sig.PubKey, txSignerData, sig.Data, | ||
txCfg.SignModeHandler(), txData) | ||
if err != nil { | ||
addr, _ := sdk.AccAddressFromHexUnsafe(sig.PubKey.Address().String()) | ||
return fmt.Errorf("couldn't verify signature for address %s", addr) | ||
if !skipSigVerify { | ||
err = signing.VerifySignature(cmd.Context(), sig.PubKey, txSignerData, sig.Data, | ||
txCfg.SignModeHandler(), txData) | ||
if err != nil { | ||
addr, _ := sdk.AccAddressFromHexUnsafe(sig.PubKey.Address().String()) | ||
return fmt.Errorf("couldn't verify signature for address %s %w", addr, err) | ||
} | ||
} | ||
|
||
if err := multisig.AddSignatureV2(multisigSig, sig, multisigPub.GetPubKeys()); err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,10 @@ Since v0.13.0, x/tx follows Cosmos SDK semver: https://github.com/cosmos/cosmos- | |
|
||
## [Unreleased] | ||
|
||
### Improvements | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changelog is misplaced, this is a x/auth thing |
||
|
||
* [#20438](https://github.com/cosmos/cosmos-sdk/pull/20438) Add `--skip-signature-verification` flag to multisign command to allow nested multisigs. | ||
|
||
## [v0.13.3](https://github.com/cosmos/cosmos-sdk/releases/tag/x/tx/v0.13.3) - 2024-04-22 | ||
|
||
### Improvements | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test
TestBech32KeysOutputNestedMsig
appears comprehensive and correctly tests the output of a nested multisig key. However, consider adding more assertions to verify the structure of the nested multisig key in more detail, such as checking individual public keys within the nested structure.