diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8aeb8d50..59fccaa8f9 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) `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. diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 1fa833c66d..79d485f25e 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -1307,6 +1307,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 977a9284d8..6eb29b2fc4 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -461,7 +461,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