Skip to content

Commit

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

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored and emidev98 committed Mar 21, 2024
1 parent dd769c9 commit 343c6ad
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (server) [#18920](https://github.com/cosmos/cosmos-sdk/pull/18920) fixes consensus failure while restart node with wrong `chainId` in genesis.
* [#19106](https://github.com/cosmos/cosmos-sdk/pull/19106) Allow empty public keys when setting signatures. Public keys aren't needed for every transaction.
* (server) [#18920](https://github.com/cosmos/cosmos-sdk/pull/18920) Fixes consensus failure while restart node with wrong `chainId` in genesis.

## [v0.47.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.7) - 2023-12-20

Expand Down
16 changes: 11 additions & 5 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,20 @@ 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)
any, 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: any,
PublicKey: pubKey,
ModeInfo: modeInfo,
Sequence: sig.Sequence,
}
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 @@ -123,6 +123,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 343c6ad

Please sign in to comment.