From 01fb4985b9672315e06146ccfe5a0da831360aa2 Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Fri, 17 Feb 2023 13:11:22 +0100 Subject: [PATCH 1/3] fix: check CountSubKeys nil --- x/auth/ante/ante_test.go | 1 + x/auth/ante/sigverify.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index f3493db2fa02..ac62ad69fd59 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -1305,6 +1305,7 @@ func TestCountSubkeys(t *testing.T) { {"single key", args{singleKey}, 1}, {"single level multikey", args{singleLevelMultiKey}, 5}, {"multi level multikey", args{multiLevelMultiKey}, 11}, + {"nil key", args{nil}, 0}, } for _, tc := range testCases { t.Run(tc.name, func(T *testing.T) { diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 9006bd38b448..137d87dffb64 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -460,7 +460,12 @@ func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (sdk.A } // CountSubKeys counts the total number of keys for a multi-sig public key. +// A non-multisig, i.e. a regular signature, it naturally a count of 1. If it is a multisig, +// then it recursively calls it on its pubkeys. func CountSubKeys(pub cryptotypes.PubKey) int { + if pub == nil { + return 0 + } v, ok := pub.(*kmultisig.LegacyAminoPubKey) if !ok { return 1 From f8e56f707f15241816fdce9a23b00f6e838b2bc7 Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Fri, 17 Feb 2023 16:16:45 +0100 Subject: [PATCH 2/3] add: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8aeb8d502c..e2d5bcd6f827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -271,6 +271,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf ### Bug Fixes +* (x/auth) [#15059](https://github.com/cosmos/cosmos-sdk/pull/15059#pullrequestreview-1303611368) `ante.CountSubKeys` returns 0 when passing a nil `Pubkey`. * (x/capability) [#15030](https://github.com/cosmos/cosmos-sdk/pull/15030) Fixed bug where `x/capability` consumed `GasMeter` gas during `InitMemStore`. * [#14995](https://github.com/cosmos/cosmos-sdk/pull/14995) Allow unknown fields in `ParseTypedEvent`. * [#14952](https://github.com/cosmos/cosmos-sdk/pull/14952) Pin version of github.com/syndtr/goleveldb `v1.0.1-0.20210819022825-2ae1ddf74ef7` to avoid issues in the store. From c31ad69deb1b26522853f5fc866eb288dc056e9a Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Fri, 17 Feb 2023 16:17:51 +0100 Subject: [PATCH 3/3] fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2d5bcd6f827..59fccaa8f99d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -271,7 +271,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf ### Bug Fixes -* (x/auth) [#15059](https://github.com/cosmos/cosmos-sdk/pull/15059#pullrequestreview-1303611368) `ante.CountSubKeys` returns 0 when passing a nil `Pubkey`. +* (x/auth) [#15059](https://github.com/cosmos/cosmos-sdk/pull/15059) `ante.CountSubKeys` returns 0 when passing a nil `Pubkey`. * (x/capability) [#15030](https://github.com/cosmos/cosmos-sdk/pull/15030) Fixed bug where `x/capability` consumed `GasMeter` gas during `InitMemStore`. * [#14995](https://github.com/cosmos/cosmos-sdk/pull/14995) Allow unknown fields in `ParseTypedEvent`. * [#14952](https://github.com/cosmos/cosmos-sdk/pull/14952) Pin version of github.com/syndtr/goleveldb `v1.0.1-0.20210819022825-2ae1ddf74ef7` to avoid issues in the store.