Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (x/auth/tx) [#26815](https://github.com/cosmos/cosmos-sdk/pull/26815) `GetSigningTxData` now converts the nested `ModeInfos` of a multisig `ModeInfo`; previously the converted entries were discarded and the slice was left as nil placeholders.
* (client/tx) [#26759](https://github.com/cosmos/cosmos-sdk/issues/26759) Populate the multisig bit array in simulation txs so `--gas auto` works for multisig senders.
* (blockstm) [#26772](https://github.com/cosmos/cosmos-sdk/pull/26772) Panic with a descriptive error when accessing an unregistered store instead of silently using store index zero.
* (x/genutil) [#26741](https://github.com/cosmos/cosmos-sdk/issues/26741) Preserve vote extension enable height when exporting genesis state.
Expand Down
5 changes: 3 additions & 2 deletions x/auth/tx/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ func adaptModeInfo(legacy *tx.ModeInfo, res *txv1beta1.ModeInfo) {
}
multiModeInfos := mi.Multi.ModeInfos
modeInfos := make([]*txv1beta1.ModeInfo, len(multiModeInfos))
for _, modeInfo := range multiModeInfos {
adaptModeInfo(modeInfo, &txv1beta1.ModeInfo{})
for i, modeInfo := range multiModeInfos {
modeInfos[i] = &txv1beta1.ModeInfo{}
adaptModeInfo(modeInfo, modeInfos[i])
}
Comment on lines +138 to 141

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Nil child modes become present

When a multisig contains an omitted child signature, SignatureDataToModeInfoAndSig produces a nil nested ModeInfo. This loop now materializes it as a non-nil empty message, so downstream consumers can mistake an absent child mode for a present but malformed mode. Only allocate the destination entry when the source entry is non-nil.

Suggested change
for i, modeInfo := range multiModeInfos {
modeInfos[i] = &txv1beta1.ModeInfo{}
adaptModeInfo(modeInfo, modeInfos[i])
}
for i, modeInfo := range multiModeInfos {
if modeInfo != nil {
modeInfos[i] = &txv1beta1.ModeInfo{}
adaptModeInfo(modeInfo, modeInfos[i])
}
}

var bitarray *multisigv1beta1.CompactBitArray
if mi.Multi.Bitarray != nil {
Expand Down
37 changes: 37 additions & 0 deletions x/auth/tx/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/stretchr/testify/require"

signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"

Expand All @@ -14,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -452,3 +454,38 @@ func TestGetSigningTxData_NilModeInfoMulti(t *testing.T) {
require.NotNil(t, td.AuthInfo.SignerInfos[0].ModeInfo.GetMulti())
})
}

func TestGetSigningTxData_MultisigModeInfos(t *testing.T) {
marshaler := codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
w := newBuilder(marshaler)

_, pubkey, addr := testdata.KeyTestPubAddr()
require.NoError(t, w.SetMsgs(testdata.NewTestMsg(addr)))

// a 2-of-2 multisig signature with one direct and one amino-json sub-signer
multi := signing.SignatureV2{
PubKey: pubkey,
Data: &signing.MultiSignatureData{
BitArray: cryptotypes.NewCompactBitArray(2),
Signatures: []signing.SignatureData{
&signing.SingleSignatureData{SignMode: signing.SignMode_SIGN_MODE_DIRECT},
&signing.SingleSignatureData{SignMode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON},
},
},
}
require.NoError(t, w.SetSignatures(multi))

td := w.GetSigningTxData()
require.Len(t, td.AuthInfo.SignerInfos, 1)

multiModeInfo := td.AuthInfo.SignerInfos[0].ModeInfo.GetMulti()
require.NotNil(t, multiModeInfo)
require.NotNil(t, multiModeInfo.Bitarray)

// the nested mode infos must be converted, not left as nil placeholders
require.Len(t, multiModeInfo.ModeInfos, 2)
require.NotNil(t, multiModeInfo.ModeInfos[0])
require.NotNil(t, multiModeInfo.ModeInfos[1])
require.Equal(t, signingv1beta1.SignMode_SIGN_MODE_DIRECT, multiModeInfo.ModeInfos[0].GetSingle().Mode)
require.Equal(t, signingv1beta1.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, multiModeInfo.ModeInfos[1].GetSingle().Mode)
}
Loading