From 4297067a5333425232a9842a0bc2eb413498f394 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Fri, 19 Jan 2024 09:23:44 +1300 Subject: [PATCH] fix: allow empty public keys when setting signatures (#19106) (cherry picked from commit e621eb6b1b9462af437e30929820aca2ea7958b8) # Conflicts: # x/auth/CHANGELOG.md # x/auth/tx/builder.go --- x/auth/CHANGELOG.md | 53 +++++++++++++++++++++++++++++++++++++++ x/auth/tx/builder.go | 14 ++++++++++- x/auth/tx/builder_test.go | 14 +++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 x/auth/CHANGELOG.md diff --git a/x/auth/CHANGELOG.md b/x/auth/CHANGELOG.md new file mode 100644 index 00000000000..2409c10e3b4 --- /dev/null +++ b/x/auth/CHANGELOG.md @@ -0,0 +1,53 @@ + + +# Changelog + +## [Unreleased] + +### Features + +* [#18641](https://github.com/cosmos/cosmos-sdk/pull/18641) Support the ability to broadcast unordered transactions per ADR-070. See UPGRADING.md for more details on integration. +* [#18281](https://github.com/cosmos/cosmos-sdk/pull/18281) Support broadcasting multiple transactions. +* (vesting) [#17810](https://github.com/cosmos/cosmos-sdk/pull/17810) Add the ability to specify a start time for continuous vesting accounts. +* (tx) [#18772](https://github.com/cosmos/cosmos-sdk/pull/18772) Remove misleading gas wanted from tx simulation failure log. + +### Improvements + +* [#18780](https://github.com/cosmos/cosmos-sdk/pull/18780) Move sig verification out of the for loop, into the authenticate method. + +### CLI Breaking Changes + +* (vesting) [#18100](https://github.com/cosmos/cosmos-sdk/pull/18100) `appd tx vesting create-vesting-account` takes an amount of coin as last argument instead of second. Coins are space separated. + +### API Breaking Changes + +* [#17985](https://github.com/cosmos/cosmos-sdk/pull/17985) Remove `StdTxConfig` + +### Consensus Breaking Changes + +* [#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. + +### 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. diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index ed84b6a23ed..96e75a3ef22 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -288,11 +288,23 @@ 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) +<<<<<<< HEAD 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 + } +>>>>>>> e621eb6b1 (fix: allow empty public keys when setting signatures (#19106)) } signerInfos[i] = &tx.SignerInfo{ PublicKey: any, diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index f7122dd3921..b4c1556e5c3 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -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()