From 9048ffa8d351b8ad0232c51fa3902ffd31e6244e Mon Sep 17 00:00:00 2001 From: colin axner <25233464+colin-axner@users.noreply.github.com> Date: Thu, 11 Jun 2020 15:19:25 -0700 Subject: [PATCH] Update ibc proof to be bytes (#6393) * update interfaces to use []byte instead of commitment proof * update 03/04 msgs with bytes * fix compile errors * fix channel tests * fix connection tests * fix testing, tm, and localhost tests * fix ante tests * update 03-connection spec * update channel msgs spec * small fixes after self review * rm unused import * Update x/ibc/03-connection/client/utils/utils.go Co-authored-by: Alessio Treglia * add empty proof test and rm ics 20 from ibc spec * fix merge issues Co-authored-by: Alessio Treglia --- x/ibc/02-client/exported/exported.go | 21 +- x/ibc/03-connection/client/cli/tx.go | 30 +- x/ibc/03-connection/client/rest/rest.go | 22 +- x/ibc/03-connection/client/utils/utils.go | 20 +- x/ibc/03-connection/keeper/handshake.go | 11 +- x/ibc/03-connection/keeper/keeper_test.go | 6 +- x/ibc/03-connection/keeper/verify.go | 25 +- x/ibc/03-connection/types/msgs.go | 35 +- x/ibc/03-connection/types/msgs_test.go | 13 +- x/ibc/03-connection/types/types.pb.go | 319 +++++++------ x/ibc/03-connection/types/types.proto | 19 +- x/ibc/04-channel/client/rest/rest.go | 51 +- x/ibc/04-channel/keeper/handshake.go | 9 +- x/ibc/04-channel/keeper/keeper_test.go | 6 +- x/ibc/04-channel/keeper/packet.go | 7 +- x/ibc/04-channel/keeper/packet_test.go | 3 +- x/ibc/04-channel/keeper/timeout.go | 5 +- x/ibc/04-channel/keeper/timeout_test.go | 3 +- x/ibc/04-channel/types/expected_keepers.go | 11 +- x/ibc/04-channel/types/msgs.go | 57 +-- x/ibc/04-channel/types/msgs_test.go | 177 +++---- x/ibc/04-channel/types/types.pb.go | 440 +++++++++--------- x/ibc/04-channel/types/types.proto | 19 +- x/ibc/07-tendermint/types/client_state.go | 91 ++-- .../07-tendermint/types/client_state_test.go | 38 +- x/ibc/09-localhost/types/client_state.go | 23 +- x/ibc/09-localhost/types/client_state_test.go | 36 +- x/ibc/ante/ante_test.go | 12 +- x/ibc/spec/04_messages.md | 252 +++++++++- x/ibc/testing/chain.go | 11 +- 30 files changed, 1010 insertions(+), 762 deletions(-) diff --git a/x/ibc/02-client/exported/exported.go b/x/ibc/02-client/exported/exported.go index 304a62430c..e8157fcc47 100644 --- a/x/ibc/02-client/exported/exported.go +++ b/x/ibc/02-client/exported/exported.go @@ -26,13 +26,14 @@ type ClientState interface { VerifyClientConsensusState( store sdk.KVStore, - cdc *codec.Codec, + cdc codec.Marshaler, + aminoCdc *codec.Codec, root commitmentexported.Root, height uint64, counterpartyClientIdentifier string, consensusHeight uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, consensusState ConsensusState, ) error VerifyConnectionState( @@ -40,7 +41,7 @@ type ClientState interface { cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, connectionID string, connectionEnd connectionexported.ConnectionI, consensusState ConsensusState, @@ -50,7 +51,7 @@ type ClientState interface { cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, channel channelexported.ChannelI, @@ -58,9 +59,10 @@ type ClientState interface { ) error VerifyPacketCommitment( store sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -69,9 +71,10 @@ type ClientState interface { ) error VerifyPacketAcknowledgement( store sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -80,9 +83,10 @@ type ClientState interface { ) error VerifyPacketAcknowledgementAbsence( store sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -90,9 +94,10 @@ type ClientState interface { ) error VerifyNextSequenceRecv( store sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, nextSequenceRecv uint64, diff --git a/x/ibc/03-connection/client/cli/tx.go b/x/ibc/03-connection/client/cli/tx.go index 36d8eb1634..7c41faa5af 100644 --- a/x/ibc/03-connection/client/cli/tx.go +++ b/x/ibc/03-connection/client/cli/tx.go @@ -81,7 +81,7 @@ func GetCmdConnectionOpenTry(storeKey string, cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ Use: strings.TrimSpace(`open-try [connection-id] [client-id] [counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json] -[counterparty-versions] [path/to/proof_init.json]`), +[counterparty-versions] [path/to/proof_init.json] [path/to/proof_consensus.json]`), Short: "initiate connection handshake between two chains", Long: strings.TrimSpace( fmt.Sprintf(`initialize a connection on chain A with a given counterparty chain B: @@ -89,10 +89,10 @@ func GetCmdConnectionOpenTry(storeKey string, cdc *codec.Codec) *cobra.Command { Example: $ %s tx ibc connection open-try connection-id] [client-id] \ [counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json] \ -[counterparty-versions] [path/to/proof_init.json] +[counterparty-versions] [path/to/proof_init.json] [path/tp/proof_consensus.json] `, version.ClientName), ), - Args: cobra.ExactArgs(7), + Args: cobra.ExactArgs(8), RunE: func(cmd *cobra.Command, args []string) error { inBuf := bufio.NewReader(cmd.InOrStdin()) txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) @@ -113,7 +113,12 @@ $ %s tx ibc connection open-try connection-id] [client-id] \ // TODO: parse strings? counterpartyVersions := args[5] - proofInit, err := utils.ParseProof(clientCtx.Codec, args[1]) + proofInit, err := utils.ParseProof(clientCtx.Codec, args[6]) + if err != nil { + return err + } + + proofConsensus, err := utils.ParseProof(clientCtx.Codec, args[7]) if err != nil { return err } @@ -126,7 +131,7 @@ $ %s tx ibc connection open-try connection-id] [client-id] \ msg := types.NewMsgConnectionOpenTry( connectionID, clientID, counterpartyConnectionID, counterpartyClientID, - counterpartyPrefix, []string{counterpartyVersions}, proofInit, proofInit, proofHeight, + counterpartyPrefix, []string{counterpartyVersions}, proofInit, proofConsensus, proofHeight, consensusHeight, clientCtx.GetFromAddress(), ) @@ -145,16 +150,16 @@ $ %s tx ibc connection open-try connection-id] [client-id] \ // connection open attempt from chain B to chain A func GetCmdConnectionOpenAck(storeKey string, cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ - Use: "open-ack [connection-id] [path/to/proof_try.json] [version]", + Use: "open-ack [connection-id] [path/to/proof_try.json] [path/to/proof_consensus.json] [version]", Short: "relay the acceptance of a connection open attempt from chain B to chain A", Long: strings.TrimSpace( fmt.Sprintf(`relay the acceptance of a connection open attempt from chain B to chain A: Example: -$ %s tx ibc connection open-ack [connection-id] [path/to/proof_try.json] [version] +$ %s tx ibc connection open-ack [connection-id] [path/to/proof_try.json] [path/to/proof_consensus.json] [version] `, version.ClientName), ), - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { inBuf := bufio.NewReader(cmd.InOrStdin()) txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) @@ -167,16 +172,21 @@ $ %s tx ibc connection open-ack [connection-id] [path/to/proof_try.json] [versio return err } + proofConsensus, err := utils.ParseProof(clientCtx.Codec, args[2]) + if err != nil { + return err + } + proofHeight := uint64(clientCtx.Height) consensusHeight, err := lastHeight(clientCtx) if err != nil { return err } - version := args[4] + version := args[3] msg := types.NewMsgConnectionOpenAck( - connectionID, proofTry, proofTry, proofHeight, + connectionID, proofTry, proofConsensus, proofHeight, consensusHeight, version, clientCtx.GetFromAddress(), ) diff --git a/x/ibc/03-connection/client/rest/rest.go b/x/ibc/03-connection/client/rest/rest.go index 04e039d0d9..b959a449c4 100644 --- a/x/ibc/03-connection/client/rest/rest.go +++ b/x/ibc/03-connection/client/rest/rest.go @@ -38,25 +38,25 @@ type ConnectionOpenTryReq struct { CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"` CounterpartyPrefix commitmenttypes.MerklePrefix `json:"counterparty_prefix" yaml:"counterparty_prefix"` CounterpartyVersions []string `json:"counterparty_versions" yaml:"counterparty_versions"` - ProofInit commitmenttypes.MerkleProof `json:"proof_init" yaml:"proof_init"` - ProofConsensus commitmenttypes.MerkleProof `json:"proof_consensus" yaml:"proof_consensus"` + ProofInit []byte `json:"proof_init" yaml:"proof_init"` + ProofConsensus []byte `json:"proof_consensus" yaml:"proof_consensus"` ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"` } // ConnectionOpenAckReq defines the properties of a connection open ack request's body. type ConnectionOpenAckReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ProofTry commitmenttypes.MerkleProof `json:"proof_try" yaml:"proof_try"` - ProofConsensus commitmenttypes.MerkleProof `json:"proof_consensus" yaml:"proof_consensus"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` - ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"` - Version string `json:"version" yaml:"version"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + ProofTry []byte `json:"proof_try" yaml:"proof_try"` + ProofConsensus []byte `json:"proof_consensus" yaml:"proof_consensus"` + ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"` + Version string `json:"version" yaml:"version"` } // ConnectionOpenConfirmReq defines the properties of a connection open confirm request's body. type ConnectionOpenConfirmReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ProofAck commitmenttypes.MerkleProof `json:"proof_ack" yaml:"proof_ack"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + ProofAck []byte `json:"proof_ack" yaml:"proof_ack"` + ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` } diff --git a/x/ibc/03-connection/client/utils/utils.go b/x/ibc/03-connection/client/utils/utils.go index c5e1c275e6..5694dac367 100644 --- a/x/ibc/03-connection/client/utils/utils.go +++ b/x/ibc/03-connection/client/utils/utils.go @@ -129,19 +129,21 @@ func ParsePrefix(cdc *codec.Codec, arg string) (commitmenttypes.MerklePrefix, er return prefix, nil } -// ParseProof unmarshals an cmd input argument from a JSON string to a commitment -// Proof. If the input is not a JSON, it looks for a path to the JSON file. -func ParseProof(cdc *codec.Codec, arg string) (commitmenttypes.MerkleProof, error) { - var proof commitmenttypes.MerkleProof - if err := cdc.UnmarshalJSON([]byte(arg), &proof); err != nil { +// ParseProof unmarshals a cmd input argument from a JSON string to a commitment +// Proof. If the input is not a JSON, it looks for a path to the JSON file. It +// then marshals the commitment proof into a proto encoded byte array. +func ParseProof(cdc *codec.Codec, arg string) ([]byte, error) { + var merkleProof commitmenttypes.MerkleProof + if err := cdc.UnmarshalJSON([]byte(arg), &merkleProof); err != nil { // check for file path if JSON input is not provided contents, err := ioutil.ReadFile(arg) if err != nil { - return commitmenttypes.MerkleProof{}, errors.New("neither JSON input nor path to .json file were provided") + return nil, errors.New("neither JSON input nor path to .json file were provided") } - if err := cdc.UnmarshalJSON(contents, &proof); err != nil { - return commitmenttypes.MerkleProof{}, errors.Wrap(err, "error unmarshalling commitment proof") + if err := cdc.UnmarshalJSON(contents, &merkleProof); err != nil { + return nil, fmt.Errorf("error unmarshalling commitment proof: %w", err) } } - return proof, nil + + return cdc.MarshalBinaryBare(&merkleProof) } diff --git a/x/ibc/03-connection/keeper/handshake.go b/x/ibc/03-connection/keeper/handshake.go index 1bdcf3164d..48aefed3f3 100644 --- a/x/ibc/03-connection/keeper/handshake.go +++ b/x/ibc/03-connection/keeper/handshake.go @@ -8,7 +8,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) @@ -50,8 +49,8 @@ func (k Keeper) ConnOpenTry( counterparty types.Counterparty, // counterpartyConnectionIdentifier, counterpartyPrefix and counterpartyClientIdentifier clientID string, // clientID of chainA counterpartyVersions []string, // supported versions of chain A - proofInit commitmentexported.Proof, // proof that chainA stored connectionEnd in state (on ConnOpenInit) - proofConsensus commitmentexported.Proof, // proof that chainA stored chainB's consensus state at consensus height + proofInit []byte, // proof that chainA stored connectionEnd in state (on ConnOpenInit) + proofConsensus []byte, // proof that chainA stored chainB's consensus state at consensus height proofHeight uint64, // height at which relayer constructs proof of A storing connectionEnd in state consensusHeight uint64, // latest height of chain B which chain A has stored in its chain B client ) error { @@ -124,8 +123,8 @@ func (k Keeper) ConnOpenAck( ctx sdk.Context, connectionID string, version string, // version that ChainB chose in ConnOpenTry - proofTry commitmentexported.Proof, // proof that connectionEnd was added to ChainB state in ConnOpenTry - proofConsensus commitmentexported.Proof, // proof that chainB has stored ConsensusState of chainA on its client + proofTry []byte, // proof that connectionEnd was added to ChainB state in ConnOpenTry + proofConsensus []byte, // proof that chainB has stored ConsensusState of chainA on its client proofHeight uint64, // height that relayer constructed proofTry consensusHeight uint64, // latest height of chainA that chainB has stored on its chainA client ) error { @@ -196,7 +195,7 @@ func (k Keeper) ConnOpenAck( func (k Keeper) ConnOpenConfirm( ctx sdk.Context, connectionID string, - proofAck commitmentexported.Proof, // proof that connection opened on ChainA during ConnOpenAck + proofAck []byte, // proof that connection opened on ChainA during ConnOpenAck proofHeight uint64, // height that relayer constructed proofAck ) error { // Retrieve connection diff --git a/x/ibc/03-connection/keeper/keeper_test.go b/x/ibc/03-connection/keeper/keeper_test.go index 18284b929d..42aab0b8bf 100644 --- a/x/ibc/03-connection/keeper/keeper_test.go +++ b/x/ibc/03-connection/keeper/keeper_test.go @@ -67,7 +67,7 @@ func (suite *KeeperTestSuite) SetupTest() { } // nolint: unused -func queryProof(chain *TestChain, key []byte) (commitmenttypes.MerkleProof, uint64) { +func queryProof(chain *TestChain, key []byte) ([]byte, uint64) { res := chain.App.Query(abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", storeKey), Height: chain.App.LastBlockHeight(), @@ -75,10 +75,12 @@ func queryProof(chain *TestChain, key []byte) (commitmenttypes.MerkleProof, uint Prove: true, }) - proof := commitmenttypes.MerkleProof{ + merkleProof := commitmenttypes.MerkleProof{ Proof: res.Proof, } + proof, _ := chain.App.AppCodec().MarshalBinaryBare(&merkleProof) + return proof, uint64(res.Height) } func TestKeeperTestSuite(t *testing.T) { diff --git a/x/ibc/03-connection/keeper/verify.go b/x/ibc/03-connection/keeper/verify.go index 1398b7b5b2..2a578cc2ad 100644 --- a/x/ibc/03-connection/keeper/verify.go +++ b/x/ibc/03-connection/keeper/verify.go @@ -7,7 +7,6 @@ import ( clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" ) // VerifyClientConsensusState verifies a proof of the consensus state of the @@ -17,7 +16,7 @@ func (k Keeper) VerifyClientConsensusState( connection exported.ConnectionI, height uint64, consensusHeight uint64, - proof commitmentexported.Proof, + proof []byte, consensusState clientexported.ConsensusState, ) error { clientID := connection.GetClientID() @@ -32,7 +31,7 @@ func (k Keeper) VerifyClientConsensusState( } return clientState.VerifyClientConsensusState( - k.clientKeeper.ClientStore(ctx, clientID), k.aminoCdc, targetConsState.GetRoot(), height, + k.clientKeeper.ClientStore(ctx, clientID), k.cdc, k.aminoCdc, targetConsState.GetRoot(), height, connection.GetCounterparty().GetClientID(), consensusHeight, connection.GetCounterparty().GetPrefix(), proof, consensusState, ) } @@ -43,7 +42,7 @@ func (k Keeper) VerifyConnectionState( ctx sdk.Context, connection exported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, connectionID string, connectionEnd exported.ConnectionI, // opposite connection ) error { @@ -75,7 +74,7 @@ func (k Keeper) VerifyChannelState( ctx sdk.Context, connection exported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, channel channelexported.ChannelI, @@ -109,7 +108,7 @@ func (k Keeper) VerifyPacketCommitment( ctx sdk.Context, connection exported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -132,7 +131,7 @@ func (k Keeper) VerifyPacketCommitment( } return clientState.VerifyPacketCommitment( - k.clientKeeper.ClientStore(ctx, connection.GetClientID()), height, + k.clientKeeper.ClientStore(ctx, connection.GetClientID()), k.cdc, height, connection.GetCounterparty().GetPrefix(), proof, portID, channelID, sequence, commitmentBytes, consensusState, ) @@ -144,7 +143,7 @@ func (k Keeper) VerifyPacketAcknowledgement( ctx sdk.Context, connection exported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -167,7 +166,7 @@ func (k Keeper) VerifyPacketAcknowledgement( } return clientState.VerifyPacketAcknowledgement( - k.clientKeeper.ClientStore(ctx, connection.GetClientID()), height, + k.clientKeeper.ClientStore(ctx, connection.GetClientID()), k.cdc, height, connection.GetCounterparty().GetPrefix(), proof, portID, channelID, sequence, acknowledgement, consensusState, ) @@ -180,7 +179,7 @@ func (k Keeper) VerifyPacketAcknowledgementAbsence( ctx sdk.Context, connection exported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -202,7 +201,7 @@ func (k Keeper) VerifyPacketAcknowledgementAbsence( } return clientState.VerifyPacketAcknowledgementAbsence( - k.clientKeeper.ClientStore(ctx, connection.GetClientID()), height, + k.clientKeeper.ClientStore(ctx, connection.GetClientID()), k.cdc, height, connection.GetCounterparty().GetPrefix(), proof, portID, channelID, sequence, consensusState, ) @@ -214,7 +213,7 @@ func (k Keeper) VerifyNextSequenceRecv( ctx sdk.Context, connection exported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, nextSequenceRecv uint64, @@ -236,7 +235,7 @@ func (k Keeper) VerifyNextSequenceRecv( } return clientState.VerifyNextSequenceRecv( - k.clientKeeper.ClientStore(ctx, connection.GetClientID()), height, + k.clientKeeper.ClientStore(ctx, connection.GetClientID()), k.cdc, height, connection.GetCounterparty().GetPrefix(), proof, portID, channelID, nextSequenceRecv, consensusState, ) diff --git a/x/ibc/03-connection/types/msgs.go b/x/ibc/03-connection/types/msgs.go index 1b61f43324..5f2adc9694 100644 --- a/x/ibc/03-connection/types/msgs.go +++ b/x/ibc/03-connection/types/msgs.go @@ -66,7 +66,7 @@ var _ sdk.Msg = &MsgConnectionOpenTry{} func NewMsgConnectionOpenTry( connectionID, clientID, counterpartyConnectionID, counterpartyClientID string, counterpartyPrefix commitmenttypes.MerklePrefix, - counterpartyVersions []string, proofInit, proofConsensus commitmenttypes.MerkleProof, + counterpartyVersions []string, proofInit, proofConsensus []byte, proofHeight, consensusHeight uint64, signer sdk.AccAddress, ) *MsgConnectionOpenTry { counterparty := NewCounterparty(counterpartyClientID, counterpartyConnectionID, counterpartyPrefix) @@ -109,14 +109,11 @@ func (msg MsgConnectionOpenTry) ValidateBasic() error { return sdkerrors.Wrap(sdkerrors.ErrInvalidVersion, "version can't be blank") } } - if msg.ProofInit.Empty() || msg.ProofConsensus.Empty() { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") + if len(msg.ProofInit) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof init") } - if err := msg.ProofInit.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof init cannot be nil") - } - if err := msg.ProofConsensus.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof consensus cannot be nil") + if len(msg.ProofConsensus) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof of consensus state") } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") @@ -144,7 +141,7 @@ var _ sdk.Msg = &MsgConnectionOpenAck{} // NewMsgConnectionOpenAck creates a new MsgConnectionOpenAck instance func NewMsgConnectionOpenAck( - connectionID string, proofTry, proofConsensus commitmenttypes.MerkleProof, + connectionID string, proofTry, proofConsensus []byte, proofHeight, consensusHeight uint64, version string, signer sdk.AccAddress, ) *MsgConnectionOpenAck { @@ -177,14 +174,11 @@ func (msg MsgConnectionOpenAck) ValidateBasic() error { if strings.TrimSpace(msg.Version) == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidVersion, "version can't be blank") } - if msg.ProofTry.Empty() || msg.ProofConsensus.Empty() { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") + if len(msg.ProofTry) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof try") } - if err := msg.ProofTry.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof try cannot be nil") - } - if err := msg.ProofConsensus.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof consensus cannot be nil") + if len(msg.ProofConsensus) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof of consensus state") } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") @@ -212,7 +206,7 @@ var _ sdk.Msg = &MsgConnectionOpenConfirm{} // NewMsgConnectionOpenConfirm creates a new MsgConnectionOpenConfirm instance func NewMsgConnectionOpenConfirm( - connectionID string, proofAck commitmenttypes.MerkleProof, proofHeight uint64, + connectionID string, proofAck []byte, proofHeight uint64, signer sdk.AccAddress, ) *MsgConnectionOpenConfirm { return &MsgConnectionOpenConfirm{ @@ -238,11 +232,8 @@ func (msg MsgConnectionOpenConfirm) ValidateBasic() error { if err := host.ConnectionIdentifierValidator(msg.ConnectionID); err != nil { return sdkerrors.Wrap(err, "invalid connection ID") } - if msg.ProofAck.Empty() { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") - } - if err := msg.ProofAck.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof ack cannot be nil") + if len(msg.ProofAck) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof ack") } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") diff --git a/x/ibc/03-connection/types/msgs_test.go b/x/ibc/03-connection/types/msgs_test.go index 3f35e61083..48ec2214a5 100644 --- a/x/ibc/03-connection/types/msgs_test.go +++ b/x/ibc/03-connection/types/msgs_test.go @@ -9,6 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/rootmulti" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -19,16 +20,17 @@ import ( var ( emptyPrefix = commitmenttypes.MerklePrefix{} - emptyProof = commitmenttypes.MerkleProof{Proof: nil} + emptyProof = []byte{} ) type MsgTestSuite struct { suite.Suite - proof commitmenttypes.MerkleProof + proof []byte } func (suite *MsgTestSuite) SetupTest() { + app := simapp.Setup(false) db := dbm.NewMemDB() store := rootmulti.NewStore(db) storeKey := storetypes.NewKVStoreKey("iavlStoreKey") @@ -46,7 +48,12 @@ func (suite *MsgTestSuite) SetupTest() { Prove: true, }) - suite.proof = commitmenttypes.MerkleProof{Proof: res.Proof} + merkleProof := commitmenttypes.MerkleProof{Proof: res.Proof} + proof, err := app.AppCodec().MarshalBinaryBare(&merkleProof) + suite.NoError(err) + + suite.proof = proof + } func TestMsgTestSuite(t *testing.T) { diff --git a/x/ibc/03-connection/types/types.pb.go b/x/ibc/03-connection/types/types.pb.go index 6c7e8f3334..8e9982d560 100644 --- a/x/ibc/03-connection/types/types.pb.go +++ b/x/ibc/03-connection/types/types.pb.go @@ -140,10 +140,10 @@ type MsgConnectionOpenTry struct { Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` CounterpartyVersions []string `protobuf:"bytes,4,rep,name=counterparty_versions,json=counterpartyVersions,proto3" json:"counterparty_versions,omitempty" yaml:"counterparty_versions"` // proof of the initialization the connection on Chain A: `UNITIALIZED -> INIT` - ProofInit types.MerkleProof `protobuf:"bytes,5,opt,name=proof_init,json=proofInit,proto3" json:"proof_init" yaml:"proof_init"` - ProofHeight uint64 `protobuf:"varint,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` + ProofInit []byte `protobuf:"bytes,5,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty" yaml:"proof_init"` + ProofHeight uint64 `protobuf:"varint,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty"` // proof of client consensus state - ProofConsensus types.MerkleProof `protobuf:"bytes,7,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus" yaml:"proof_consensus"` + ProofConsensus []byte `protobuf:"bytes,7,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus,omitempty" yaml:"proof_consensus"` ConsensusHeight uint64 `protobuf:"varint,8,opt,name=consensus_height,json=consensusHeight,proto3" json:"consensus_height,omitempty" yaml:"consensus_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,9,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -209,11 +209,11 @@ func (m *MsgConnectionOpenTry) GetCounterpartyVersions() []string { return nil } -func (m *MsgConnectionOpenTry) GetProofInit() types.MerkleProof { +func (m *MsgConnectionOpenTry) GetProofInit() []byte { if m != nil { return m.ProofInit } - return types.MerkleProof{} + return nil } func (m *MsgConnectionOpenTry) GetProofHeight() uint64 { @@ -223,11 +223,11 @@ func (m *MsgConnectionOpenTry) GetProofHeight() uint64 { return 0 } -func (m *MsgConnectionOpenTry) GetProofConsensus() types.MerkleProof { +func (m *MsgConnectionOpenTry) GetProofConsensus() []byte { if m != nil { return m.ProofConsensus } - return types.MerkleProof{} + return nil } func (m *MsgConnectionOpenTry) GetConsensusHeight() uint64 { @@ -250,10 +250,10 @@ type MsgConnectionOpenAck struct { ConnectionID string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // proof of the initialization the connection on Chain B: `UNITIALIZED -> TRYOPEN` - ProofTry types.MerkleProof `protobuf:"bytes,3,opt,name=proof_try,json=proofTry,proto3" json:"proof_try" yaml:"proof_try"` - ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` + ProofTry []byte `protobuf:"bytes,3,opt,name=proof_try,json=proofTry,proto3" json:"proof_try,omitempty" yaml:"proof_try"` + ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` // proof of client consensus state - ProofConsensus types.MerkleProof `protobuf:"bytes,5,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus" yaml:"proof_consensus"` + ProofConsensus []byte `protobuf:"bytes,5,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus,omitempty" yaml:"proof_consensus"` ConsensusHeight uint64 `protobuf:"varint,6,opt,name=consensus_height,json=consensusHeight,proto3" json:"consensus_height,omitempty" yaml:"consensus_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,7,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -305,11 +305,11 @@ func (m *MsgConnectionOpenAck) GetVersion() string { return "" } -func (m *MsgConnectionOpenAck) GetProofTry() types.MerkleProof { +func (m *MsgConnectionOpenAck) GetProofTry() []byte { if m != nil { return m.ProofTry } - return types.MerkleProof{} + return nil } func (m *MsgConnectionOpenAck) GetProofHeight() uint64 { @@ -319,11 +319,11 @@ func (m *MsgConnectionOpenAck) GetProofHeight() uint64 { return 0 } -func (m *MsgConnectionOpenAck) GetProofConsensus() types.MerkleProof { +func (m *MsgConnectionOpenAck) GetProofConsensus() []byte { if m != nil { return m.ProofConsensus } - return types.MerkleProof{} + return nil } func (m *MsgConnectionOpenAck) GetConsensusHeight() uint64 { @@ -345,7 +345,7 @@ func (m *MsgConnectionOpenAck) GetSigner() github_com_cosmos_cosmos_sdk_types.Ac type MsgConnectionOpenConfirm struct { ConnectionID string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` // proof for the change of the connection state on Chain A: `INIT -> OPEN` - ProofAck types.MerkleProof `protobuf:"bytes,2,opt,name=proof_ack,json=proofAck,proto3" json:"proof_ack" yaml:"proof_ack"` + ProofAck []byte `protobuf:"bytes,2,opt,name=proof_ack,json=proofAck,proto3" json:"proof_ack,omitempty" yaml:"proof_ack"` ProofHeight uint64 `protobuf:"varint,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -390,11 +390,11 @@ func (m *MsgConnectionOpenConfirm) GetConnectionID() string { return "" } -func (m *MsgConnectionOpenConfirm) GetProofAck() types.MerkleProof { +func (m *MsgConnectionOpenConfirm) GetProofAck() []byte { if m != nil { return m.ProofAck } - return types.MerkleProof{} + return nil } func (m *MsgConnectionOpenConfirm) GetProofHeight() uint64 { @@ -566,64 +566,63 @@ func init() { } var fileDescriptor_30ee50c03d1fbe43 = []byte{ - // 911 bytes of a gzipped FileDescriptorProto - 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b9, 0x0f, 0x1e, - 0x24, 0xe5, 0xce, 0x6b, 0xe8, 0x63, 0xe4, 0xb9, 0x58, 0x91, 0xf4, 0x34, 0xbd, 0xf1, 0x2c, 0xd0, - 0x3e, 0x9e, 0xa7, 0x77, 0x89, 0x99, 0x61, 0xad, 0x27, 0xf5, 0x2f, 0x43, 0xb5, 0x0c, 0x01, 0x18, - 0xfb, 0x9e, 0x77, 0xd0, 0x41, 0x2e, 0x22, 0x4a, 0x86, 0x25, 0xfb, 0xf9, 0x65, 0xc9, 0xce, 0x21, - 0xa7, 0xc9, 0xee, 0x40, 0x7f, 0x78, 0x08, 0x5b, 0xd4, 0xaf, 0xfe, 0x21, 0xcd, 0x75, 0x16, 0x68, - 0xf7, 0xf8, 0xe1, 0x71, 0x30, 0xc3, 0xca, 0x33, 0x81, 0xd1, 0xfe, 0x09, 0x28, 0xf0, 0x9d, 0x01, - 0x44, 0xfd, 0x01, 0x51, 0xb2, 0xba, 0x50, 0x96, 0xac, 0x55, 0xa6, 0xfb, 0x86, 0xa9, 0x64, 0x02, - 0xee, 0x72, 0x13, 0xdb, 0x73, 0x31, 0x74, 0xf1, 0x11, 0x56, 0x56, 0x6e, 0x9e, 0x8e, 0x1a, 0xa6, - 0xf3, 0x41, 0x32, 0x9d, 0x28, 0xa2, 0x61, 0xdd, 0x61, 0x9a, 0xc6, 0x5c, 0x21, 0x3f, 0x07, 0xc5, - 0x68, 0x77, 0x9e, 0x5c, 0x8e, 0x26, 0x57, 0xff, 0x68, 0x16, 0x68, 0x0f, 0xa3, 0x86, 0x5f, 0xb0, - 0x30, 0xac, 0xbb, 0x91, 0x2a, 0xcc, 0x3e, 0x06, 0x3d, 0x7f, 0x5b, 0xd0, 0x7f, 0x91, 0x2e, 0x01, - 0xbd, 0x66, 0x0f, 0x17, 0x49, 0x15, 0x6e, 0x45, 0xaa, 0x02, 0x56, 0x42, 0x3a, 0x38, 0xf2, 0xd6, - 0x5c, 0x94, 0x7b, 0x80, 0xb7, 0x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FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0xbf, 0x6f, 0xdb, 0x46, + 0x14, 0x16, 0x29, 0x4a, 0x96, 0xce, 0x72, 0xa2, 0x30, 0x72, 0x43, 0xb0, 0x05, 0xc9, 0x32, 0x48, + 0x21, 0x14, 0x35, 0x55, 0x3b, 0x45, 0x06, 0x17, 0x1d, 0x24, 0x59, 0x41, 0x59, 0xd4, 0x8a, 0x40, + 0xcb, 0x01, 0x9a, 0x85, 0x90, 0x48, 0x5a, 0x3a, 0xc8, 0x22, 0x05, 0xde, 0x39, 0xb0, 0xf6, 0x0e, + 0x81, 0xa7, 0xae, 0x1d, 0x0c, 0x14, 0xc8, 0xd6, 0x3f, 0xa4, 0xf0, 0x98, 0xb1, 0x13, 0x51, 0xc8, + 0x7b, 0x07, 0x8d, 0x9d, 0x0a, 0xde, 0x51, 0xa4, 0x14, 0xb9, 0x0e, 0x0c, 0x69, 0x28, 0x90, 0x45, + 0xba, 0xf7, 0xeb, 0x7b, 0xf7, 0xde, 0xf7, 0xf8, 0x48, 0xf0, 0xe4, 0xbc, 0x02, 0xbb, 0x56, 0xe5, + 0xeb, 0xa7, 0x3b, 0x96, 0xe7, 0xba, 0x8e, 0x85, 0xa1, 0xe7, 0x56, 0xf0, 0x78, 0xe4, 0x20, 0xfa, + 0xab, 0x8d, 0x7c, 0x0f, 0x7b, 0xbc, 0x64, 0x79, 0x68, 0xe8, 0x21, 0x13, 0xd9, 0x03, 0xed, 0x5c, + 0x83, 0x5d, 0x4b, 0x4b, 0xdc, 0xb5, 0xd7, 0xbb, 0xe2, 0x17, 0xb8, 0x0f, 0x7d, 0xdb, 0x1c, 0x75, + 0x7c, 0x3c, 0xae, 0x90, 0x90, 0x4a, 0xcf, 0xeb, 0x79, 0xc9, 0x89, 0xe2, 0x88, 0x51, 0xba, 0xbd, + 0x30, 0xdd, 0x70, 0x08, 0xf1, 0xd0,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0xab, 0x83, 0xfb, 0x88, 0x2f, 0x81, 0xcc, + 0x28, 0x3c, 0x08, 0x0c, 0xe1, 0x8c, 0x0a, 0x5f, 0xfe, 0xca, 0x80, 0x0c, 0x21, 0x81, 0x7f, 0x06, + 0xe4, 0xa3, 0x76, 0xb5, 0xdd, 0x30, 0x8f, 0x9b, 0x7a, 0x53, 0x6f, 0xeb, 0xd5, 0x1f, 0xf5, 0x57, + 0x8d, 0x03, 0xf3, 0xb8, 0x79, 0xd4, 0x6a, 0xd4, 0xf5, 0xe7, 0x7a, 0xe3, 0xa0, 0x98, 0x12, 0x1f, + 0x5c, 0x5c, 0x2a, 0x5b, 0x0b, 0x0e, 0xbc, 0x00, 0x00, 0x8d, 0x0b, 0x95, 0x45, 0x46, 0xcc, 0x5d, + 0x5c, 0x2a, 0x5c, 0x78, 0xe6, 0x25, 0xb0, 0x45, 0x2d, 0x6d, 0xe3, 0xa7, 0x17, 0xad, 0x46, 0xb3, + 0xc8, 0x8a, 0x9b, 0x17, 0x97, 0xca, 0x46, 0x24, 0x26, 0x91, 0xc4, 0x98, 0xa6, 0x91, 0xe1, 0x59, + 0xe4, 0xde, 0xbc, 0x95, 0x52, 0xb5, 0xd6, 0xd5, 0x44, 0x62, 0xde, 0x4d, 0x24, 0xe6, 0xaf, 0x89, + 0xc4, 0xfc, 0x72, 0x2d, 0xa5, 0xde, 0x5d, 0x4b, 0xa9, 0x3f, 0xaf, 0xa5, 0xd4, 0xab, 0x67, 0xb7, + 0x3e, 0x2f, 0xff, 0xf9, 0xb1, 0xd9, 0xcd, 0x92, 0x0f, 0xbf, 0xa7, 0xff, 0x06, 0x00, 0x00, 0xff, + 0xff, 0x9f, 0x6b, 0x1d, 0x24, 0x90, 0x0a, 0x00, 0x00, } func (m *MsgConnectionOpenInit) Marshal() (dAtA []byte, err error) { @@ -712,31 +711,25 @@ func (m *MsgConnectionOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x40 } - { - size, err := m.ProofConsensus.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofConsensus) > 0 { + i -= len(m.ProofConsensus) + copy(dAtA[i:], m.ProofConsensus) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofConsensus))) + i-- + dAtA[i] = 0x3a } - i-- - dAtA[i] = 0x3a if m.ProofHeight != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) i-- dAtA[i] = 0x30 } - { - size, err := m.ProofInit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofInit) > 0 { + i -= len(m.ProofInit) + copy(dAtA[i:], m.ProofInit) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofInit))) + i-- + dAtA[i] = 0x2a } - i-- - dAtA[i] = 0x2a if len(m.CounterpartyVersions) > 0 { for iNdEx := len(m.CounterpartyVersions) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.CounterpartyVersions[iNdEx]) @@ -805,31 +798,25 @@ func (m *MsgConnectionOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x30 } - { - size, err := m.ProofConsensus.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofConsensus) > 0 { + i -= len(m.ProofConsensus) + copy(dAtA[i:], m.ProofConsensus) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofConsensus))) + i-- + dAtA[i] = 0x2a } - i-- - dAtA[i] = 0x2a if m.ProofHeight != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) i-- dAtA[i] = 0x20 } - { - size, err := m.ProofTry.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofTry) > 0 { + i -= len(m.ProofTry) + copy(dAtA[i:], m.ProofTry) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofTry))) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if len(m.Version) > 0 { i -= len(m.Version) copy(dAtA[i:], m.Version) @@ -879,16 +866,13 @@ func (m *MsgConnectionOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error i-- dAtA[i] = 0x18 } - { - size, err := m.ProofAck.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofAck) > 0 { + i -= len(m.ProofAck) + copy(dAtA[i:], m.ProofAck) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofAck))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.ConnectionID) > 0 { i -= len(m.ConnectionID) copy(dAtA[i:], m.ConnectionID) @@ -1095,13 +1079,17 @@ func (m *MsgConnectionOpenTry) Size() (n int) { n += 1 + l + sovTypes(uint64(l)) } } - l = m.ProofInit.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofInit) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } - l = m.ProofConsensus.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofConsensus) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ConsensusHeight != 0 { n += 1 + sovTypes(uint64(m.ConsensusHeight)) } @@ -1126,13 +1114,17 @@ func (m *MsgConnectionOpenAck) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.ProofTry.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofTry) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } - l = m.ProofConsensus.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofConsensus) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ConsensusHeight != 0 { n += 1 + sovTypes(uint64(m.ConsensusHeight)) } @@ -1153,8 +1145,10 @@ func (m *MsgConnectionOpenConfirm) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.ProofAck.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofAck) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -1579,7 +1573,7 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -1589,23 +1583,24 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofInit = append(m.ProofInit[:0], dAtA[iNdEx:postIndex]...) + if m.ProofInit == nil { + m.ProofInit = []byte{} } iNdEx = postIndex case 6: @@ -1631,7 +1626,7 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofConsensus", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -1641,23 +1636,24 @@ func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofConsensus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofConsensus = append(m.ProofConsensus[:0], dAtA[iNdEx:postIndex]...) + if m.ProofConsensus == nil { + m.ProofConsensus = []byte{} } iNdEx = postIndex case 8: @@ -1834,7 +1830,7 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofTry", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -1844,23 +1840,24 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofTry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofTry = append(m.ProofTry[:0], dAtA[iNdEx:postIndex]...) + if m.ProofTry == nil { + m.ProofTry = []byte{} } iNdEx = postIndex case 4: @@ -1886,7 +1883,7 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofConsensus", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -1896,23 +1893,24 @@ func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofConsensus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofConsensus = append(m.ProofConsensus[:0], dAtA[iNdEx:postIndex]...) + if m.ProofConsensus == nil { + m.ProofConsensus = []byte{} } iNdEx = postIndex case 6: @@ -2057,7 +2055,7 @@ func (m *MsgConnectionOpenConfirm) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofAck", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2067,23 +2065,24 @@ func (m *MsgConnectionOpenConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofAck.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofAck = append(m.ProofAck[:0], dAtA[iNdEx:postIndex]...) + if m.ProofAck == nil { + m.ProofAck = []byte{} } iNdEx = postIndex case 3: diff --git a/x/ibc/03-connection/types/types.proto b/x/ibc/03-connection/types/types.proto index 4e729e2935..278846f1d4 100644 --- a/x/ibc/03-connection/types/types.proto +++ b/x/ibc/03-connection/types/types.proto @@ -23,12 +23,11 @@ message MsgConnectionOpenTry { Counterparty counterparty = 3 [(gogoproto.nullable) = false]; repeated string counterparty_versions = 4 [(gogoproto.moretags) = "yaml:\"counterparty_versions\""]; // proof of the initialization the connection on Chain A: `UNITIALIZED -> INIT` - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_init = 5 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_init\""]; + bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; uint64 proof_height = 6; // proof of client consensus state - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_consensus = 7 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_consensus\""]; + bytes proof_consensus = 7 + [(gogoproto.moretags) = "yaml:\"proof_consensus\""]; uint64 consensus_height = 8 [(gogoproto.moretags) = "yaml:\"consensus_height\""]; bytes signer = 9 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -39,12 +38,12 @@ message MsgConnectionOpenAck { string connection_id = 1 [(gogoproto.customname) = "ConnectionID", (gogoproto.moretags) = "yaml:\"connection_id\""]; string version = 2; // proof of the initialization the connection on Chain B: `UNITIALIZED -> TRYOPEN` - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_try = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_try\""]; + bytes proof_try = 3 + [(gogoproto.moretags) = "yaml:\"proof_try\""]; uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; // proof of client consensus state - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_consensus = 5 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_consensus\""]; + bytes proof_consensus = 5 + [(gogoproto.moretags) = "yaml:\"proof_consensus\""]; uint64 consensus_height = 6 [(gogoproto.moretags) = "yaml:\"consensus_height\""]; bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -54,8 +53,8 @@ message MsgConnectionOpenAck { message MsgConnectionOpenConfirm { string connection_id = 1 [(gogoproto.customname) = "ConnectionID", (gogoproto.moretags) = "yaml:\"connection_id\""]; // proof for the change of the connection state on Chain A: `INIT -> OPEN` - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_ack = 2 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_ack\""]; + bytes proof_ack = 2 + [(gogoproto.moretags) = "yaml:\"proof_ack\""]; uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } diff --git a/x/ibc/04-channel/client/rest/rest.go b/x/ibc/04-channel/client/rest/rest.go index 807dcbd4e0..fc7c62cf28 100644 --- a/x/ibc/04-channel/client/rest/rest.go +++ b/x/ibc/04-channel/client/rest/rest.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) const ( @@ -34,32 +33,32 @@ type ChannelOpenInitReq struct { // ChannelOpenTryReq defines the properties of a channel open try request's body. type ChannelOpenTryReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - PortID string `json:"port_id" yaml:"port_id"` - ChannelID string `json:"channel_id" yaml:"channel_id"` - Version string `json:"version" yaml:"version"` - ChannelOrder types.Order `json:"channel_order" yaml:"channel_order"` - ConnectionHops []string `json:"connection_hops" yaml:"connection_hops"` - CounterpartyPortID string `json:"counterparty_port_id" yaml:"counterparty_port_id"` - CounterpartyChannelID string `json:"counterparty_channel_id" yaml:"counterparty_channel_id"` - CounterpartyVersion string `json:"counterparty_version" yaml:"counterparty_version"` - ProofInit commitmenttypes.MerkleProof `json:"proof_init" yaml:"proof_init"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + PortID string `json:"port_id" yaml:"port_id"` + ChannelID string `json:"channel_id" yaml:"channel_id"` + Version string `json:"version" yaml:"version"` + ChannelOrder types.Order `json:"channel_order" yaml:"channel_order"` + ConnectionHops []string `json:"connection_hops" yaml:"connection_hops"` + CounterpartyPortID string `json:"counterparty_port_id" yaml:"counterparty_port_id"` + CounterpartyChannelID string `json:"counterparty_channel_id" yaml:"counterparty_channel_id"` + CounterpartyVersion string `json:"counterparty_version" yaml:"counterparty_version"` + ProofInit []byte `json:"proof_init" yaml:"proof_init"` + ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` } // ChannelOpenAckReq defines the properties of a channel open ack request's body. type ChannelOpenAckReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - CounterpartyVersion string `json:"counterparty_version" yaml:"counterparty_version"` - ProofTry commitmenttypes.MerkleProof `json:"proof_try" yaml:"proof_try"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + CounterpartyVersion string `json:"counterparty_version" yaml:"counterparty_version"` + ProofTry []byte `json:"proof_try" yaml:"proof_try"` + ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` } // ChannelOpenConfirmReq defines the properties of a channel open confirm request's body. type ChannelOpenConfirmReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ProofAck commitmenttypes.MerkleProof `json:"proof_ack" yaml:"proof_ack"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + ProofAck []byte `json:"proof_ack" yaml:"proof_ack"` + ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` } // ConnectionOpenInitReq defines the properties of a channel close init request's body. @@ -69,15 +68,15 @@ type ChannelCloseInitReq struct { // ChannelCloseConfirmReq defines the properties of a channel close confirm request's body. type ChannelCloseConfirmReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ProofInit commitmenttypes.MerkleProof `json:"proof_init" yaml:"proof_init"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + ProofInit []byte `json:"proof_init" yaml:"proof_init"` + ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` } // RecvPacketReq defines the properties of a receive packet request's body. type RecvPacketReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Packet types.Packet `json:"packet" yaml:"packet"` - Proofs commitmenttypes.MerkleProof `json:"proofs" yaml:"proofs"` - Height uint64 `json:"height" yaml:"height"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + Packet types.Packet `json:"packet" yaml:"packet"` + Proofs []byte `json:"proofs" yaml:"proofs"` + Height uint64 `json:"height" yaml:"height"` } diff --git a/x/ibc/04-channel/keeper/handshake.go b/x/ibc/04-channel/keeper/handshake.go index a141ce315e..2aa683424e 100644 --- a/x/ibc/04-channel/keeper/handshake.go +++ b/x/ibc/04-channel/keeper/handshake.go @@ -9,7 +9,6 @@ import ( connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -92,7 +91,7 @@ func (k Keeper) ChanOpenTry( counterparty types.Counterparty, version, counterpartyVersion string, - proofInit commitmentexported.Proof, + proofInit []byte, proofHeight uint64, ) (*capability.Capability, error) { // channel identifier and connection hop length checked on msg.ValidateBasic() @@ -170,7 +169,7 @@ func (k Keeper) ChanOpenAck( channelID string, chanCap *capability.Capability, counterpartyVersion string, - proofTry commitmentexported.Proof, + proofTry []byte, proofHeight uint64, ) error { channel, found := k.GetChannel(ctx, portID, channelID) @@ -237,7 +236,7 @@ func (k Keeper) ChanOpenConfirm( portID, channelID string, chanCap *capability.Capability, - proofAck commitmentexported.Proof, + proofAck []byte, proofHeight uint64, ) error { channel, found := k.GetChannel(ctx, portID, channelID) @@ -348,7 +347,7 @@ func (k Keeper) ChanCloseConfirm( portID, channelID string, chanCap *capability.Capability, - proofInit commitmentexported.Proof, + proofInit []byte, proofHeight uint64, ) error { if !k.scopedKeeper.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) { diff --git a/x/ibc/04-channel/keeper/keeper_test.go b/x/ibc/04-channel/keeper/keeper_test.go index 6884595006..f2b8f51a5d 100644 --- a/x/ibc/04-channel/keeper/keeper_test.go +++ b/x/ibc/04-channel/keeper/keeper_test.go @@ -299,7 +299,7 @@ func commitBlockWithNewTimestamp(chain *TestChain, timestamp int64) { } // nolint: unused -func queryProof(chain *TestChain, key []byte) (commitmenttypes.MerkleProof, uint64) { +func queryProof(chain *TestChain, key []byte) ([]byte, uint64) { res := chain.App.Query(abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", host.StoreKey), Height: chain.App.LastBlockHeight(), @@ -307,10 +307,12 @@ func queryProof(chain *TestChain, key []byte) (commitmenttypes.MerkleProof, uint Prove: true, }) - proof := commitmenttypes.MerkleProof{ + merkleProof := commitmenttypes.MerkleProof{ Proof: res.Proof, } + proof, _ := chain.App.AppCodec().MarshalBinaryBare(&merkleProof) + return proof, uint64(res.Height) } diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index e14e51579a..cf20dc9b43 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -12,7 +12,6 @@ import ( connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -141,7 +140,7 @@ func (k Keeper) SendPacket( func (k Keeper) RecvPacket( ctx sdk.Context, packet exported.PacketI, - proof commitmentexported.Proof, + proof []byte, proofHeight uint64, ) (exported.PacketI, error) { channel, found := k.GetChannel(ctx, packet.GetDestPort(), packet.GetDestChannel()) @@ -312,7 +311,7 @@ func (k Keeper) AcknowledgePacket( ctx sdk.Context, packet exported.PacketI, acknowledgement []byte, - proof commitmentexported.Proof, + proof []byte, proofHeight uint64, ) (exported.PacketI, error) { channel, found := k.GetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) @@ -463,7 +462,7 @@ func (k Keeper) CleanupPacket( ctx sdk.Context, chanCap *capability.Capability, packet exported.PacketI, - proof commitmentexported.Proof, + proof []byte, proofHeight, nextSequenceRecv uint64, acknowledgement []byte, diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index 9efcd3710b..fc8870b3be 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -8,7 +8,6 @@ import ( connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -521,7 +520,7 @@ func (suite *KeeperTestSuite) TestCleanupPacket() { for i, tc := range testCases { tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { - var proof commitmentexported.Proof + var proof []byte var proofHeight uint64 suite.SetupTest() // reset diff --git a/x/ibc/04-channel/keeper/timeout.go b/x/ibc/04-channel/keeper/timeout.go index 1a402ae511..959892b878 100644 --- a/x/ibc/04-channel/keeper/timeout.go +++ b/x/ibc/04-channel/keeper/timeout.go @@ -10,7 +10,6 @@ import ( connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -23,7 +22,7 @@ import ( func (k Keeper) TimeoutPacket( ctx sdk.Context, packet exported.PacketI, - proof commitmentexported.Proof, + proof []byte, proofHeight, nextSequenceRecv uint64, ) (exported.PacketI, error) { @@ -170,7 +169,7 @@ func (k Keeper) TimeoutOnClose( chanCap *capability.Capability, packet exported.PacketI, proof, - proofClosed commitmentexported.Proof, + proofClosed []byte, proofHeight, nextSequenceRecv uint64, ) (exported.PacketI, error) { diff --git a/x/ibc/04-channel/keeper/timeout_test.go b/x/ibc/04-channel/keeper/timeout_test.go index deb5c52a58..5857dc0731 100644 --- a/x/ibc/04-channel/keeper/timeout_test.go +++ b/x/ibc/04-channel/keeper/timeout_test.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/capability" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) @@ -242,7 +241,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { for i, tc := range testCases { tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { - var proof commitmentexported.Proof + var proof []byte suite.SetupTest() // reset tc.malleate() diff --git a/x/ibc/04-channel/types/expected_keepers.go b/x/ibc/04-channel/types/expected_keepers.go index e2599b80d2..6df8ad51fc 100644 --- a/x/ibc/04-channel/types/expected_keepers.go +++ b/x/ibc/04-channel/types/expected_keepers.go @@ -7,7 +7,6 @@ import ( connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" ) // ClientKeeper expected account IBC client keeper @@ -27,7 +26,7 @@ type ConnectionKeeper interface { ctx sdk.Context, connection connectionexported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, channel exported.ChannelI, @@ -36,7 +35,7 @@ type ConnectionKeeper interface { ctx sdk.Context, connection connectionexported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -46,7 +45,7 @@ type ConnectionKeeper interface { ctx sdk.Context, connection connectionexported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -56,7 +55,7 @@ type ConnectionKeeper interface { ctx sdk.Context, connection connectionexported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, @@ -65,7 +64,7 @@ type ConnectionKeeper interface { ctx sdk.Context, connection connectionexported.ConnectionI, height uint64, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, nextSequenceRecv uint64, diff --git a/x/ibc/04-channel/types/msgs.go b/x/ibc/04-channel/types/msgs.go index 6c038f5ac3..e52b83b8ef 100644 --- a/x/ibc/04-channel/types/msgs.go +++ b/x/ibc/04-channel/types/msgs.go @@ -65,7 +65,7 @@ var _ sdk.Msg = &MsgChannelOpenTry{} func NewMsgChannelOpenTry( portID, channelID, version string, channelOrder Order, connectionHops []string, counterpartyPortID, counterpartyChannelID, counterpartyVersion string, - proofInit commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, + proofInit []byte, proofHeight uint64, signer sdk.AccAddress, ) *MsgChannelOpenTry { counterparty := NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := NewChannel(INIT, channelOrder, counterparty, connectionHops, version) @@ -101,11 +101,8 @@ func (msg MsgChannelOpenTry) ValidateBasic() error { if strings.TrimSpace(msg.CounterpartyVersion) == "" { return sdkerrors.Wrap(ErrInvalidCounterparty, "counterparty version cannot be blank") } - if msg.ProofInit.Empty() { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") - } - if err := msg.ProofInit.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof init cannot be nil") + if len(msg.ProofInit) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof init") } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") @@ -128,7 +125,7 @@ var _ sdk.Msg = &MsgChannelOpenAck{} // NewMsgChannelOpenAck creates a new MsgChannelOpenAck instance func NewMsgChannelOpenAck( - portID, channelID string, cpv string, proofTry commitmenttypes.MerkleProof, proofHeight uint64, + portID, channelID string, cpv string, proofTry []byte, proofHeight uint64, signer sdk.AccAddress, ) *MsgChannelOpenAck { return &MsgChannelOpenAck{ @@ -162,11 +159,8 @@ func (msg MsgChannelOpenAck) ValidateBasic() error { if strings.TrimSpace(msg.CounterpartyVersion) == "" { return sdkerrors.Wrap(ErrInvalidCounterparty, "counterparty version cannot be blank") } - if msg.ProofTry.Empty() { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") - } - if err := msg.ProofTry.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof try cannot be nil") + if len(msg.ProofTry) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof try") } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") @@ -189,7 +183,7 @@ var _ sdk.Msg = &MsgChannelOpenConfirm{} // NewMsgChannelOpenConfirm creates a new MsgChannelOpenConfirm instance func NewMsgChannelOpenConfirm( - portID, channelID string, proofAck commitmenttypes.MerkleProof, proofHeight uint64, + portID, channelID string, proofAck []byte, proofHeight uint64, signer sdk.AccAddress, ) *MsgChannelOpenConfirm { return &MsgChannelOpenConfirm{ @@ -219,11 +213,8 @@ func (msg MsgChannelOpenConfirm) ValidateBasic() error { if err := host.ChannelIdentifierValidator(msg.ChannelID); err != nil { return sdkerrors.Wrap(err, "invalid channel ID") } - if msg.ProofAck.Empty() { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") - } - if err := msg.ProofAck.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof ack cannot be nil") + if len(msg.ProofAck) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof ack") } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") @@ -291,7 +282,7 @@ var _ sdk.Msg = &MsgChannelCloseConfirm{} // NewMsgChannelCloseConfirm creates a new MsgChannelCloseConfirm instance func NewMsgChannelCloseConfirm( - portID, channelID string, proofInit commitmenttypes.MerkleProof, proofHeight uint64, + portID, channelID string, proofInit []byte, proofHeight uint64, signer sdk.AccAddress, ) *MsgChannelCloseConfirm { return &MsgChannelCloseConfirm{ @@ -321,11 +312,8 @@ func (msg MsgChannelCloseConfirm) ValidateBasic() error { if err := host.ChannelIdentifierValidator(msg.ChannelID); err != nil { return sdkerrors.Wrap(err, "invalid channel ID") } - if msg.ProofInit.Empty() { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") - } - if err := msg.ProofInit.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof init cannot be nil") + if len(msg.ProofInit) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof init") } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") @@ -348,7 +336,7 @@ var _ sdk.Msg = &MsgPacket{} // NewMsgPacket constructs new MsgPacket func NewMsgPacket( - packet Packet, proof commitmenttypes.MerkleProof, proofHeight uint64, + packet Packet, proof []byte, proofHeight uint64, signer sdk.AccAddress, ) *MsgPacket { return &MsgPacket{ @@ -366,12 +354,9 @@ func (msg MsgPacket) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgPacket) ValidateBasic() error { - if msg.Proof.Empty() { + if len(msg.Proof) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } - if err := msg.Proof.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof ack cannot be nil") - } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") } @@ -408,7 +393,7 @@ var _ sdk.Msg = &MsgTimeout{} // NewMsgTimeout constructs new MsgTimeout func NewMsgTimeout( - packet Packet, nextSequenceRecv uint64, proof commitmenttypes.MerkleProof, + packet Packet, nextSequenceRecv uint64, proof []byte, proofHeight uint64, signer sdk.AccAddress, ) *MsgTimeout { return &MsgTimeout{ @@ -427,12 +412,9 @@ func (msg MsgTimeout) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgTimeout) ValidateBasic() error { - if msg.Proof.Empty() { + if len(msg.Proof) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } - if err := msg.Proof.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof ack cannot be nil") - } if msg.ProofHeight == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be > 0") } @@ -462,7 +444,7 @@ var _ sdk.Msg = &MsgAcknowledgement{} // NewMsgAcknowledgement constructs a new MsgAcknowledgement func NewMsgAcknowledgement( - packet Packet, ack []byte, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) *MsgAcknowledgement { + packet Packet, ack []byte, proof []byte, proofHeight uint64, signer sdk.AccAddress) *MsgAcknowledgement { return &MsgAcknowledgement{ Packet: packet, Acknowledgement: ack, @@ -479,12 +461,9 @@ func (msg MsgAcknowledgement) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgAcknowledgement) ValidateBasic() error { - if msg.Proof.Empty() { + if len(msg.Proof) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } - if err := msg.Proof.ValidateBasic(); err != nil { - return sdkerrors.Wrap(err, "proof ack cannot be nil") - } if len(msg.Acknowledgement) > 100 { return sdkerrors.Wrap(ErrAcknowledgementTooLong, "acknowledgement cannot exceed 100 bytes") } diff --git a/x/ibc/04-channel/types/msgs_test.go b/x/ibc/04-channel/types/msgs_test.go index 7dcc4a62fc..d737eaf4f4 100644 --- a/x/ibc/04-channel/types/msgs_test.go +++ b/x/ibc/04-channel/types/msgs_test.go @@ -4,13 +4,12 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/merkle" dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/rootmulti" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -37,23 +36,45 @@ const ( // define variables used for testing var ( + timeoutHeight = uint64(100) + timeoutTimestamp = uint64(100) + disabledTimeout = uint64(0) + validPacketData = []byte("testdata") + unknownPacketData = []byte("unknown") + invalidAckData = []byte("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890") + + packet = types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) + unknownPacket = types.NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) + invalidAck = invalidAckData + + emptyProof = []byte{} + invalidProofs1 = commitmentexported.Proof(nil) + invalidProofs2 = emptyProof + + addr1 = sdk.AccAddress("testaddr1") + emptyAddr sdk.AccAddress + + portid = "testportid" + chanid = "testchannel" + cpportid = "testcpport" + cpchanid = "testcpchannel" + connHops = []string{"testconnection"} invalidConnHops = []string{"testconnection", "testconnection"} invalidShortConnHops = []string{invalidShortConnection} invalidLongConnHops = []string{invalidLongConnection} - proof = commitmenttypes.MerkleProof{Proof: &merkle.Proof{Ops: []merkle.ProofOp{{Type: "proof", Key: []byte("key"), Data: []byte("data")}}}} - addr = sdk.AccAddress("testaddr") ) type MsgTestSuite struct { suite.Suite - proof commitmenttypes.MerkleProof + proof []byte } func (suite *MsgTestSuite) SetupTest() { + app := simapp.Setup(false) db := dbm.NewMemDB() store := rootmulti.NewStore(db) storeKey := storetypes.NewKVStoreKey("iavlStoreKey") @@ -71,7 +92,11 @@ func (suite *MsgTestSuite) SetupTest() { Prove: true, }) - suite.proof = commitmenttypes.MerkleProof{Proof: res.Proof} + merkleProof := commitmenttypes.MerkleProof{Proof: res.Proof} + proof, err := app.AppCodec().MarshalBinaryBare(&merkleProof) + suite.NoError(err) + + suite.proof = proof } func TestMsgTestSuite(t *testing.T) { @@ -150,6 +175,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { types.NewMsgChannelOpenTry("testportid", "testchannel", "", types.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // empty channel version types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, invalidPort, "testcpchannel", "1.0", suite.proof, 1, addr), // invalid counterparty port id types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", invalidChannel, "1.0", suite.proof, 1, addr), // invalid counterparty channel id + types.NewMsgChannelOpenTry("testportid", "testchannel", "1.0", types.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", emptyProof, 1, addr), // empty proof } testCases := []struct { @@ -174,6 +200,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { {testMsgs[14], false, "empty channel version"}, {testMsgs[15], false, "invalid counterparty port id"}, {testMsgs[16], false, "invalid counterparty channel id"}, + {testMsgs[17], false, "empty proof"}, } for i, tc := range testCases { @@ -189,16 +216,16 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { // TestMsgChannelOpenAck tests ValidateBasic for MsgChannelOpenAck func (suite *MsgTestSuite) TestMsgChannelOpenAck() { testMsgs := []*types.MsgChannelOpenAck{ - types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 1, addr), // valid msg - types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, 1, addr), // too short port id - types.NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, 1, addr), // too long port id - types.NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha - types.NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, 1, addr), // too short channel id - types.NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, 1, addr), // too long channel id - types.NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, 1, addr), // channel id contains non-alpha - types.NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, 1, addr), // empty counterparty version - types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof - types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, addr), // proof height is zero + types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 1, addr), // valid msg + types.NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, 1, addr), // too short port id + types.NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, 1, addr), // too long port id + types.NewMsgChannelOpenAck(invalidPort, "testchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha + types.NewMsgChannelOpenAck("testportid", invalidShortChannel, "1.0", suite.proof, 1, addr), // too short channel id + types.NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, 1, addr), // too long channel id + types.NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, 1, addr), // channel id contains non-alpha + types.NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, 1, addr), // empty counterparty version + types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", emptyProof, 1, addr), // empty proof + types.NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, addr), // proof height is zero } testCases := []struct { @@ -231,15 +258,15 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() { // TestMsgChannelOpenConfirm tests ValidateBasic for MsgChannelOpenConfirm func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { testMsgs := []*types.MsgChannelOpenConfirm{ - types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg - types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id - types.NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id - types.NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha - types.NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id - types.NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id - types.NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha - types.NewMsgChannelOpenConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof - types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero + types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg + types.NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id + types.NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id + types.NewMsgChannelOpenConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha + types.NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id + types.NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id + types.NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha + types.NewMsgChannelOpenConfirm("testportid", "testchannel", emptyProof, 1, addr), // empty proof + types.NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero } testCases := []struct { @@ -307,15 +334,15 @@ func (suite *MsgTestSuite) TestMsgChannelCloseInit() { // TestMsgChannelCloseConfirm tests ValidateBasic for MsgChannelCloseConfirm func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { testMsgs := []*types.MsgChannelCloseConfirm{ - types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg - types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id - types.NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id - types.NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha - types.NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id - types.NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id - types.NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha - types.NewMsgChannelCloseConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof - types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero + types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg + types.NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id + types.NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id + types.NewMsgChannelCloseConfirm(invalidPort, "testchannel", suite.proof, 1, addr), // port id contains non-alpha + types.NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id + types.NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id + types.NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha + types.NewMsgChannelCloseConfirm("testportid", "testchannel", emptyProof, 1, addr), // empty proof + types.NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero } testCases := []struct { @@ -344,47 +371,21 @@ func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { } } -// define variables used for testing -var ( - timeoutHeight = uint64(100) - timeoutTimestamp = uint64(100) - disabledTimeout = uint64(0) - validPacketData = []byte("testdata") - unknownPacketData = []byte("unknown") - invalidAckData = []byte("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890") +// TestMsgPacketType tests Type for MsgPacket. +func (suite *MsgTestSuite) TestMsgPacketType() { + msg := types.NewMsgPacket(packet, suite.proof, 1, addr1) - packet = types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) - unknownPacket = types.NewPacket(unknownPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) - invalidAck = invalidAckData - - emptyProof = commitmenttypes.MerkleProof{Proof: nil} - invalidProofs1 = commitmentexported.Proof(nil) - invalidProofs2 = emptyProof - - addr1 = sdk.AccAddress("testaddr1") - emptyAddr sdk.AccAddress - - portid = "testportid" - chanid = "testchannel" - cpportid = "testcpport" - cpchanid = "testcpchannel" -) - -// TestMsgPacketType tests Type for MsgPacket -func TestMsgPacketType(t *testing.T) { - msg := types.NewMsgPacket(packet, proof, 1, addr1) - - require.Equal(t, []byte("testdata"), msg.Packet.GetData()) + suite.Equal("ics04/opaque", msg.Type()) } // TestMsgPacketValidation tests ValidateBasic for MsgPacket -func TestMsgPacketValidation(t *testing.T) { +func (suite *MsgTestSuite) TestMsgPacketValidation() { testMsgs := []*types.MsgPacket{ - types.NewMsgPacket(packet, proof, 1, addr1), // valid msg - types.NewMsgPacket(packet, proof, 0, addr1), // proof height is zero - types.NewMsgPacket(packet, invalidProofs2, 1, addr1), // proof contain empty proof - types.NewMsgPacket(packet, proof, 1, emptyAddr), // missing signer address - types.NewMsgPacket(unknownPacket, proof, 1, addr1), // unknown packet + types.NewMsgPacket(packet, suite.proof, 1, addr1), // valid msg + types.NewMsgPacket(packet, suite.proof, 0, addr1), // proof height is zero + types.NewMsgPacket(packet, emptyProof, 1, addr1), // empty proof + types.NewMsgPacket(packet, suite.proof, 1, emptyAddr), // missing signer address + types.NewMsgPacket(unknownPacket, suite.proof, 1, addr1), // unknown packet } testCases := []struct { @@ -402,42 +403,42 @@ func TestMsgPacketValidation(t *testing.T) { for i, tc := range testCases { err := tc.msg.ValidateBasic() if tc.expPass { - require.NoError(t, err, "Msg %d failed: %v", i, err) + suite.NoError(err, "Msg %d failed: %v", i, err) } else { - require.Error(t, err, "Invalid Msg %d passed: %s", i, tc.errMsg) + suite.Error(err, "Invalid Msg %d passed: %s", i, tc.errMsg) } } } // TestMsgPacketGetSignBytes tests GetSignBytes for MsgPacket -func TestMsgPacketGetSignBytes(t *testing.T) { - msg := types.NewMsgPacket(packet, proof, 1, addr1) +func (suite *MsgTestSuite) TestMsgPacketGetSignBytes() { + msg := types.NewMsgPacket(packet, suite.proof, 1, addr1) res := msg.GetSignBytes() expected := fmt.Sprintf( - `{"type":"ibc/channel/MsgPacket","value":{"packet":{"data":%s,"destination_channel":"testcpchannel","destination_port":"testcpport","sequence":"1","source_channel":"testchannel","source_port":"testportid","timeout_height":"100","timeout_timestamp":"100"},"proof":{"proof":{"ops":[{"data":"ZGF0YQ==","key":"a2V5","type":"proof"}]}},"proof_height":"1","signer":"cosmos1w3jhxarpv3j8yvg4ufs4x"}}`, + `{"type":"ibc/channel/MsgPacket","value":{"packet":{"data":%s,"destination_channel":"testcpchannel","destination_port":"testcpport","sequence":"1","source_channel":"testchannel","source_port":"testportid","timeout_height":"100","timeout_timestamp":"100"},"proof":"Co0BCi4KCmljczIzOmlhdmwSA0tFWRobChkKA0tFWRIFVkFMVUUaCwgBGAEgASoDAAICClsKDGljczIzOnNpbXBsZRIMaWF2bFN0b3JlS2V5Gj0KOwoMaWF2bFN0b3JlS2V5EiAcIiDXSHQRSvh/Wa07MYpTK0B4XtbaXtzxBED76xk0WhoJCAEYASABKgEA","proof_height":"1","signer":"cosmos1w3jhxarpv3j8yvg4ufs4x"}}`, string(msg.GetDataSignBytes()), ) - require.Equal(t, expected, string(res)) + suite.Equal(expected, string(res)) } // TestMsgPacketGetSigners tests GetSigners for MsgPacket -func TestMsgPacketGetSigners(t *testing.T) { - msg := types.NewMsgPacket(packet, proof, 1, addr1) +func (suite *MsgTestSuite) TestMsgPacketGetSigners() { + msg := types.NewMsgPacket(packet, suite.proof, 1, addr1) res := msg.GetSigners() expected := "[746573746164647231]" - require.Equal(t, expected, fmt.Sprintf("%v", res)) + suite.Equal(expected, fmt.Sprintf("%v", res)) } // TestMsgTimeout tests ValidateBasic for MsgTimeout func (suite *MsgTestSuite) TestMsgTimeout() { testMsgs := []*types.MsgTimeout{ - types.NewMsgTimeout(packet, 1, proof, 1, addr), - types.NewMsgTimeout(packet, 1, proof, 0, addr), - types.NewMsgTimeout(packet, 1, proof, 1, emptyAddr), + types.NewMsgTimeout(packet, 1, suite.proof, 1, addr), + types.NewMsgTimeout(packet, 1, suite.proof, 0, addr), + types.NewMsgTimeout(packet, 1, suite.proof, 1, emptyAddr), types.NewMsgTimeout(packet, 1, emptyProof, 1, addr), - types.NewMsgTimeout(unknownPacket, 1, proof, 1, addr), + types.NewMsgTimeout(unknownPacket, 1, suite.proof, 1, addr), } testCases := []struct { @@ -465,12 +466,12 @@ func (suite *MsgTestSuite) TestMsgTimeout() { // TestMsgAcknowledgement tests ValidateBasic for MsgAcknowledgement func (suite *MsgTestSuite) TestMsgAcknowledgement() { testMsgs := []*types.MsgAcknowledgement{ - types.NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, addr), - types.NewMsgAcknowledgement(packet, packet.GetData(), proof, 0, addr), - types.NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, emptyAddr), + types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 1, addr), + types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 0, addr), + types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, 1, emptyAddr), types.NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, 1, addr), - types.NewMsgAcknowledgement(unknownPacket, packet.GetData(), proof, 1, addr), - types.NewMsgAcknowledgement(packet, invalidAck, proof, 1, addr), + types.NewMsgAcknowledgement(unknownPacket, packet.GetData(), suite.proof, 1, addr), + types.NewMsgAcknowledgement(packet, invalidAck, suite.proof, 1, addr), } testCases := []struct { diff --git a/x/ibc/04-channel/types/types.pb.go b/x/ibc/04-channel/types/types.pb.go index 249db6e582..5bee9a4667 100644 --- a/x/ibc/04-channel/types/types.pb.go +++ b/x/ibc/04-channel/types/types.pb.go @@ -6,7 +6,6 @@ package types import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -176,7 +175,7 @@ type MsgChannelOpenTry struct { ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` Channel Channel `protobuf:"bytes,3,opt,name=channel,proto3" json:"channel"` CounterpartyVersion string `protobuf:"bytes,4,opt,name=counterparty_version,json=counterpartyVersion,proto3" json:"counterparty_version,omitempty" yaml:"counterparty_version"` - ProofInit types.MerkleProof `protobuf:"bytes,5,opt,name=proof_init,json=proofInit,proto3" json:"proof_init" yaml:"proof_init"` + ProofInit []byte `protobuf:"bytes,5,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty" yaml:"proof_init"` ProofHeight uint64 `protobuf:"varint,6,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,7,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -242,11 +241,11 @@ func (m *MsgChannelOpenTry) GetCounterpartyVersion() string { return "" } -func (m *MsgChannelOpenTry) GetProofInit() types.MerkleProof { +func (m *MsgChannelOpenTry) GetProofInit() []byte { if m != nil { return m.ProofInit } - return types.MerkleProof{} + return nil } func (m *MsgChannelOpenTry) GetProofHeight() uint64 { @@ -269,7 +268,7 @@ type MsgChannelOpenAck struct { PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` CounterpartyVersion string `protobuf:"bytes,3,opt,name=counterparty_version,json=counterpartyVersion,proto3" json:"counterparty_version,omitempty" yaml:"counterparty_version"` - ProofTry types.MerkleProof `protobuf:"bytes,4,opt,name=proof_try,json=proofTry,proto3" json:"proof_try" yaml:"proof_try"` + ProofTry []byte `protobuf:"bytes,4,opt,name=proof_try,json=proofTry,proto3" json:"proof_try,omitempty" yaml:"proof_try"` ProofHeight uint64 `protobuf:"varint,5,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -328,11 +327,11 @@ func (m *MsgChannelOpenAck) GetCounterpartyVersion() string { return "" } -func (m *MsgChannelOpenAck) GetProofTry() types.MerkleProof { +func (m *MsgChannelOpenAck) GetProofTry() []byte { if m != nil { return m.ProofTry } - return types.MerkleProof{} + return nil } func (m *MsgChannelOpenAck) GetProofHeight() uint64 { @@ -354,7 +353,7 @@ func (m *MsgChannelOpenAck) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAd type MsgChannelOpenConfirm struct { PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` - ProofAck types.MerkleProof `protobuf:"bytes,3,opt,name=proof_ack,json=proofAck,proto3" json:"proof_ack" yaml:"proof_ack"` + ProofAck []byte `protobuf:"bytes,3,opt,name=proof_ack,json=proofAck,proto3" json:"proof_ack,omitempty" yaml:"proof_ack"` ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -406,11 +405,11 @@ func (m *MsgChannelOpenConfirm) GetChannelID() string { return "" } -func (m *MsgChannelOpenConfirm) GetProofAck() types.MerkleProof { +func (m *MsgChannelOpenConfirm) GetProofAck() []byte { if m != nil { return m.ProofAck } - return types.MerkleProof{} + return nil } func (m *MsgChannelOpenConfirm) GetProofHeight() uint64 { @@ -494,7 +493,7 @@ func (m *MsgChannelCloseInit) GetSigner() github_com_cosmos_cosmos_sdk_types.Acc type MsgChannelCloseConfirm struct { PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` - ProofInit types.MerkleProof `protobuf:"bytes,3,opt,name=proof_init,json=proofInit,proto3" json:"proof_init" yaml:"proof_init"` + ProofInit []byte `protobuf:"bytes,3,opt,name=proof_init,json=proofInit,proto3" json:"proof_init,omitempty" yaml:"proof_init"` ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -546,11 +545,11 @@ func (m *MsgChannelCloseConfirm) GetChannelID() string { return "" } -func (m *MsgChannelCloseConfirm) GetProofInit() types.MerkleProof { +func (m *MsgChannelCloseConfirm) GetProofInit() []byte { if m != nil { return m.ProofInit } - return types.MerkleProof{} + return nil } func (m *MsgChannelCloseConfirm) GetProofHeight() uint64 { @@ -570,7 +569,7 @@ func (m *MsgChannelCloseConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types. // MsgPacket receives incoming IBC packet type MsgPacket struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` - Proof types.MerkleProof `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof"` + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` ProofHeight uint64 `protobuf:"varint,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -615,11 +614,11 @@ func (m *MsgPacket) GetPacket() Packet { return Packet{} } -func (m *MsgPacket) GetProof() types.MerkleProof { +func (m *MsgPacket) GetProof() []byte { if m != nil { return m.Proof } - return types.MerkleProof{} + return nil } func (m *MsgPacket) GetProofHeight() uint64 { @@ -639,7 +638,7 @@ func (m *MsgPacket) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { // MsgTimeout receives timed-out packet type MsgTimeout struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` - Proof types.MerkleProof `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof"` + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` ProofHeight uint64 `protobuf:"varint,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` NextSequenceRecv uint64 `protobuf:"varint,4,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty" yaml:"next_sequence_recv"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` @@ -685,11 +684,11 @@ func (m *MsgTimeout) GetPacket() Packet { return Packet{} } -func (m *MsgTimeout) GetProof() types.MerkleProof { +func (m *MsgTimeout) GetProof() []byte { if m != nil { return m.Proof } - return types.MerkleProof{} + return nil } func (m *MsgTimeout) GetProofHeight() uint64 { @@ -717,7 +716,7 @@ func (m *MsgTimeout) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { type MsgAcknowledgement struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` Acknowledgement []byte `protobuf:"bytes,2,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"` - Proof types.MerkleProof `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof"` + Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` ProofHeight uint64 `protobuf:"varint,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height,omitempty" yaml:"proof_height"` Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` } @@ -769,11 +768,11 @@ func (m *MsgAcknowledgement) GetAcknowledgement() []byte { return nil } -func (m *MsgAcknowledgement) GetProof() types.MerkleProof { +func (m *MsgAcknowledgement) GetProof() []byte { if m != nil { return m.Proof } - return types.MerkleProof{} + return nil } func (m *MsgAcknowledgement) GetProofHeight() uint64 { @@ -958,87 +957,84 @@ func init() { } var fileDescriptor_a69005b45bd92d03 = []byte{ - // 1265 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x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x80, 0x88, 0xf3, 0x95, 0x19, 0x25, 0x37, 0x73, 0x7c, - 0x52, 0x88, 0xfb, 0x63, 0x94, 0x87, 0x79, 0x61, 0x69, 0xe2, 0x4f, 0x1a, 0xdb, 0xd5, 0x7a, 0x26, - 0x9a, 0x9b, 0x3d, 0x3e, 0x29, 0xa4, 0xa4, 0x38, 0x8c, 0xe4, 0xc6, 0x98, 0x88, 0xe4, 0x96, 0x2b, - 0x30, 0x27, 0x2c, 0x9b, 0x77, 0x1a, 0x3b, 0xd5, 0x4a, 0x26, 0x9e, 0x83, 0xe3, 0x93, 0x42, 0x52, - 0x48, 0xb9, 0xf8, 0xa3, 0x6f, 0xf3, 0x91, 0x6b, 0x0f, 0x20, 0xc1, 0x77, 0x3e, 0xba, 0x0a, 0x2b, - 0x0d, 0x5c, 0xa9, 0x62, 0xbd, 0xde, 0xa8, 0x57, 0xc7, 0xf0, 0xf2, 0x94, 0xbe, 0x1e, 0x69, 0xb0, - 0x28, 0xbc, 0xee, 0xd6, 0xf9, 0xb3, 0x5a, 0xc9, 0x28, 0xb9, 0xf9, 0xe3, 0x93, 0x42, 0x7a, 0xa0, - 0xf0, 0x01, 0x0b, 0x9f, 0xc0, 0x43, 0x02, 0x96, 0xa2, 0x98, 0xb8, 0xbc, 0xf5, 0xf8, 0x34, 0xaf, - 0x3c, 0x39, 0xcd, 0x2b, 0xbf, 0x9e, 0xe6, 0x95, 0x2f, 0x9e, 0xe6, 0x23, 0x4f, 0x9e, 0xe6, 0x23, - 0x3f, 0x3d, 0xcd, 0x47, 0xee, 0xdd, 0x38, 0xf7, 0xd8, 0x7c, 0xf6, 0x87, 0xa7, 0xdd, 0x24, 0xff, - 0x0e, 0x74, 0xe3, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xa1, 0x58, 0xd4, 0x99, 0x12, 0x00, - 0x00, + // 1219 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00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2, 0x19, 0x38, 0x3e, 0xc9, + 0xc5, 0x99, 0x94, 0x89, 0xbe, 0xf8, 0x36, 0x1b, 0xba, 0xf9, 0x0c, 0x62, 0xf4, 0xe4, 0xa3, 0x1b, + 0xb0, 0xd3, 0xc4, 0xd5, 0x1a, 0x96, 0x1b, 0xcd, 0x46, 0x6d, 0x26, 0x5f, 0x1a, 0xd2, 0xd3, 0x23, + 0x09, 0x36, 0x99, 0xd7, 0xe3, 0x06, 0x7d, 0xd6, 0xaa, 0x29, 0x21, 0xb3, 0x7e, 0x7c, 0x92, 0x4b, + 0x8e, 0x15, 0x5e, 0xc2, 0xcc, 0xc7, 0xf7, 0xe0, 0x09, 0x73, 0x91, 0xbd, 0xb8, 0xbc, 0xfb, 0xf2, + 0x34, 0x2b, 0xbc, 0x3a, 0xcd, 0x0a, 0xbf, 0x9d, 0x66, 0x85, 0x2f, 0x5e, 0x67, 0x43, 0xaf, 0x5e, + 0x67, 0x43, 0x3f, 0xbf, 0xce, 0x86, 0x9e, 0xdc, 0x9d, 0x7b, 0x6d, 0x9e, 0xff, 0xa7, 0xc7, 0x7e, + 0x9c, 0xfe, 0x55, 0x71, 0xf7, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0x7a, 0xc9, 0x51, 0x15, + 0x11, 0x00, 0x00, } func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { @@ -1127,16 +1123,13 @@ func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x30 } - { - size, err := m.ProofInit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofInit) > 0 { + i -= len(m.ProofInit) + copy(dAtA[i:], m.ProofInit) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofInit))) + i-- + dAtA[i] = 0x2a } - i-- - dAtA[i] = 0x2a if len(m.CounterpartyVersion) > 0 { i -= len(m.CounterpartyVersion) copy(dAtA[i:], m.CounterpartyVersion) @@ -1203,16 +1196,13 @@ func (m *MsgChannelOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - { - size, err := m.ProofTry.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofTry) > 0 { + i -= len(m.ProofTry) + copy(dAtA[i:], m.ProofTry) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofTry))) + i-- + dAtA[i] = 0x22 } - i-- - dAtA[i] = 0x22 if len(m.CounterpartyVersion) > 0 { i -= len(m.CounterpartyVersion) copy(dAtA[i:], m.CounterpartyVersion) @@ -1269,16 +1259,13 @@ func (m *MsgChannelOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - { - size, err := m.ProofAck.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofAck) > 0 { + i -= len(m.ProofAck) + copy(dAtA[i:], m.ProofAck) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofAck))) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if len(m.ChannelID) > 0 { i -= len(m.ChannelID) copy(dAtA[i:], m.ChannelID) @@ -1372,16 +1359,13 @@ func (m *MsgChannelCloseConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x20 } - { - size, err := m.ProofInit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ProofInit) > 0 { + i -= len(m.ProofInit) + copy(dAtA[i:], m.ProofInit) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ProofInit))) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if len(m.ChannelID) > 0 { i -= len(m.ChannelID) copy(dAtA[i:], m.ChannelID) @@ -1431,16 +1415,13 @@ func (m *MsgPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 { size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -1491,16 +1472,13 @@ func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 { size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -1546,16 +1524,13 @@ func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if len(m.Acknowledgement) > 0 { i -= len(m.Acknowledgement) copy(dAtA[i:], m.Acknowledgement) @@ -1799,8 +1774,10 @@ func (m *MsgChannelOpenTry) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.ProofInit.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofInit) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -1829,8 +1806,10 @@ func (m *MsgChannelOpenAck) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.ProofTry.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofTry) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -1855,8 +1834,10 @@ func (m *MsgChannelOpenConfirm) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.ProofAck.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofAck) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -1902,8 +1883,10 @@ func (m *MsgChannelCloseConfirm) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.ProofInit.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ProofInit) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -1922,8 +1905,10 @@ func (m *MsgPacket) Size() (n int) { _ = l l = m.Packet.Size() n += 1 + l + sovTypes(uint64(l)) - l = m.Proof.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -1942,8 +1927,10 @@ func (m *MsgTimeout) Size() (n int) { _ = l l = m.Packet.Size() n += 1 + l + sovTypes(uint64(l)) - l = m.Proof.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -1969,8 +1956,10 @@ func (m *MsgAcknowledgement) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.Proof.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.ProofHeight != 0 { n += 1 + sovTypes(uint64(m.ProofHeight)) } @@ -2415,7 +2404,7 @@ func (m *MsgChannelOpenTry) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2425,23 +2414,24 @@ func (m *MsgChannelOpenTry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofInit = append(m.ProofInit[:0], dAtA[iNdEx:postIndex]...) + if m.ProofInit == nil { + m.ProofInit = []byte{} } iNdEx = postIndex case 6: @@ -2650,7 +2640,7 @@ func (m *MsgChannelOpenAck) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofTry", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2660,23 +2650,24 @@ func (m *MsgChannelOpenAck) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofTry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofTry = append(m.ProofTry[:0], dAtA[iNdEx:postIndex]...) + if m.ProofTry == nil { + m.ProofTry = []byte{} } iNdEx = postIndex case 5: @@ -2853,7 +2844,7 @@ func (m *MsgChannelOpenConfirm) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofAck", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2863,23 +2854,24 @@ func (m *MsgChannelOpenConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofAck.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofAck = append(m.ProofAck[:0], dAtA[iNdEx:postIndex]...) + if m.ProofAck == nil { + m.ProofAck = []byte{} } iNdEx = postIndex case 4: @@ -3207,7 +3199,7 @@ func (m *MsgChannelCloseConfirm) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3217,23 +3209,24 @@ func (m *MsgChannelCloseConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ProofInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProofInit = append(m.ProofInit[:0], dAtA[iNdEx:postIndex]...) + if m.ProofInit == nil { + m.ProofInit = []byte{} } iNdEx = postIndex case 4: @@ -3379,7 +3372,7 @@ func (m *MsgPacket) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3389,23 +3382,24 @@ func (m *MsgPacket) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} } iNdEx = postIndex case 3: @@ -3551,7 +3545,7 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3561,23 +3555,24 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} } iNdEx = postIndex case 3: @@ -3776,7 +3771,7 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3786,23 +3781,24 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} } iNdEx = postIndex case 4: diff --git a/x/ibc/04-channel/types/types.proto b/x/ibc/04-channel/types/types.proto index a059a6268b..a9354017ee 100644 --- a/x/ibc/04-channel/types/types.proto +++ b/x/ibc/04-channel/types/types.proto @@ -4,7 +4,6 @@ package cosmos_sdk.x.ibc.channel.v1; option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"; import "third_party/proto/gogoproto/gogo.proto"; -import "x/ibc/23-commitment/types/types.proto"; // MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It is // called by a relayer on Chain A. @@ -22,8 +21,7 @@ message MsgChannelOpenTry { string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; Channel channel = 3 [(gogoproto.nullable) = false]; string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_init = 5 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_init\""]; + bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; uint64 proof_height = 6 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -34,8 +32,7 @@ message MsgChannelOpenAck { string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; string counterparty_version = 3 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_try = 4 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_try\""]; + bytes proof_try = 4 [(gogoproto.moretags) = "yaml:\"proof_try\""]; uint64 proof_height = 5 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 6 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -45,8 +42,7 @@ message MsgChannelOpenAck { message MsgChannelOpenConfirm { string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_ack = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_ack\""]; + bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""]; uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -64,8 +60,7 @@ message MsgChannelCloseInit { message MsgChannelCloseConfirm { string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof_init = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"proof_init\""]; + bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""]; uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -73,7 +68,7 @@ message MsgChannelCloseConfirm { // MsgPacket receives incoming IBC packet message MsgPacket { Packet packet = 1 [(gogoproto.nullable) = false]; - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof = 2 [(gogoproto.nullable) = false]; + bytes proof = 2; uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } @@ -81,7 +76,7 @@ message MsgPacket { // MsgTimeout receives timed-out packet message MsgTimeout { Packet packet = 1 [(gogoproto.nullable) = false]; - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof = 2 [(gogoproto.nullable) = false]; + bytes proof = 2; uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; @@ -91,7 +86,7 @@ message MsgTimeout { message MsgAcknowledgement { Packet packet = 1 [(gogoproto.nullable) = false]; bytes acknowledgement = 2; - cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof = 3 [(gogoproto.nullable) = false]; + bytes proof = 3; uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; } diff --git a/x/ibc/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index d4c6431ce3..8d07254772 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -150,16 +150,18 @@ func (cs ClientState) Validate() error { // Tendermint client stored on the target machine. func (cs ClientState) VerifyClientConsensusState( _ sdk.KVStore, - cdc *codec.Codec, + cdc codec.Marshaler, + aminoCdc *codec.Codec, provingRoot commitmentexported.Root, height uint64, counterpartyClientIdentifier string, consensusHeight uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, consensusState clientexported.ConsensusState, ) error { - if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil { + merkleProof, err := sanitizeVerificationArgs(cdc, cs, height, prefix, proof, consensusState) + if err != nil { return err } @@ -169,12 +171,12 @@ func (cs ClientState) VerifyClientConsensusState( return err } - bz, err := cdc.MarshalBinaryBare(consensusState) + bz, err := aminoCdc.MarshalBinaryBare(consensusState) if err != nil { return err } - if err := proof.VerifyMembership(provingRoot, path, bz); err != nil { + if err := merkleProof.VerifyMembership(provingRoot, path, bz); err != nil { return sdkerrors.Wrap(clienttypes.ErrFailedClientConsensusStateVerification, err.Error()) } @@ -188,12 +190,13 @@ func (cs ClientState) VerifyConnectionState( cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, connectionID string, connectionEnd connectionexported.ConnectionI, consensusState clientexported.ConsensusState, ) error { - if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil { + merkleProof, err := sanitizeVerificationArgs(cdc, cs, height, prefix, proof, consensusState) + if err != nil { return err } @@ -212,7 +215,7 @@ func (cs ClientState) VerifyConnectionState( return err } - if err := proof.VerifyMembership(consensusState.GetRoot(), path, bz); err != nil { + if err := merkleProof.VerifyMembership(consensusState.GetRoot(), path, bz); err != nil { return sdkerrors.Wrap(clienttypes.ErrFailedConnectionStateVerification, err.Error()) } @@ -226,13 +229,14 @@ func (cs ClientState) VerifyChannelState( cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, channel channelexported.ChannelI, consensusState clientexported.ConsensusState, ) error { - if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil { + merkleProof, err := sanitizeVerificationArgs(cdc, cs, height, prefix, proof, consensusState) + if err != nil { return err } @@ -251,7 +255,7 @@ func (cs ClientState) VerifyChannelState( return err } - if err := proof.VerifyMembership(consensusState.GetRoot(), path, bz); err != nil { + if err := merkleProof.VerifyMembership(consensusState.GetRoot(), path, bz); err != nil { return sdkerrors.Wrap(clienttypes.ErrFailedChannelStateVerification, err.Error()) } @@ -262,16 +266,18 @@ func (cs ClientState) VerifyChannelState( // the specified port, specified channel, and specified sequence. func (cs ClientState) VerifyPacketCommitment( _ sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, commitmentBytes []byte, consensusState clientexported.ConsensusState, ) error { - if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil { + merkleProof, err := sanitizeVerificationArgs(cdc, cs, height, prefix, proof, consensusState) + if err != nil { return err } @@ -280,7 +286,7 @@ func (cs ClientState) VerifyPacketCommitment( return err } - if err := proof.VerifyMembership(consensusState.GetRoot(), path, commitmentBytes); err != nil { + if err := merkleProof.VerifyMembership(consensusState.GetRoot(), path, commitmentBytes); err != nil { return sdkerrors.Wrap(clienttypes.ErrFailedPacketCommitmentVerification, err.Error()) } @@ -291,16 +297,18 @@ func (cs ClientState) VerifyPacketCommitment( // acknowledgement at the specified port, specified channel, and specified sequence. func (cs ClientState) VerifyPacketAcknowledgement( _ sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, acknowledgement []byte, consensusState clientexported.ConsensusState, ) error { - if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil { + merkleProof, err := sanitizeVerificationArgs(cdc, cs, height, prefix, proof, consensusState) + if err != nil { return err } @@ -309,7 +317,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( return err } - if err := proof.VerifyMembership(consensusState.GetRoot(), path, channeltypes.CommitAcknowledgement(acknowledgement)); err != nil { + if err := merkleProof.VerifyMembership(consensusState.GetRoot(), path, channeltypes.CommitAcknowledgement(acknowledgement)); err != nil { return sdkerrors.Wrap(clienttypes.ErrFailedPacketAckVerification, err.Error()) } @@ -321,15 +329,17 @@ func (cs ClientState) VerifyPacketAcknowledgement( // specified sequence. func (cs ClientState) VerifyPacketAcknowledgementAbsence( _ sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, sequence uint64, consensusState clientexported.ConsensusState, ) error { - if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil { + merkleProof, err := sanitizeVerificationArgs(cdc, cs, height, prefix, proof, consensusState) + if err != nil { return err } @@ -338,7 +348,7 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( return err } - if err := proof.VerifyNonMembership(consensusState.GetRoot(), path); err != nil { + if err := merkleProof.VerifyNonMembership(consensusState.GetRoot(), path); err != nil { return sdkerrors.Wrap(clienttypes.ErrFailedPacketAckAbsenceVerification, err.Error()) } @@ -349,15 +359,17 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( // received of the specified channel at the specified port. func (cs ClientState) VerifyNextSequenceRecv( _ sdk.KVStore, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, portID, channelID string, nextSequenceRecv uint64, consensusState clientexported.ConsensusState, ) error { - if err := validateVerificationArgs(cs, height, prefix, proof, consensusState); err != nil { + merkleProof, err := sanitizeVerificationArgs(cdc, cs, height, prefix, proof, consensusState) + if err != nil { return err } @@ -368,59 +380,60 @@ func (cs ClientState) VerifyNextSequenceRecv( bz := sdk.Uint64ToBigEndian(nextSequenceRecv) - if err := proof.VerifyMembership(consensusState.GetRoot(), path, bz); err != nil { + if err := merkleProof.VerifyMembership(consensusState.GetRoot(), path, bz); err != nil { return sdkerrors.Wrap(clienttypes.ErrFailedNextSeqRecvVerification, err.Error()) } return nil } -// validateVerificationArgs perfoms the basic checks on the arguments that are -// shared between the verification functions. -func validateVerificationArgs( +// sanitizeVerificationArgs perfoms the basic checks on the arguments that are +// shared between the verification functions and returns the unmarshalled +// merkle proof and an error if one occurred. +func sanitizeVerificationArgs( + cdc codec.Marshaler, cs ClientState, height uint64, prefix commitmentexported.Prefix, - proof commitmentexported.Proof, + proof []byte, consensusState clientexported.ConsensusState, -) error { +) (merkleProof commitmenttypes.MerkleProof, err error) { if cs.GetLatestHeight() < height { - return sdkerrors.Wrapf( + return commitmenttypes.MerkleProof{}, sdkerrors.Wrapf( sdkerrors.ErrInvalidHeight, "client state (%s) height < proof height (%d < %d)", cs.ID, cs.GetLatestHeight(), height, ) } if cs.IsFrozen() && cs.FrozenHeight <= height { - return clienttypes.ErrClientFrozen + return commitmenttypes.MerkleProof{}, clienttypes.ErrClientFrozen } if prefix == nil { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidPrefix, "prefix cannot be empty") + return commitmenttypes.MerkleProof{}, sdkerrors.Wrap(commitmenttypes.ErrInvalidPrefix, "prefix cannot be empty") } _, ok := prefix.(*commitmenttypes.MerklePrefix) if !ok { - return sdkerrors.Wrapf(commitmenttypes.ErrInvalidPrefix, "invalid prefix type %T, expected *MerklePrefix", prefix) + return commitmenttypes.MerkleProof{}, sdkerrors.Wrapf(commitmenttypes.ErrInvalidPrefix, "invalid prefix type %T, expected *MerklePrefix", prefix) } if proof == nil { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "proof cannot be empty") + return commitmenttypes.MerkleProof{}, sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "proof cannot be empty") } - _, ok = proof.(commitmenttypes.MerkleProof) - if !ok { - return sdkerrors.Wrapf(commitmenttypes.ErrInvalidProof, "invalid proof type %T, expected MerkleProof", proof) + if err = cdc.UnmarshalBinaryBare(proof, &merkleProof); err != nil { + return commitmenttypes.MerkleProof{}, sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "failed to unmarshal proof into commitment merkle proof") } if consensusState == nil { - return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be empty") + return commitmenttypes.MerkleProof{}, sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be empty") } _, ok = consensusState.(ConsensusState) if !ok { - return sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "invalid consensus type %T, expected %T", consensusState, ConsensusState{}) + return commitmenttypes.MerkleProof{}, sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "invalid consensus type %T, expected %T", consensusState, ConsensusState{}) } - return nil + return merkleProof, nil } diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index bb6f284c04..accb388d6b 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -78,7 +78,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { clientState ibctmtypes.ClientState consensusState ibctmtypes.ConsensusState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ // FIXME: uncomment @@ -126,7 +126,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { ValidatorSet: suite.valSet, }, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -135,7 +135,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { tc := tc err := tc.clientState.VerifyClientConsensusState( - nil, suite.aminoCdc, tc.consensusState.Root, height, "chainA", tc.consensusState.GetHeight(), tc.prefix, tc.proof, tc.consensusState, + nil, suite.cdc, suite.aminoCdc, tc.consensusState.Root, height, "chainA", tc.consensusState.GetHeight(), tc.prefix, tc.proof, tc.consensusState, ) if tc.expPass { @@ -156,7 +156,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { connection connection.End consensusState ibctmtypes.ConsensusState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ // FIXME: uncomment @@ -209,7 +209,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { ValidatorSet: suite.valSet, }, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -239,7 +239,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { channel channel.Channel consensusState ibctmtypes.ConsensusState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ // FIXME: uncomment @@ -292,7 +292,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { ValidatorSet: suite.valSet, }, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -319,7 +319,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { commitment []byte consensusState ibctmtypes.ConsensusState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ // FIXME: uncomment @@ -372,7 +372,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { ValidatorSet: suite.valSet, }, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -381,7 +381,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { tc := tc err := tc.clientState.VerifyPacketCommitment( - nil, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.commitment, tc.consensusState, + nil, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.commitment, tc.consensusState, ) if tc.expPass { @@ -399,7 +399,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { ack []byte consensusState ibctmtypes.ConsensusState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ // FIXME: uncomment @@ -452,7 +452,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { ValidatorSet: suite.valSet, }, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -461,7 +461,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { tc := tc err := tc.clientState.VerifyPacketAcknowledgement( - nil, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.ack, tc.consensusState, + nil, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.ack, tc.consensusState, ) if tc.expPass { @@ -478,7 +478,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { clientState ibctmtypes.ClientState consensusState ibctmtypes.ConsensusState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ // FIXME: uncomment @@ -527,7 +527,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { ValidatorSet: suite.valSet, }, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -536,7 +536,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { tc := tc err := tc.clientState.VerifyPacketAcknowledgementAbsence( - nil, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.consensusState, + nil, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.consensusState, ) if tc.expPass { @@ -553,7 +553,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { clientState ibctmtypes.ClientState consensusState ibctmtypes.ConsensusState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ // FIXME: uncomment @@ -602,7 +602,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { ValidatorSet: suite.valSet, }, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -611,7 +611,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { tc := tc err := tc.clientState.VerifyNextSequenceRecv( - nil, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.consensusState, + nil, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.consensusState, ) if tc.expPass { diff --git a/x/ibc/09-localhost/types/client_state.go b/x/ibc/09-localhost/types/client_state.go index ab613be1dd..35524fccfb 100644 --- a/x/ibc/09-localhost/types/client_state.go +++ b/x/ibc/09-localhost/types/client_state.go @@ -80,13 +80,14 @@ func (cs ClientState) Validate() error { // Tendermint client stored on the target machine. func (cs ClientState) VerifyClientConsensusState( store sdk.KVStore, - cdc *codec.Codec, + _ codec.Marshaler, + aminoCdc *codec.Codec, _ commitmentexported.Root, height uint64, _ string, consensusHeight uint64, prefix commitmentexported.Prefix, - _ commitmentexported.Proof, + _ []byte, consensusState clientexported.ConsensusState, ) error { path, err := commitmenttypes.ApplyPrefix(prefix, consensusStatePath(cs.GetID())) @@ -100,7 +101,7 @@ func (cs ClientState) VerifyClientConsensusState( } var prevConsensusState clientexported.ConsensusState - if err := cdc.UnmarshalBinaryBare(data, &prevConsensusState); err != nil { + if err := aminoCdc.UnmarshalBinaryBare(data, &prevConsensusState); err != nil { return err } @@ -121,7 +122,7 @@ func (cs ClientState) VerifyConnectionState( cdc codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, - _ commitmentexported.Proof, + _ []byte, connectionID string, connectionEnd connectionexported.ConnectionI, _ clientexported.ConsensusState, @@ -159,7 +160,7 @@ func (cs ClientState) VerifyChannelState( cdc codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, - _ commitmentexported.Proof, + _ []byte, portID, channelID string, channel channelexported.ChannelI, @@ -195,9 +196,10 @@ func (cs ClientState) VerifyChannelState( // the specified port, specified channel, and specified sequence. func (cs ClientState) VerifyPacketCommitment( store sdk.KVStore, + _ codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, - _ commitmentexported.Proof, + _ []byte, portID, channelID string, sequence uint64, @@ -228,9 +230,10 @@ func (cs ClientState) VerifyPacketCommitment( // acknowledgement at the specified port, specified channel, and specified sequence. func (cs ClientState) VerifyPacketAcknowledgement( store sdk.KVStore, + _ codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, - _ commitmentexported.Proof, + _ []byte, portID, channelID string, sequence uint64, @@ -262,9 +265,10 @@ func (cs ClientState) VerifyPacketAcknowledgement( // specified sequence. func (cs ClientState) VerifyPacketAcknowledgementAbsence( store sdk.KVStore, + _ codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, - _ commitmentexported.Proof, + _ []byte, portID, channelID string, sequence uint64, @@ -287,9 +291,10 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( // received of the specified channel at the specified port. func (cs ClientState) VerifyNextSequenceRecv( store sdk.KVStore, + _ codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, - _ commitmentexported.Proof, + _ []byte, portID, channelID string, nextSequenceRecv uint64, diff --git a/x/ibc/09-localhost/types/client_state_test.go b/x/ibc/09-localhost/types/client_state_test.go index 367d74c187..6835b31826 100644 --- a/x/ibc/09-localhost/types/client_state_test.go +++ b/x/ibc/09-localhost/types/client_state_test.go @@ -52,7 +52,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientConsensusState() { name string clientState types.ClientState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ { @@ -65,7 +65,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientConsensusState() { name: "proof verification failed", clientState: types.NewClientState("chainID", 10), prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -74,7 +74,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientConsensusState() { tc := tc err := tc.clientState.VerifyClientConsensusState( - suite.store, suite.aminoCdc, nil, height, "chainA", 0, tc.prefix, tc.proof, nil, + suite.store, suite.cdc, suite.aminoCdc, nil, height, "chainA", 0, tc.prefix, tc.proof, nil, ) if tc.expPass { @@ -94,7 +94,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() { clientState types.ClientState connection connection.End prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ { @@ -109,7 +109,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() { clientState: types.NewClientState("chainID", 10), connection: conn, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -138,7 +138,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { clientState types.ClientState channel channel.Channel prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ { @@ -160,7 +160,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { clientState: types.NewClientState("chainID", 10), channel: ch, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -186,7 +186,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketCommitment() { clientState types.ClientState commitment []byte prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ { @@ -215,7 +215,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketCommitment() { clientState: types.NewClientState("chainID", 10), commitment: []byte{}, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -224,7 +224,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketCommitment() { tc := tc err := tc.clientState.VerifyPacketCommitment( - suite.store, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.commitment, nil, + suite.store, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.commitment, nil, ) if tc.expPass { @@ -241,7 +241,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() { clientState types.ClientState ack []byte prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ { @@ -270,7 +270,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() { clientState: types.NewClientState("chainID", 10), ack: []byte{}, prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -279,7 +279,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() { tc := tc err := tc.clientState.VerifyPacketAcknowledgement( - suite.store, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.ack, nil, + suite.store, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, tc.ack, nil, ) if tc.expPass { @@ -295,7 +295,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgementAbsence() { name string clientState types.ClientState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ { @@ -310,7 +310,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgementAbsence() { tc := tc err := tc.clientState.VerifyPacketAcknowledgementAbsence( - suite.store, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, nil, + suite.store, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, nil, ) if tc.expPass { @@ -326,7 +326,7 @@ func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() { name string clientState types.ClientState prefix commitmenttypes.MerklePrefix - proof commitmenttypes.MerkleProof + proof []byte expPass bool }{ { @@ -351,7 +351,7 @@ func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() { name: "proof verification failed", clientState: types.NewClientState("chainID", 10), prefix: commitmenttypes.NewMerklePrefix([]byte("ibc")), - proof: commitmenttypes.MerkleProof{}, + proof: []byte{}, expPass: false, }, } @@ -360,7 +360,7 @@ func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() { tc := tc err := tc.clientState.VerifyNextSequenceRecv( - suite.store, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, nil, + suite.store, suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, testSequence, nil, ) if tc.expPass { diff --git a/x/ibc/ante/ante_test.go b/x/ibc/ante/ante_test.go index 727a82a751..f1117b9b26 100644 --- a/x/ibc/ante/ante_test.go +++ b/x/ibc/ante/ante_test.go @@ -60,19 +60,21 @@ func (suite *HandlerTestSuite) SetupTest() { suite.chainB.createConnection(testConnection, testConnection, testClientIDA, testClientIDB, connectiontypes.OPEN) } -func queryProof(chain *TestChain, key string) (proof commitmenttypes.MerkleProof, height int64) { +func queryProof(chain *TestChain, key string) ([]byte, int64) { res := chain.App.Query(abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", host.StoreKey), Data: []byte(key), Prove: true, }) - height = res.Height - proof = commitmenttypes.MerkleProof{ + height := res.Height + merkleProof := commitmenttypes.MerkleProof{ Proof: res.Proof, } - return + proof, _ := chain.App.AppCodec().MarshalBinaryBare(&merkleProof) + + return proof, height } func (suite *HandlerTestSuite) newTx(msg sdk.Msg) sdk.Tx { @@ -93,7 +95,7 @@ func (suite *HandlerTestSuite) TestHandleMsgPacketOrdered() { cctx, _ := ctx.CacheContext() // suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(ctx, packet.SourcePort, packet.SourceChannel, 1) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, packet.Sequence, channeltypes.CommitPacket(packet)) - msg := channel.NewMsgPacket(packet, commitmenttypes.MerkleProof{}, 0, addr1) + msg := channel.NewMsgPacket(packet, []byte{}, 0, addr1) _, err := handler(cctx, suite.newTx(msg), false) suite.Error(err, "%+v", err) // channel does not exist diff --git a/x/ibc/spec/04_messages.md b/x/ibc/spec/04_messages.md index 39be055e29..175615d6ca 100644 --- a/x/ibc/spec/04_messages.md +++ b/x/ibc/spec/04_messages.md @@ -17,7 +17,7 @@ type MsgCreateClient struct { ClientID string ClientType string ConsensusState ConsensusState - Signer AccAddress + Signer sdk.AccAddress } ``` @@ -41,7 +41,7 @@ A light client is updated with a new header using the `MsgUpdateClient`. type MsgUpdateClient struct { ClientID string Header Header - Signer AccAddress + Signer sdk.AccAddress } ``` @@ -59,6 +59,119 @@ height, commitment root and validator sets, which are then stored. ## ICS 03 - Connection +### MsgConnectionOpenInit + +A connection is initialized on a light client using the `MsgConnectionOpenInit`. + +```go +type MsgConnectionOpenInit struct { + ClientID string + ConnectionID string + Counterparty Counterparty + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `ClientID` is invalid (see naming requirements) +- `ConnectionID` is invalid (see naming requirements) +- `Counterparty` is empty +- `Signer` is empty +- A Client hasn't been created for the given ID +- A Connection for the given ID already exists + +The message creates a connection for the given ID with an INIT state. + +### MsgConnectionOpenTry + +When a counterparty connection is initialized then a connection is initialized on a light client +using the `MsgConnectionOpenTry`. + +```go +type MsgConnectionOpenTry struct { + ClientID string + ConnectionID string + Counterparty Counterparty + CounterpartyVersions []string + ProofInit []byte + ProofHeight uint64 + ProofConsensus []byte + ConsensusHeight uint64 + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `ClientID` is invalid (see naming requirements) +- `ConnectionID` is invalid (see naming requirements) +- `Counterparty` is empty +- `CounterpartyVersions` is empty +- `ProofInit` is empty +- `ProofHeight` is zero +- `ProofConsensus` is empty +- `ConsensusHeight` is zero +- `Signer` is empty +- A Client hasn't been created for the given ID +- A Connection for the given ID already exists +- `ProofInit` does not prove that the counterparty connection is in state INIT +- `ProofConsensus` does not prove that the counterparty has the correct consensus state for this chain + +The message creates a connection for the given ID with an TRYOPEN State. + +### MsgConnectionOpenAck + +When a counterparty connection is initialized then a connection is opened on a light client +using the `MsgConnectionOpenAck`. + +```go +type MsgConnectionOpenAck struct { + ConnectionID string + Version string + ProofTry []byte + ProofHeight uint64 + ProofConsensus []byte + ConsensusHeight uint64 + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `ConnectionID` is invalid (see naming requirements) +- `Version` is empty +- `ProofTry` is empty +- `ProofHeight` is zero +- `ProofConsensus` is empty +- `ConsensusHeight` is zero +- `Signer` is empty +- `ProofTry` does not prove that the counterparty connection is in state TRYOPEN +- `ProofConsensus` does not prove that the counterparty has the correct consensus state for this chain + +The message sets the connection state for the given ID to OPEN. + +### MsgConnectionOpenConfirm + +When a counterparty connection is opened then a connection is opened on a light client using +the `MsgConnectionOpenConfirm`. + +```go +type MsgConnectionOpenConfirm struct { + ConnectionID string + ProofAck []byte + ProofHeight uint64 + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `ConnectionID` is invalid (see naming requirements) +- `ProofAck` is empty +- `ProofHeight` is zero +- `Signer` is empty +- A Connection with the given ID does not exist +- `ProofAck` does not prove that the counterparty connection is in state OPEN + +The message sets the connection state for the given ID to OPEN. + ## ICS 04 - Channels ### MsgChannelOpenInit @@ -76,5 +189,138 @@ type MsgChannelOpenInit struct { ``` This message is expected to fail if: +- `PortID` is invalid (see naming requirements) +- `ChannelID` is invalid (see naming requirements) +- `Channel` is empty +- `Signer` is empty +- A Channel End exists for the given Channel ID and Port ID -## ICS 20 - Fungible Token Transfer +The message creates a channel on chain A with an INIT state for the given Channel ID +and Port ID. + +### MsgChannelOpenTry + +A channel handshake initialization attempt is acknowledged by a chain B using +the `MsgChannelOpenTry` message. + +```go +type MsgChannelOpenTry struct { + PortID string + ChannelID string + Channel Channel + CounterpartyVersion string + ProofInit []byte + ProofHeight uint64 + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `PortID` is invalid (see naming requirements) +- `ChannelID` is invalid (see naming requirements) +- `Channel` is empty +- `CounterpartyVersion` is empty +- `ProofInit` is empty +- `ProofHeight` is zero +- `Signer` is empty +- A Channel End exists for the given Channel and Port ID +- `ProofInit` does not prove that the counterparty's Channel state is in INIT + +The message creates a channel on chain B with an TRYOPEN state for the given Channel ID +and Port ID. + +### MsgChannelOpenAck + +A channel handshake is opened by a chain A using the `MsgChannelOpenAck` message. + +```go +type MsgChannelOpenAck struct { + PortID string + ChannelID string + CounterpartyVersion string + ProofTry []byte + ProofHeight uint64 + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `PortID` is invalid (see naming requirements) +- `ChannelID` is invalid (see naming requirements) +- `CounterpartyVersion` is empty +- `ProofTry` is empty +- `ProofHeight` is zero +- `Signer` is empty +- `ProofTry` does not prove that the counterparty's Channel state is in TRYOPEN + +The message sets a channel on chain A to state OPEN for the given Channel ID and Port ID. + +### MsgChannelOpenConfirm + +A channel handshake is confirmed and opened by a chain B using the `MsgChannelOpenConfirm` +message. + +```go +type MsgChannelOpenConfirm struct { + PortID string + ChannelID string + ProofAck []byte + ProofHeight uint64 + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `PortID` is invalid (see naming requirements) +- `ChannelID` is invalid (see naming requirements) +- `ProofAck` is empty +- `ProofHeight` is zero +- `Signer` is empty +- `ProofAck` does not prove that the counterparty's Channel state is in OPEN + +The message sets a channel on chain B to state OPEN for the given Channel ID and Port ID. + +### MsgChannelCloseInit + +A channel is closed on chain A using the `MsgChannelCloseInit`. + +```go +type MsgChannelCloseInit struct { + PortID string + ChannelID string + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `PortID` is invalid (see naming requirements) +- `ChannelID` is invalid (see naming requirements) +- `Signer` is empty +- A Channel for the given Port ID and Channel ID does not exist or is already closed + +The message closes a channel on chain A for the given Port ID and Channel ID. + +### MsgChannelCloseConfirm + +A channel is closed on chain B using the `MsgChannelCloseConfirm`. + +```go +type MsgChannelCloseConfirm struct { + PortID string + ChannelID string + ProofInit []byte + ProofHeight uint64 + Signer sdk.AccAddress +} +``` + +This message is expected to fail if: +- `PortID` is invalid (see naming requirements) +- `ChannelID` is invalid (see naming requirements) +- `ProofInit` is empty +- `ProofHeight` is zero +- `Signer` is empty +- A Channel for the given Port ID and Channel ID does not exist or is already closed +- `ProofInit` does not prove that the counterparty set its channel to state CLOSED + +The message closes a channel on chain B for the given Port ID and Channel ID. diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 8a46f9c986..780ea3ccc9 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -132,9 +132,9 @@ func (chain *TestChain) GetContext() sdk.Context { return chain.App.BaseApp.NewContext(false, chain.CurrentHeader) } -// QueryProof performs an abci query with the given key and returns the merkle proof for the query -// and the height at which the query was performed. -func (chain *TestChain) QueryProof(key []byte) (commitmenttypes.MerkleProof, uint64) { +// QueryProof performs an abci query with the given key and returns the proto encoded merkle proof +// for the query and the height at which the query was performed. +func (chain *TestChain) QueryProof(key []byte) ([]byte, uint64) { res := chain.App.Query(abci.RequestQuery{ Path: fmt.Sprintf("store/%s/key", host.StoreKey), Height: chain.App.LastBlockHeight(), @@ -142,10 +142,13 @@ func (chain *TestChain) QueryProof(key []byte) (commitmenttypes.MerkleProof, uin Prove: true, }) - proof := commitmenttypes.MerkleProof{ + merkleProof := commitmenttypes.MerkleProof{ Proof: res.Proof, } + proof, err := chain.App.AppCodec().MarshalBinaryBare(&merkleProof) + require.NoError(chain.t, err) + return proof, uint64(res.Height) }