From c2933abebcf87ece6cf071c67045cc038083dc10 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Fri, 19 Jan 2024 09:23:44 +1300 Subject: [PATCH 1/2] fix: allow empty public keys when setting signatures (#19106) (cherry picked from commit e621eb6b1b9462af437e30929820aca2ea7958b8) # Conflicts: # x/auth/CHANGELOG.md --- x/auth/CHANGELOG.md | 53 +++++++++++++++++++++++++++++++++++++++ x/auth/tx/builder.go | 14 ++++++++--- x/auth/tx/builder_test.go | 14 +++++++++++ 3 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 x/auth/CHANGELOG.md diff --git a/x/auth/CHANGELOG.md b/x/auth/CHANGELOG.md new file mode 100644 index 000000000000..2409c10e3b4b --- /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 4d13c11e876f..628c9618fcd5 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -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, diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index 3ea3ae0c3b42..2fb88905beb2 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -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() From e0c2940a9d53b50266c3548db09d3de8cf20e075 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 18 Jan 2024 22:03:45 +0100 Subject: [PATCH 2/2] fix conflicts --- CHANGELOG.md | 4 ++++ x/auth/CHANGELOG.md | 53 --------------------------------------------- 2 files changed, 4 insertions(+), 53 deletions(-) delete mode 100644 x/auth/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dc9d67dc4fe..eeb4d6657bfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/x/auth/CHANGELOG.md b/x/auth/CHANGELOG.md deleted file mode 100644 index 2409c10e3b4b..000000000000 --- a/x/auth/CHANGELOG.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# 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.