Skip to content

Commit

Permalink
fix: allow empty public keys when setting signatures (backport #19106) (
Browse files Browse the repository at this point in the history
#19107)

Co-authored-by: Callum Waters <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2024
1 parent 3897926 commit 396be81
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Bug Fixes

* [#19106](https://github.com/cosmos/cosmos-sdk/pull/19106) Allow empty public keys when setting signatures. Public keys aren't needed for every transaction.

## [v0.50.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.3) - 2023-01-15

### Features
Expand Down
14 changes: 10 additions & 4 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,17 @@ func (w *wrapper) SetSignatures(signatures ...signing.SignatureV2) error {
rawSigs := make([][]byte, n)

for i, sig := range signatures {
var modeInfo *tx.ModeInfo
var (
modeInfo *tx.ModeInfo
pubKey *codectypes.Any
err error
)
modeInfo, rawSigs[i] = SignatureDataToModeInfoAndSig(sig.Data)
pubKey, err := codectypes.NewAnyWithValue(sig.PubKey)
if err != nil {
return err
if sig.PubKey != nil {
pubKey, err = codectypes.NewAnyWithValue(sig.PubKey)
if err != nil {
return err
}
}
signerInfos[i] = &tx.SignerInfo{
PublicKey: pubKey,
Expand Down
14 changes: 14 additions & 0 deletions x/auth/tx/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ func TestTxBuilder(t *testing.T) {
})
}

func TestSetSignaturesNoPublicKey(t *testing.T) {
_, pubkey, _ := testdata.KeyTestPubAddr()
txBuilder := newBuilder(nil)
sig2 := signing.SignatureV2{
Data: &signing.SingleSignatureData{
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
Signature: legacy.Cdc.MustMarshal(pubkey),
},
Sequence: 1,
}
err := txBuilder.SetSignatures(sig2)
require.NoError(t, err)
}

func TestBuilderValidateBasic(t *testing.T) {
// keys and addresses
_, pubKey1, addr1 := testdata.KeyTestPubAddr()
Expand Down

0 comments on commit 396be81

Please sign in to comment.