Skip to content

Commit

Permalink
fix: allow empty public keys when setting signatures (#19106)
Browse files Browse the repository at this point in the history
(cherry picked from commit e621eb6)

# Conflicts:
#	x/auth/CHANGELOG.md
#	x/auth/tx/builder.go
  • Loading branch information
cmwaters authored and mergify[bot] committed Jan 18, 2024
1 parent 6aed814 commit 4297067
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
53 changes: 53 additions & 0 deletions x/auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section under the
appropriate stanza (see below). Each entry should ideally include a tag and
the Github issue reference in the following format:
* (<tag>) [#<issue-number>] Changelog message.
Types of changes (Stanzas):
"Features" for new features.
"Improvements" for changes in existing functionality.
"Deprecated" for soon-to-be removed features.
"Bug Fixes" for any bug fixes.
"API Breaking" for breaking exported APIs used by developers building on SDK.
Ref: https://keepachangelog.com/en/1.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.
14 changes: 13 additions & 1 deletion x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: unexpected <<, expecting }

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '<<' (typecheck)

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected <<, expecting }

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expecting }

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expecting }

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected <<, expecting }

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected <<, expecting }

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expecting }

Check failure on line 297 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expecting }
any, err := codectypes.NewAnyWithValue(sig.PubKey)
if err != nil {
return err
=======

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: unexpected ==, expecting }

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '==' (typecheck)

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expecting }

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expecting }

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expecting }

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected ==, expecting }

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected ==, expecting }

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expecting }

Check failure on line 301 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expecting }
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))

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

invalid character U+0023 '#'

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

expected statement, found '>>' (typecheck)

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid character U+0023 '#'

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid character U+0023 '#'

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid character U+0023 '#'

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid character U+0023 '#'

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid character U+0023 '#'

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expecting }

Check failure on line 307 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'
}
signerInfos[i] = &tx.SignerInfo{

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / golangci-lint

syntax error: non-declaration statement outside function body (typecheck)

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 309 in x/auth/tx/builder.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body
PublicKey: any,
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 4297067

Please sign in to comment.