Skip to content

Commit 1663a59

Browse files
mergify[bot]cmwatersjulienrbrt
authored
fix: allow empty public keys when setting signatures (backport #19106) (#19108)
Co-authored-by: Callum Waters <cmwaters19@gmail.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
1 parent 6aed814 commit 1663a59

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
4545

4646
### Bug Fixes
4747

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

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

x/auth/tx/builder.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,20 @@ func (w *wrapper) SetSignatures(signatures ...signing.SignatureV2) error {
288288
rawSigs := make([][]byte, n)
289289

290290
for i, sig := range signatures {
291-
var modeInfo *tx.ModeInfo
291+
var (
292+
modeInfo *tx.ModeInfo
293+
pubKey *codectypes.Any
294+
err error
295+
)
292296
modeInfo, rawSigs[i] = SignatureDataToModeInfoAndSig(sig.Data)
293-
any, err := codectypes.NewAnyWithValue(sig.PubKey)
294-
if err != nil {
295-
return err
297+
if sig.PubKey != nil {
298+
pubKey, err = codectypes.NewAnyWithValue(sig.PubKey)
299+
if err != nil {
300+
return err
301+
}
296302
}
297303
signerInfos[i] = &tx.SignerInfo{
298-
PublicKey: any,
304+
PublicKey: pubKey,
299305
ModeInfo: modeInfo,
300306
Sequence: sig.Sequence,
301307
}

x/auth/tx/builder_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ func TestTxBuilder(t *testing.T) {
123123
})
124124
}
125125

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

0 commit comments

Comments
 (0)