From 87e95ee01c3f8b59b5a8fd178ee995994149f1fb Mon Sep 17 00:00:00 2001 From: ItsFunny <39111451+ItsFunny@users.noreply.github.com> Date: Thu, 1 Dec 2022 19:52:30 +0800 Subject: [PATCH] Merge PR: optimize txdecoder decode simulate situation (#2752) * optimize simulate * add blank * rm error Co-authored-by: KamiD <44460798+KamiD@users.noreply.github.com> --- libs/cosmos-sdk/x/auth/ibc-tx/decoder.go | 26 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libs/cosmos-sdk/x/auth/ibc-tx/decoder.go b/libs/cosmos-sdk/x/auth/ibc-tx/decoder.go index 2b7ebf2ee9..b38c1a0b4b 100644 --- a/libs/cosmos-sdk/x/auth/ibc-tx/decoder.go +++ b/libs/cosmos-sdk/x/auth/ibc-tx/decoder.go @@ -2,6 +2,7 @@ package ibc_tx import ( "fmt" + "github.com/okex/exchain/libs/cosmos-sdk/codec" "github.com/okex/exchain/libs/cosmos-sdk/codec/unknownproto" "github.com/okex/exchain/libs/cosmos-sdk/crypto/types" @@ -10,6 +11,7 @@ import ( "github.com/okex/exchain/libs/cosmos-sdk/types/tx/signing" "github.com/okex/exchain/libs/cosmos-sdk/x/auth/ibc-tx/internal/adapter" "google.golang.org/protobuf/encoding/protowire" + //"github.com/okex/exchain/libs/cosmos-sdk/codec/unknownproto" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" @@ -166,11 +168,20 @@ func constructMsgs(ibcTx *tx.Tx) ([]sdk.Msg, []sdk.Msg, error) { } func convertSignature(ibcTx *tx.Tx) []authtypes.StdSignature { - signatures := []authtypes.StdSignature{} + ret := make([]authtypes.StdSignature, len(ibcTx.Signatures)) + for i, s := range ibcTx.Signatures { var pkData types.PubKey if ibcTx.AuthInfo.SignerInfos != nil { var ok bool + if ibcTx.AuthInfo.SignerInfos[i].PublicKey == nil { + // maybe it is a simulate request + ret[i] = authtypes.StdSignature{ + Signature: s, + PubKey: nil, + } + continue + } pkData, ok = ibcTx.AuthInfo.SignerInfos[i].PublicKey.GetCachedValue().(types.PubKey) if !ok { return []authtypes.StdSignature{} @@ -181,14 +192,13 @@ func convertSignature(ibcTx *tx.Tx) []authtypes.StdSignature { return []authtypes.StdSignature{} } - signatures = append(signatures, - authtypes.StdSignature{ - Signature: s, - PubKey: pubKey, - }, - ) + ret[i] = authtypes.StdSignature{ + Signature: s, + PubKey: pubKey, + } } - return signatures + + return ret } func convertFee(authInfo tx.AuthInfo) (authtypes.StdFee, authtypes.IbcFee, string, error) {