Skip to content

Commit 21dc6f2

Browse files
cmwatersrelyt29
authored andcommitted
fix: allow empty public keys when setting signatures (cosmos#19106)
1 parent 993cdf6 commit 21dc6f2

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

x/auth/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ Ref: https://keepachangelog.com/en/1.0.0/
4949
* [#18817](https://github.com/cosmos/cosmos-sdk/pull/18817) SigVerification, GasConsumption, IncreaseSequence ante decorators have all been joined into one SigVerification decorator. Gas consumption during TX validation flow has reduced.
5050

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

x/auth/tx/builder.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,17 @@ func (w *wrapper) SetSignatures(signatures ...signing.SignatureV2) error {
352352
rawSigs := make([][]byte, n)
353353

354354
for i, sig := range signatures {
355-
var modeInfo *tx.ModeInfo
355+
var (
356+
modeInfo *tx.ModeInfo
357+
pubKey *codectypes.Any
358+
err error
359+
)
356360
modeInfo, rawSigs[i] = SignatureDataToModeInfoAndSig(sig.Data)
357-
pubKey, err := codectypes.NewAnyWithValue(sig.PubKey)
358-
if err != nil {
359-
return err
361+
if sig.PubKey != nil {
362+
pubKey, err = codectypes.NewAnyWithValue(sig.PubKey)
363+
if err != nil {
364+
return err
365+
}
360366
}
361367
signerInfos[i] = &tx.SignerInfo{
362368
PublicKey: pubKey,

x/auth/tx/builder_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ func TestTxBuilder(t *testing.T) {
127127
})
128128
}
129129

130+
func TestSetSignaturesNoPublicKey(t *testing.T) {
131+
_, pubkey, _ := testdata.KeyTestPubAddr()
132+
txBuilder := newBuilder(nil)
133+
sig2 := signing.SignatureV2{
134+
Data: &signing.SingleSignatureData{
135+
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
136+
Signature: legacy.Cdc.MustMarshal(pubkey),
137+
},
138+
Sequence: 1,
139+
}
140+
err := txBuilder.SetSignatures(sig2)
141+
require.NoError(t, err)
142+
}
143+
130144
func TestBuilderValidateBasic(t *testing.T) {
131145
// keys and addresses
132146
_, pubKey1, addr1 := testdata.KeyTestPubAddr()

0 commit comments

Comments
 (0)