From 1662e457b85825baf03006603c117d66e0489923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Aasted=20S=C3=B8rensen?= Date: Fri, 10 Sep 2021 21:32:40 +0200 Subject: [PATCH] fix: unmarshalling issue with multisig keys in master (#10061) (cherry picked from commit 3d3bc7c43218c37c6d0033d578cc7b24968a9be2) # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 20 ++++++++++++++++++++ crypto/keys/multisig/amino.go | 2 ++ crypto/keys/multisig/multisig_test.go | 8 ++++++++ 3 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfe08c13ccf6..317e17d5c717 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,9 +53,29 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Deprecated +<<<<<<< HEAD * (x/upgrade) [\#9906](https://github.com/cosmos/cosmos-sdk/pull/9906) Deprecate `UpgradeConsensusState` gRPC query since this functionality is only used for IBC, which now has its own [IBC replacement](https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) ### Bug Fixes +======= +* (x/genutil) [#10104](https://github.com/cosmos/cosmos-sdk/pull/10104) Ensure the `init` command reads the `--home` flag value correctly. +* [\#9651](https://github.com/cosmos/cosmos-sdk/pull/9651) Change inconsistent limit of `0` to `MaxUint64` on InfiniteGasMeter and add GasRemaining func to GasMeter. +* [\#9639](https://github.com/cosmos/cosmos-sdk/pull/9639) Check store keys length before accessing them by making sure that `key` is of length `m+1` (for `key[n:m]`) +* (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt` +* (x/genutil) [\#9574](https://github.com/cosmos/cosmos-sdk/pull/9575) Actually use the `gentx` client tx flags (like `--keyring-dir`) +* (x/distribution) [\#9599](https://github.com/cosmos/cosmos-sdk/pull/9599) Withdraw rewards event now includes a value attribute even if there are 0 rewards (due to situations like 100% commission). +* (x/genutil) [\#9638](https://github.com/cosmos/cosmos-sdk/pull/9638) Added missing validator key save when recovering from mnemonic +* [\#9762](https://github.com/cosmos/cosmos-sdk/pull/9762) The init command uses the chain-id from the client config if --chain-id is not provided +* [\#9854](https://github.com/cosmos/cosmos-sdk/pull/9854) Fixed the `make proto-gen` to get dynamic container name based on project name for the cosmos based sdks. +* [\#9829](https://github.com/cosmos/cosmos-sdk/pull/9829) Fixed Coin denom sorting not being checked during `Balance.Validate` check. Refactored the Validation logic to use `Coins.Validate` for `Balance.Coins`. ++ [\#9965](https://github.com/cosmos/cosmos-sdk/pull/9965) Fixed `simd version` command output to report the right release tag. ++ [\#9980](https://github.com/cosmos/cosmos-sdk/pull/9980) Returning the error when the invalid argument is passed to bank query total supply cli. ++ [\#10061](https://github.com/cosmos/cosmos-sdk/pull/10061) Ensure that `LegacyAminoPubKey` struct correctly unmarshals from JSON +* (server) [#10016](https://github.com/cosmos/cosmos-sdk/issues/10016) Fix marshaling of index-events into server config file. + + +### State Machine Breaking +>>>>>>> 3d3bc7c43 (fix: unmarshalling issue with multisig keys in master (#10061)) * [\#9965](https://github.com/cosmos/cosmos-sdk/pull/9965) Fixed `simd version` command output to report the right release tag. diff --git a/crypto/keys/multisig/amino.go b/crypto/keys/multisig/amino.go index 4849a23173d2..a1394fb0e9cf 100644 --- a/crypto/keys/multisig/amino.go +++ b/crypto/keys/multisig/amino.go @@ -78,7 +78,9 @@ func (m *LegacyAminoPubKey) UnmarshalAminoJSON(tmPk tmMultisig) error { // Instead of just doing `*m = *protoPk`, we prefer to modify in-place the // existing Anys inside `m` (instead of allocating new Anys), as so not to // break the `.compat` fields in the existing Anys. + m.PubKeys = make([]*types.Any, len(protoPk.PubKeys)) for i := range m.PubKeys { + m.PubKeys[i] = &types.Any{} m.PubKeys[i].TypeUrl = protoPk.PubKeys[i].TypeUrl m.PubKeys[i].Value = protoPk.PubKeys[i].Value } diff --git a/crypto/keys/multisig/multisig_test.go b/crypto/keys/multisig/multisig_test.go index 8fb93d3524c4..fafbd4f51564 100644 --- a/crypto/keys/multisig/multisig_test.go +++ b/crypto/keys/multisig/multisig_test.go @@ -428,6 +428,14 @@ func TestAminoUnmarshalJSON(t *testing.T) { require.NoError(t, err) lpk := pk.(*kmultisig.LegacyAminoPubKey) require.Equal(t, uint32(3), lpk.Threshold) + require.Equal(t, 5, len(pk.(*kmultisig.LegacyAminoPubKey).PubKeys)) + + for _, key := range pk.(*kmultisig.LegacyAminoPubKey).PubKeys { + require.NotNil(t, key) + pk := secp256k1.PubKey{} + err := pk.Unmarshal(key.Value) + require.NoError(t, err) + } } func TestProtoMarshalJSON(t *testing.T) {