diff --git a/simapp/app.go b/simapp/app.go index 97c4b4c1d96a..20bdcd1be0be 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -232,13 +232,15 @@ func NewSimApp( ) // Create IBC Keeper + // TODO: remove amino codec dependency once Tendermint version is upgraded with + // protobuf changes app.IBCKeeper = ibc.NewKeeper( - app.cdc, keys[ibc.StoreKey], app.StakingKeeper, scopedIBCKeeper, + app.cdc, appCodec, keys[ibc.StoreKey], app.StakingKeeper, scopedIBCKeeper, ) // Create Transfer Keepers app.TransferKeeper = transfer.NewKeeper( - app.cdc, keys[transfer.StoreKey], + appCodec, keys[transfer.StoreKey], app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, ) diff --git a/std/codec.pb.go b/std/codec.pb.go index 9f612475f724..f05db8eed67a 100644 --- a/std/codec.pb.go +++ b/std/codec.pb.go @@ -282,8 +282,8 @@ func (m *MsgSubmitProposal) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitProposal proto.InternalMessageInfo -// Proposal defines the application-level concrete proposal type used in governance -// proposals. +// Proposal defines the application-level concrete proposal type used in +// governance proposals. type Proposal struct { types3.ProposalBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` Content Content `protobuf:"bytes,2,opt,name=content,proto3" json:"content"` @@ -332,7 +332,8 @@ func (m *Proposal) GetContent() Content { // Content defines the application-level allowed Content to be included in a // governance proposal. type Content struct { - // sum defines a set of all acceptable concrete governance proposal Content types. + // sum defines a set of all acceptable concrete governance proposal Content + // types. // // Types that are valid to be assigned to Sum: // *Content_Text diff --git a/std/codec.proto b/std/codec.proto index 8f0bb11e7bbc..7e8dfe5812e7 100644 --- a/std/codec.proto +++ b/std/codec.proto @@ -52,8 +52,8 @@ message MsgSubmitProposal { Content content = 2; } -// Proposal defines the application-level concrete proposal type used in governance -// proposals. +// Proposal defines the application-level concrete proposal type used in +// governance proposals. message Proposal { option (gogoproto.equal) = true; @@ -67,7 +67,8 @@ message Content { option (gogoproto.equal) = true; option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/gov/types.Content"; - // sum defines a set of all acceptable concrete governance proposal Content types. + // sum defines a set of all acceptable concrete governance proposal Content + // types. oneof sum { cosmos_sdk.x.gov.v1.TextProposal text = 1; cosmos_sdk.x.params.v1.ParameterChangeProposal parameter_change = 2; diff --git a/x/evidence/types/expected_keepers.go b/x/evidence/types/expected_keepers.go index fc4b12247639..501371ce9a5d 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -3,10 +3,10 @@ package types import ( "time" + "github.com/tendermint/tendermint/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported" - - "github.com/tendermint/tendermint/crypto" ) type ( diff --git a/x/ibc/02-client/exported/exported.go b/x/ibc/02-client/exported/exported.go index 90e8b7a07300..e272d72027e6 100644 --- a/x/ibc/02-client/exported/exported.go +++ b/x/ibc/02-client/exported/exported.go @@ -35,7 +35,7 @@ type ClientState interface { consensusState ConsensusState, ) error VerifyConnectionState( - cdc *codec.Codec, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, proof commitmentexported.Proof, @@ -44,7 +44,7 @@ type ClientState interface { consensusState ConsensusState, ) error VerifyChannelState( - cdc *codec.Codec, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, proof commitmentexported.Proof, diff --git a/x/ibc/03-connection/alias.go b/x/ibc/03-connection/alias.go index 3479242d36c4..e902793bfe52 100644 --- a/x/ibc/03-connection/alias.go +++ b/x/ibc/03-connection/alias.go @@ -28,6 +28,7 @@ var ( QuerierConnections = keeper.QuerierConnections QuerierClientConnections = keeper.QuerierClientConnections RegisterCodec = types.RegisterCodec + RegisterInterfaces = types.RegisterInterfaces NewConnectionEnd = types.NewConnectionEnd NewCounterparty = types.NewCounterparty ErrConnectionExists = types.ErrConnectionExists diff --git a/x/ibc/03-connection/client/rest/rest.go b/x/ibc/03-connection/client/rest/rest.go index a3d3c5613de1..7d1a42f73b70 100644 --- a/x/ibc/03-connection/client/rest/rest.go +++ b/x/ibc/03-connection/client/rest/rest.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/types/rest" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" + commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) const ( @@ -21,42 +21,42 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, queryRoute string) // ConnectionOpenInitReq defines the properties of a connection open init request's body. type ConnectionOpenInitReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ConnectionID string `json:"connection_id" yaml:"connection_id"` - ClientID string `json:"client_id" yaml:"client_id"` - CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"` - CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"` - CounterpartyPrefix commitmentexported.Prefix `json:"counterparty_prefix" yaml:"counterparty_prefix"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + ConnectionID string `json:"connection_id" yaml:"connection_id"` + ClientID string `json:"client_id" yaml:"client_id"` + CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"` + CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"` + CounterpartyPrefix commitmenttypes.MerklePrefix `json:"counterparty_prefix" yaml:"counterparty_prefix"` } // ConnectionOpenTryReq defines the properties of a connection open try request's body. type ConnectionOpenTryReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ConnectionID string `json:"connection_id" yaml:"connection_id"` - ClientID string `json:"client_id" yaml:"client_id"` - CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"` - CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"` - CounterpartyPrefix commitmentexported.Prefix `json:"counterparty_prefix" yaml:"counterparty_prefix"` - CounterpartyVersions []string `json:"counterparty_versions" yaml:"counterparty_versions"` - ProofInit commitmentexported.Proof `json:"proof_init" yaml:"proof_init"` - ProofConsensus commitmentexported.Proof `json:"proof_consensus" yaml:"proof_consensus"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` - ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"` + BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` + ConnectionID string `json:"connection_id" yaml:"connection_id"` + ClientID string `json:"client_id" yaml:"client_id"` + CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"` + 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"` + 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 commitmentexported.Proof `json:"proof_try" yaml:"proof_try"` - ProofConsensus commitmentexported.Proof `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 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"` } // 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 commitmentexported.Proof `json:"proof_ack" yaml:"proof_ack"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + 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"` } diff --git a/x/ibc/03-connection/exported/exported.go b/x/ibc/03-connection/exported/exported.go index afd7f8f0c065..b4aaca158764 100644 --- a/x/ibc/03-connection/exported/exported.go +++ b/x/ibc/03-connection/exported/exported.go @@ -1,14 +1,13 @@ package exported import ( - "encoding/json" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) // ConnectionI describes the required methods for a connection. type ConnectionI interface { - GetState() State + GetState() ibctypes.State GetID() string GetClientID() string GetCounterparty() CounterpartyI @@ -23,68 +22,3 @@ type CounterpartyI interface { GetPrefix() commitmentexported.Prefix ValidateBasic() error } - -// State defines the state of a connection between two disctinct -// chains -type State byte - -// available connection states -const ( - UNINITIALIZED State = iota // default State - INIT - TRYOPEN - OPEN -) - -// string representation of the connection states -const ( - StateUninitialized string = "UNINITIALIZED" - StateInit string = "INIT" - StateTryOpen string = "TRYOPEN" - StateOpen string = "OPEN" -) - -// String implements the Stringer interface -func (s State) String() string { - switch s { - case INIT: - return StateInit - case TRYOPEN: - return StateTryOpen - case OPEN: - return StateOpen - default: - return StateUninitialized - } -} - -// StateFromString parses a string into a connection state -func StateFromString(state string) State { - switch state { - case StateInit: - return INIT - case StateTryOpen: - return TRYOPEN - case StateOpen: - return OPEN - default: - return UNINITIALIZED - } -} - -// MarshalJSON marshal to JSON using string. -func (s State) MarshalJSON() ([]byte, error) { - return json.Marshal(s.String()) -} - -// UnmarshalJSON decodes from JSON assuming Bech32 encoding. -func (s *State) UnmarshalJSON(data []byte) error { - var str string - err := json.Unmarshal(data, &str) - if err != nil { - return err - } - - *s = StateFromString(str) - return nil -} diff --git a/x/ibc/03-connection/exported/exported_test.go b/x/ibc/03-connection/exported/exported_test.go deleted file mode 100644 index c45dfe6cca2b..000000000000 --- a/x/ibc/03-connection/exported/exported_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package exported - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestConnectionStateString(t *testing.T) { - cases := []struct { - name string - state State - }{ - {StateUninitialized, UNINITIALIZED}, - {StateInit, INIT}, - {StateTryOpen, TRYOPEN}, - {StateOpen, OPEN}, - } - - for _, tt := range cases { - tt := tt - require.Equal(t, tt.state, StateFromString(tt.name)) - require.Equal(t, tt.name, tt.state.String()) - } -} - -func TestConnectionlStateMarshalJSON(t *testing.T) { - cases := []struct { - name string - state State - }{ - {StateUninitialized, UNINITIALIZED}, - {StateInit, INIT}, - {StateTryOpen, TRYOPEN}, - {StateOpen, OPEN}, - } - - for _, tt := range cases { - tt := tt - bz, err := tt.state.MarshalJSON() - require.NoError(t, err) - var state State - require.NoError(t, state.UnmarshalJSON(bz)) - require.Equal(t, tt.name, state.String()) - } -} diff --git a/x/ibc/03-connection/keeper/handshake.go b/x/ibc/03-connection/keeper/handshake.go index 4cf0ff2a28b6..64cac7628b51 100644 --- a/x/ibc/03-connection/keeper/handshake.go +++ b/x/ibc/03-connection/keeper/handshake.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" 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/exported" "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" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -28,7 +28,7 @@ func (k Keeper) ConnOpenInit( } // connection defines chain A's ConnectionEnd - connection := types.NewConnectionEnd(exported.INIT, connectionID, clientID, counterparty, types.GetCompatibleVersions()) + connection := types.NewConnectionEnd(ibctypes.INIT, connectionID, clientID, counterparty, types.GetCompatibleVersions()) k.SetConnection(ctx, connectionID, connection) if err := k.addConnectionToClient(ctx, clientID, connectionID); err != nil { @@ -68,15 +68,15 @@ func (k Keeper) ConnOpenTry( // expectedConnection defines Chain A's ConnectionEnd // NOTE: chain A's counterparty is chain B (i.e where this code is executed) prefix := k.GetCommitmentPrefix() - expectedCounterparty := types.NewCounterparty(clientID, connectionID, prefix) - expectedConnection := types.NewConnectionEnd(exported.INIT, counterparty.ConnectionID, counterparty.ClientID, expectedCounterparty, counterpartyVersions) + expectedCounterparty := types.NewCounterparty(clientID, connectionID, commitmenttypes.NewMerklePrefix(prefix.Bytes())) + expectedConnection := types.NewConnectionEnd(ibctypes.INIT, counterparty.ConnectionID, counterparty.ClientID, expectedCounterparty, counterpartyVersions) // chain B picks a version from Chain A's available versions that is compatible // with the supported IBC versions version := types.PickVersion(counterpartyVersions, types.GetCompatibleVersions()) // connection defines chain B's ConnectionEnd - connection := types.NewConnectionEnd(exported.UNINITIALIZED, connectionID, clientID, counterparty, []string{version}) + connection := types.NewConnectionEnd(ibctypes.UNINITIALIZED, connectionID, clientID, counterparty, []string{version}) // Check that ChainA committed expectedConnectionEnd to its state if err := k.VerifyConnectionState( @@ -97,7 +97,7 @@ func (k Keeper) ConnOpenTry( // is chainA and connection is on INIT stage // Check that existing connection version is on desired version of current handshake previousConnection, found := k.GetConnection(ctx, connectionID) - if found && !(previousConnection.State == exported.INIT && + if found && !(previousConnection.State == ibctypes.INIT && previousConnection.Counterparty.ConnectionID == counterparty.ConnectionID && bytes.Equal(previousConnection.Counterparty.Prefix.Bytes(), counterparty.Prefix.Bytes()) && previousConnection.ClientID == clientID && @@ -107,7 +107,7 @@ func (k Keeper) ConnOpenTry( } // Set connection state to TRYOPEN and store in chainB state - connection.State = exported.TRYOPEN + connection.State = ibctypes.TRYOPEN if err := k.addConnectionToClient(ctx, clientID, connectionID); err != nil { return sdkerrors.Wrap(err, "cannot relay connection attempt") } @@ -142,7 +142,7 @@ func (k Keeper) ConnOpenAck( } // Check connection on ChainA is on correct state: INIT - if connection.State != exported.INIT { + if connection.State != ibctypes.INIT { return sdkerrors.Wrapf( types.ErrInvalidConnectionState, "connection state is not INIT (got %s)", connection.State.String(), @@ -164,8 +164,8 @@ func (k Keeper) ConnOpenAck( } prefix := k.GetCommitmentPrefix() - expectedCounterparty := types.NewCounterparty(connection.ClientID, connectionID, prefix) - expectedConnection := types.NewConnectionEnd(exported.TRYOPEN, connection.Counterparty.ConnectionID, connection.Counterparty.ClientID, expectedCounterparty, []string{version}) + expectedCounterparty := types.NewCounterparty(connection.ClientID, connectionID, commitmenttypes.NewMerklePrefix(prefix.Bytes())) + expectedConnection := types.NewConnectionEnd(ibctypes.TRYOPEN, connection.Counterparty.ConnectionID, connection.Counterparty.ClientID, expectedCounterparty, []string{version}) // Ensure that ChainB stored expected connectionEnd in its state during ConnOpenTry if err := k.VerifyConnectionState( @@ -183,7 +183,7 @@ func (k Keeper) ConnOpenAck( } // Update connection state to Open - connection.State = exported.OPEN + connection.State = ibctypes.OPEN connection.Versions = []string{version} k.SetConnection(ctx, connectionID, connection) k.Logger(ctx).Info(fmt.Sprintf("connection %s state updated: INIT -> OPEN ", connectionID)) @@ -207,7 +207,7 @@ func (k Keeper) ConnOpenConfirm( } // Check that connection state on ChainB is on state: TRYOPEN - if connection.State != exported.TRYOPEN { + if connection.State != ibctypes.TRYOPEN { return sdkerrors.Wrapf( types.ErrInvalidConnectionState, "connection state is not TRYOPEN (got %s)", connection.State.String(), @@ -215,8 +215,8 @@ func (k Keeper) ConnOpenConfirm( } prefix := k.GetCommitmentPrefix() - expectedCounterparty := types.NewCounterparty(connection.ClientID, connectionID, prefix) - expectedConnection := types.NewConnectionEnd(exported.OPEN, connection.Counterparty.ConnectionID, connection.Counterparty.ClientID, expectedCounterparty, connection.Versions) + expectedCounterparty := types.NewCounterparty(connection.ClientID, connectionID, commitmenttypes.NewMerklePrefix(prefix.Bytes())) + expectedConnection := types.NewConnectionEnd(ibctypes.OPEN, connection.Counterparty.ConnectionID, connection.Counterparty.ClientID, expectedCounterparty, connection.Versions) // Check that connection on ChainA is open if err := k.VerifyConnectionState( @@ -227,7 +227,7 @@ func (k Keeper) ConnOpenConfirm( } // Update ChainB's connection to Open - connection.State = exported.OPEN + connection.State = ibctypes.OPEN k.SetConnection(ctx, connectionID, connection) k.Logger(ctx).Info(fmt.Sprintf("connection %s state updated: TRYOPEN -> OPEN ", connectionID)) return nil diff --git a/x/ibc/03-connection/keeper/handshake_test.go b/x/ibc/03-connection/keeper/handshake_test.go index 6c78915e842a..ccd2071f0b2d 100644 --- a/x/ibc/03-connection/keeper/handshake_test.go +++ b/x/ibc/03-connection/keeper/handshake_test.go @@ -4,7 +4,7 @@ import ( "fmt" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" - "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" + commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -20,12 +20,12 @@ func (suite *KeeperTestSuite) TestConnOpenInit() { suite.chainA.CreateClient(suite.chainB) }, true}, {"connection already exists", func() { - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.INIT) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.INIT) }, false}, {"couldn't add connection to client", func() {}, false}, } - counterparty := connection.NewCounterparty(testClientIDB, testConnectionIDB, suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) + counterparty := connection.NewCounterparty(testClientIDB, testConnectionIDB, commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) for i, tc := range testCases { tc := tc @@ -50,7 +50,7 @@ func (suite *KeeperTestSuite) TestConnOpenInit() { func (suite *KeeperTestSuite) TestConnOpenTry() { // counterparty for A on B counterparty := connection.NewCounterparty( - testClientIDB, testConnectionIDA, suite.chainB.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix(), + testClientIDB, testConnectionIDA, commitmenttypes.NewMerklePrefix(suite.chainB.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()), ) testCases := []struct { @@ -61,12 +61,12 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { {"success", func() uint64 { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.INIT) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.INIT) suite.chainB.updateClient(suite.chainA) suite.chainA.updateClient(suite.chainB) suite.chainB.updateClient(suite.chainA) suite.chainA.updateClient(suite.chainB) - return uint64(suite.chainB.Header.Height - 1) + return suite.chainB.Header.GetHeight() - 1 }, true}, {"consensus height > latest height", func() uint64 { return 0 @@ -78,29 +78,29 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { {"connection state verification invalid", func() uint64 { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.UNINITIALIZED) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.UNINITIALIZED) suite.chainB.updateClient(suite.chainA) return 0 }, false}, {"consensus state verification invalid", func() uint64 { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.INIT) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.INIT) suite.chainB.updateClient(suite.chainA) suite.chainA.updateClient(suite.chainB) - return uint64(suite.chainB.Header.Height) + return suite.chainB.Header.GetHeight() }, false}, {"invalid previous connection", func() uint64 { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, exported.UNINITIALIZED) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.UNINITIALIZED) suite.chainB.updateClient(suite.chainA) suite.chainA.updateClient(suite.chainB) return 0 }, false}, {"couldn't add connection to client", func() uint64 { suite.chainB.CreateClient(suite.chainA) - suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, exported.UNINITIALIZED) + suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, ibctypes.UNINITIALIZED) suite.chainB.updateClient(suite.chainA) suite.chainA.updateClient(suite.chainB) return 0 @@ -150,11 +150,11 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { {"success", version, func() uint64 { suite.chainA.CreateClient(suite.chainB) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, exported.TRYOPEN) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.INIT) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.TRYOPEN) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.INIT) suite.chainB.updateClient(suite.chainA) suite.chainA.updateClient(suite.chainB) - return uint64(suite.chainB.Header.Height) + return suite.chainB.Header.GetHeight() }, true}, {"consensus height > latest height", version, func() uint64 { return 10 @@ -163,38 +163,38 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { return 2 }, false}, {"connection state is not INIT", version, func() uint64 { - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.UNINITIALIZED) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.UNINITIALIZED) suite.chainB.updateClient(suite.chainA) - return uint64(suite.chainB.Header.Height) + return suite.chainB.Header.GetHeight() }, false}, {"incompatible IBC versions", "2.0", func() uint64 { - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.INIT) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.INIT) suite.chainB.updateClient(suite.chainA) - return uint64(suite.chainB.Header.Height) + return suite.chainB.Header.GetHeight() }, false}, {"self consensus state not found", version, func() uint64 { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.INIT) - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, exported.TRYOPEN) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.INIT) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.TRYOPEN) suite.chainB.updateClient(suite.chainA) - return uint64(suite.chainB.Header.Height) + return suite.chainB.Header.GetHeight() }, false}, {"connection state verification failed", version, func() uint64 { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.INIT) - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, exported.UNINITIALIZED) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.INIT) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.UNINITIALIZED) suite.chainB.updateClient(suite.chainA) - return uint64(suite.chainB.Header.Height) + return suite.chainB.Header.GetHeight() }, false}, {"consensus state verification failed", version, func() uint64 { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.INIT) - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, exported.UNINITIALIZED) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.INIT) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.UNINITIALIZED) suite.chainB.updateClient(suite.chainA) - return uint64(suite.chainB.Header.Height) + return suite.chainB.Header.GetHeight() }, false}, } @@ -233,22 +233,22 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() { {"success", func() { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.OPEN) - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, exported.TRYOPEN) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.TRYOPEN) suite.chainB.updateClient(suite.chainA) }, true}, {"connection not found", func() {}, false}, {"chain B's connection state is not TRYOPEN", func() { - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, exported.UNINITIALIZED) - suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, exported.OPEN) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, ibctypes.UNINITIALIZED) + suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, ibctypes.OPEN) suite.chainA.updateClient(suite.chainB) }, false}, {"connection state verification failed", func() { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) suite.chainB.updateClient(suite.chainA) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.INIT) - suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, exported.TRYOPEN) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.INIT) + suite.chainB.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, ibctypes.TRYOPEN) suite.chainA.updateClient(suite.chainA) }, false}, } diff --git a/x/ibc/03-connection/keeper/keeper.go b/x/ibc/03-connection/keeper/keeper.go index 446a74a9140a..5dfa17ec3da2 100644 --- a/x/ibc/03-connection/keeper/keeper.go +++ b/x/ibc/03-connection/keeper/keeper.go @@ -20,14 +20,16 @@ import ( // Keeper defines the IBC connection keeper type Keeper struct { storeKey sdk.StoreKey - cdc *codec.Codec + aminoCdc *codec.Codec // amino codec. TODO: remove after clients have been migrated to proto + cdc codec.Marshaler // hybrid codec clientKeeper types.ClientKeeper } // NewKeeper creates a new IBC connection Keeper instance -func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, ck types.ClientKeeper) Keeper { +func NewKeeper(aminoCdc *codec.Codec, cdc codec.Marshaler, key sdk.StoreKey, ck types.ClientKeeper) Keeper { return Keeper{ storeKey: key, + aminoCdc: aminoCdc, cdc: cdc, clientKeeper: ck, } @@ -54,13 +56,14 @@ func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.Conne var connection types.ConnectionEnd k.cdc.MustUnmarshalBinaryBare(bz, &connection) + return connection, true } // SetConnection sets a connection to the store func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection types.ConnectionEnd) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryBare(connection) + bz := k.cdc.MustMarshalBinaryBare(&connection) store.Set(ibctypes.KeyConnection(connectionID), bz) } @@ -90,15 +93,16 @@ func (k Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]st return nil, false } - var paths []string - k.cdc.MustUnmarshalBinaryBare(bz, &paths) - return paths, true + var clientPaths types.ClientPaths + k.cdc.MustUnmarshalBinaryBare(bz, &clientPaths) + return clientPaths.Paths, true } // SetClientConnectionPaths sets the connections paths for client func (k Keeper) SetClientConnectionPaths(ctx sdk.Context, clientID string, paths []string) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryBare(paths) + clientPaths := types.ClientPaths{Paths: paths} + bz := k.cdc.MustMarshalBinaryBare(&clientPaths) store.Set(ibctypes.KeyClientConnections(clientID), bz) } diff --git a/x/ibc/03-connection/keeper/keeper_test.go b/x/ibc/03-connection/keeper/keeper_test.go index 39bd2724fce5..2284209e0b73 100644 --- a/x/ibc/03-connection/keeper/keeper_test.go +++ b/x/ibc/03-connection/keeper/keeper_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/stretchr/testify/suite" + abci "github.com/tendermint/tendermint/abci/types" tmtypes "github.com/tendermint/tendermint/types" @@ -13,9 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" - "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" @@ -88,8 +87,8 @@ func (suite *KeeperTestSuite) TestSetAndGetConnection() { _, existed := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetConnection(suite.chainA.GetContext(), testConnectionIDA) suite.Require().False(existed) - counterparty := types.NewCounterparty(testClientIDA, testConnectionIDA, suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) - expConn := types.NewConnectionEnd(exported.INIT, testConnectionIDB, testClientIDB, counterparty, types.GetCompatibleVersions()) + counterparty := types.NewCounterparty(testClientIDA, testConnectionIDA, commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) + expConn := types.NewConnectionEnd(ibctypes.INIT, testConnectionIDB, testClientIDB, counterparty, types.GetCompatibleVersions()) suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), testConnectionIDA, expConn) conn, existed := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetConnection(suite.chainA.GetContext(), testConnectionIDA) suite.Require().True(existed) @@ -108,13 +107,13 @@ func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() { func (suite KeeperTestSuite) TestGetAllConnections() { // Connection (Counterparty): A(C) -> C(B) -> B(A) - counterparty1 := types.NewCounterparty(testClientIDA, testConnectionIDA, suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) - counterparty2 := types.NewCounterparty(testClientIDB, testConnectionIDB, suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) - counterparty3 := types.NewCounterparty(testClientID3, testConnectionID3, suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) + counterparty1 := types.NewCounterparty(testClientIDA, testConnectionIDA, commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) + counterparty2 := types.NewCounterparty(testClientIDB, testConnectionIDB, commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) + counterparty3 := types.NewCounterparty(testClientID3, testConnectionID3, commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) - conn1 := types.NewConnectionEnd(exported.INIT, testConnectionIDA, testClientIDA, counterparty3, types.GetCompatibleVersions()) - conn2 := types.NewConnectionEnd(exported.INIT, testConnectionIDB, testClientIDB, counterparty1, types.GetCompatibleVersions()) - conn3 := types.NewConnectionEnd(exported.UNINITIALIZED, testConnectionID3, testClientID3, counterparty2, types.GetCompatibleVersions()) + conn1 := types.NewConnectionEnd(ibctypes.INIT, testConnectionIDA, testClientIDA, counterparty3, types.GetCompatibleVersions()) + conn2 := types.NewConnectionEnd(ibctypes.INIT, testConnectionIDB, testClientIDB, counterparty1, types.GetCompatibleVersions()) + conn3 := types.NewConnectionEnd(ibctypes.UNINITIALIZED, testConnectionID3, testClientID3, counterparty2, types.GetCompatibleVersions()) expConnections := []types.ConnectionEnd{conn1, conn2, conn3} @@ -124,7 +123,7 @@ func (suite KeeperTestSuite) TestGetAllConnections() { connections := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetAllConnections(suite.chainA.GetContext()) suite.Require().Len(connections, len(expConnections)) - suite.Require().ElementsMatch(expConnections, connections) + suite.Require().Equal(expConnections, connections) } func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() { @@ -172,7 +171,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { tc.malleate() // create and store a connection to chainB on chainA - connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.OPEN) + connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.OPEN) actualTimestamp, err := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetTimestampAtHeight( suite.chainA.GetContext(), connection, uint64(suite.chainB.Header.Height), @@ -224,7 +223,7 @@ func NewTestChain(clientID string) *TestChain { // Creates simple context for testing purposes func (chain *TestChain) GetContext() sdk.Context { - return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.ChainID, Height: chain.Header.Height}) + return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height}) } // createClient will create a client for clientChain on targetChain @@ -233,7 +232,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { // Commit and create a new block on appTarget to get a fresh CommitID client.App.Commit() commitID := client.App.LastCommitID() - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -250,7 +249,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo) // also set staking params stakingParams := staking.DefaultParams() @@ -307,7 +306,7 @@ func (chain *TestChain) updateClient(client *TestChain) { } */ - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -324,17 +323,17 @@ func (chain *TestChain) updateClient(client *TestChain) { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo) consensusState := ibctmtypes.ConsensusState{ - Height: uint64(client.Header.Height), + Height: client.Header.GetHeight(), Timestamp: client.Header.Time, Root: commitmenttypes.NewMerkleRoot(commitID.Hash), ValidatorSet: client.Vals, } chain.App.IBCKeeper.ClientKeeper.SetClientConsensusState( - ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, + ctxTarget, client.ClientID, client.Header.GetHeight(), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), @@ -355,9 +354,9 @@ func (chain *TestChain) updateClient(client *TestChain) { func (chain *TestChain) createConnection( connID, counterpartyConnID, clientID, counterpartyClientID string, - state exported.State, + state ibctypes.State, ) types.ConnectionEnd { - counterparty := types.NewCounterparty(counterpartyClientID, counterpartyConnID, chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) + counterparty := types.NewCounterparty(counterpartyClientID, counterpartyConnID, commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) connection := types.ConnectionEnd{ State: state, ID: connID, @@ -372,20 +371,21 @@ func (chain *TestChain) createConnection( func (chain *TestChain) createChannel( portID, channelID, counterpartyPortID, counterpartyChannelID string, - state channelexported.State, order channelexported.Order, connectionID string, + state ibctypes.State, order ibctypes.Order, connectionID string, ) channeltypes.Channel { counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID) - channel := channeltypes.NewChannel(state, order, counterparty, - []string{connectionID}, "1.0", - ) + channel := channeltypes.NewChannel(state, order, counterparty, []string{connectionID}, "1.0") ctx := chain.GetContext() chain.App.IBCKeeper.ChannelKeeper.SetChannel(ctx, portID, channelID, channel) return channel } func nextHeader(chain *TestChain) ibctmtypes.Header { - return ibctmtypes.CreateTestHeader(chain.Header.ChainID, chain.Header.Height+1, - chain.Header.Time.Add(nextTimestamp), chain.Vals, chain.Signers) + return ibctmtypes.CreateTestHeader( + chain.Header.SignedHeader.Header.ChainID, + chain.Header.SignedHeader.Header.Height+1, + chain.Header.Time.Add(nextTimestamp), chain.Vals, chain.Signers, + ) } func prefixedClientKey(clientID string, key []byte) []byte { diff --git a/x/ibc/03-connection/keeper/verify.go b/x/ibc/03-connection/keeper/verify.go index 699ef5db15d6..bf79c907ba5b 100644 --- a/x/ibc/03-connection/keeper/verify.go +++ b/x/ibc/03-connection/keeper/verify.go @@ -32,7 +32,7 @@ func (k Keeper) VerifyClientConsensusState( } return clientState.VerifyClientConsensusState( - k.cdc, targetConsState.GetRoot(), height, connection.GetCounterparty().GetClientID(), consensusHeight, connection.GetCounterparty().GetPrefix(), proof, consensusState, + k.aminoCdc, targetConsState.GetRoot(), height, connection.GetCounterparty().GetClientID(), consensusHeight, connection.GetCounterparty().GetPrefix(), proof, consensusState, ) } diff --git a/x/ibc/03-connection/keeper/verify_test.go b/x/ibc/03-connection/keeper/verify_test.go index 78f8e1e77f83..07906674647d 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -4,9 +4,7 @@ import ( "fmt" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" - "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" @@ -24,10 +22,10 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() { // create connection on chainA to chainB counterparty := types.NewCounterparty( testClientIDA, testConnectionIDA, - suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix(), + commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()), ) connection1 := types.NewConnectionEnd( - exported.UNINITIALIZED, testConnectionIDB, testClientIDB, counterparty, + ibctypes.UNINITIALIZED, testConnectionIDB, testClientIDB, counterparty, types.GetCompatibleVersions(), ) @@ -67,7 +65,7 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() { suite.chainA.updateClient(suite.chainB) // TODO: is this the right consensus height - consensusHeight := uint64(suite.chainA.Header.Height) + consensusHeight := suite.chainA.Header.GetHeight() consensusKey := prefixedClientKey(testClientIDA, ibctypes.KeyConsensusState(consensusHeight)) // get proof that chainB stored chainA' consensus state @@ -119,11 +117,11 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() { tc.malleate() // create and store connection on chain A - expectedConnection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, exported.OPEN) + expectedConnection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.OPEN) // // create expected connection // TODO: why is this commented - // expectedConnection := types.NewConnectionEnd(exported.INIT, testClientIDB, counterparty, []string{"1.0.0"}) + // expectedConnection := types.NewConnectionEnd(types.INIT, testClientIDB, counterparty, []string{"1.0.0"}) // perform a couple updates of chain A on chain B suite.chainB.updateClient(suite.chainA) @@ -136,7 +134,7 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() { // Create B's connection to A counterparty := types.NewCounterparty(testClientIDB, testConnectionIDB, commitmenttypes.NewMerklePrefix([]byte("ibc"))) - connection := types.NewConnectionEnd(exported.UNINITIALIZED, testConnectionIDA, testClientIDA, counterparty, []string{"1.0.0"}) + connection := types.NewConnectionEnd(ibctypes.UNINITIALIZED, testConnectionIDA, testClientIDA, counterparty, []string{"1.0.0"}) // Ensure chain B can verify connection exists in chain A err := suite.chainB.App.IBCKeeper.ConnectionKeeper.VerifyConnectionState( suite.chainB.GetContext(), connection, proofHeight+1, proof, testConnectionIDA, expectedConnection, @@ -157,11 +155,11 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() { // create connection of chainB to pass into verify function counterparty := types.NewCounterparty( testClientIDB, testConnectionIDB, - suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix(), + commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()), ) connection := types.NewConnectionEnd( - exported.UNINITIALIZED, testConnectionIDA, testClientIDA, counterparty, + ibctypes.UNINITIALIZED, testConnectionIDA, testClientIDA, counterparty, types.GetCompatibleVersions(), ) @@ -195,7 +193,7 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() { // Create and store channel on chain A channel := suite.chainA.createChannel( testPort1, testChannel1, testPort2, testChannel2, - channelexported.OPEN, channelexported.ORDERED, testConnectionIDA, + ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA, ) // Update chainA client on chainB @@ -252,7 +250,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() { tc.malleate() // Set PacketCommitment on chainA - connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.OPEN) + connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), testPort1, testChannel1, 1, commitmentBz) // Update ChainA client on chainB @@ -305,7 +303,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { suite.SetupTest() // reset tc.malleate() - connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.OPEN) + connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), testPort1, testChannel1, 1, channeltypes.CommitAcknowledgement(ack)) suite.chainB.updateClient(suite.chainA) @@ -355,7 +353,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() { suite.SetupTest() // reset tc.malleate() - connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.OPEN) + connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) suite.chainB.updateClient(suite.chainA) proof, proofHeight := queryProof(suite.chainA, packetAckKey) @@ -403,7 +401,7 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { suite.SetupTest() // reset tc.malleate() - connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, exported.OPEN) + connection := suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort1, testChannel1, 1) suite.chainB.updateClient(suite.chainA) diff --git a/x/ibc/03-connection/types/codec.go b/x/ibc/03-connection/types/codec.go index 263ec4c3f4ae..5ae9aa6ed89f 100644 --- a/x/ibc/03-connection/types/codec.go +++ b/x/ibc/03-connection/types/codec.go @@ -2,27 +2,49 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" ) -// SubModuleCdc defines the IBC connection codec. -var SubModuleCdc *codec.Codec - -// RegisterCodec registers the IBC connection types +// RegisterCodec registers the necessary x/ibc/03-connection interfaces and concrete types +// on the provided Amino codec. These types are used for Amino JSON serialization. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.ConnectionI)(nil), nil) cdc.RegisterInterface((*exported.CounterpartyI)(nil), nil) - cdc.RegisterConcrete(ConnectionEnd{}, "ibc/connection/ConnectionEnd", nil) + cdc.RegisterConcrete(ConnectionEnd{}, "ibc/connection/ConnectionEnd", nil) cdc.RegisterConcrete(MsgConnectionOpenInit{}, "ibc/connection/MsgConnectionOpenInit", nil) cdc.RegisterConcrete(MsgConnectionOpenTry{}, "ibc/connection/MsgConnectionOpenTry", nil) cdc.RegisterConcrete(MsgConnectionOpenAck{}, "ibc/connection/MsgConnectionOpenAck", nil) cdc.RegisterConcrete(MsgConnectionOpenConfirm{}, "ibc/connection/MsgConnectionOpenConfirm", nil) +} - SetSubModuleCodec(cdc) +// RegisterInterfaces register the ibc interfaces submodule implementations to protobuf +// Any. +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgConnectionOpenInit{}, + &MsgConnectionOpenTry{}, + &MsgConnectionOpenAck{}, + &MsgConnectionOpenConfirm{}, + ) } -// SetSubModuleCodec sets the ibc connection codec -func SetSubModuleCodec(cdc *codec.Codec) { - SubModuleCdc = cdc +var ( + amino = codec.New() + + // SubModuleCdc references the global x/ibc/03-connectionl module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/ibc/03-connectionl and + // defined at the application level. + SubModuleCdc = codec.NewHybridCodec(amino, cdctypes.NewInterfaceRegistry()) +) + +func init() { + RegisterCodec(amino) + amino.Seal() } diff --git a/x/ibc/03-connection/types/connection.go b/x/ibc/03-connection/types/connection.go index 0c9adbaa13df..e439d143423b 100644 --- a/x/ibc/03-connection/types/connection.go +++ b/x/ibc/03-connection/types/connection.go @@ -6,43 +6,26 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" + commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) -var _ exported.ConnectionI = ConnectionEnd{} - -// ICS03 - Connection Data Structures as defined in https://github.com/cosmos/ics/tree/master/spec/ics-003-connection-semantics#data-structures - -// ConnectionEnd defines a stateful object on a chain connected to another separate -// one. -// NOTE: there must only be 2 defined ConnectionEnds to establish a connection -// between two chains. -type ConnectionEnd struct { - State exported.State `json:"state" yaml:"state"` - ID string `json:"id" yaml:"id"` - ClientID string `json:"client_id" yaml:"client_id"` - - // Counterparty chain associated with this connection. - Counterparty Counterparty `json:"counterparty" yaml:"counterparty"` - // Version is utilised to determine encodings or protocols for channels or - // packets utilising this connection. - Versions []string `json:"versions" yaml:"versions"` -} +var _ exported.ConnectionI = (*ConnectionEnd)(nil) // NewConnectionEnd creates a new ConnectionEnd instance. -func NewConnectionEnd(state exported.State, connectionID, clientID string, counterparty Counterparty, versions []string) ConnectionEnd { +func NewConnectionEnd(state ibctypes.State, connectionID, clientID string, counterparty Counterparty, versions []string) ConnectionEnd { return ConnectionEnd{ - State: state, ID: connectionID, ClientID: clientID, - Counterparty: counterparty, Versions: versions, + State: state, + Counterparty: counterparty, } } // GetState implements the Connection interface -func (c ConnectionEnd) GetState() exported.State { +func (c ConnectionEnd) GetState() ibctypes.State { return c.State } @@ -87,17 +70,10 @@ func (c ConnectionEnd) ValidateBasic() error { return c.Counterparty.ValidateBasic() } -var _ exported.CounterpartyI = Counterparty{} - -// Counterparty defines the counterparty chain associated with a connection end. -type Counterparty struct { - ClientID string `json:"client_id" yaml:"client_id"` - ConnectionID string `json:"connection_id" yaml:"connection_id"` - Prefix commitmentexported.Prefix `json:"prefix" yaml:"prefix"` -} +var _ exported.CounterpartyI = (*Counterparty)(nil) // NewCounterparty creates a new Counterparty instance. -func NewCounterparty(clientID, connectionID string, prefix commitmentexported.Prefix) Counterparty { +func NewCounterparty(clientID, connectionID string, prefix commitmenttypes.MerklePrefix) Counterparty { return Counterparty{ ClientID: clientID, ConnectionID: connectionID, @@ -117,7 +93,7 @@ func (c Counterparty) GetConnectionID() string { // GetPrefix implements the CounterpartyI interface func (c Counterparty) GetPrefix() commitmentexported.Prefix { - return c.Prefix + return &c.Prefix } // ValidateBasic performs a basic validation check of the identifiers and prefix @@ -138,7 +114,7 @@ func (c Counterparty) ValidateBasic() error { ).Error(), ) } - if c.Prefix == nil || len(c.Prefix.Bytes()) == 0 { + if c.Prefix.IsEmpty() { return sdkerrors.Wrap(ErrInvalidCounterparty, "invalid counterparty prefix") } return nil diff --git a/x/ibc/03-connection/types/connection_test.go b/x/ibc/03-connection/types/connection_test.go index aae3536ae2fb..faabbaf7ab11 100644 --- a/x/ibc/03-connection/types/connection_test.go +++ b/x/ibc/03-connection/types/connection_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) var ( @@ -24,32 +24,32 @@ func TestConnectionValidateBasic(t *testing.T) { }{ { "valid connection", - ConnectionEnd{exported.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}}, + ConnectionEnd{connectionID, clientID, []string{"1.0.0"}, ibctypes.INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}}, true, }, { "invalid connection id", - ConnectionEnd{exported.INIT, "connectionIDONE", clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}}, + ConnectionEnd{"connectionIDONE", clientID, []string{"1.0.0"}, ibctypes.INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}}, false, }, { "invalid client id", - ConnectionEnd{exported.INIT, connectionID, "ClientIDTwo", Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}}, + ConnectionEnd{connectionID, "clientID1", []string{"1.0.0"}, ibctypes.INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}}, false, }, { "empty versions", - ConnectionEnd{exported.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, nil}, + ConnectionEnd{connectionID, clientID, nil, ibctypes.INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}}, false, }, { "invalid version", - ConnectionEnd{exported.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{""}}, + ConnectionEnd{connectionID, clientID, []string{""}, ibctypes.INIT, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}}, false, }, { "invalid counterparty", - ConnectionEnd{exported.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, nil}, []string{"1.0.0"}}, + ConnectionEnd{connectionID, clientID, []string{"1.0.0"}, ibctypes.INIT, Counterparty{clientID2, connectionID2, emptyPrefix}}, false, }, } @@ -72,10 +72,10 @@ func TestCounterpartyValidateBasic(t *testing.T) { counterparty Counterparty expPass bool }{ - {"valid counterparty", Counterparty{"clientidone", connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, true}, + {"valid counterparty", Counterparty{clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, true}, {"invalid client id", Counterparty{"InvalidClient", "channelidone", commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false}, - {"invalid connection id", Counterparty{"clientidone", "InvalidConnection", commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false}, - {"invalid prefix", Counterparty{"clientidone", connectionID2, nil}, false}, + {"invalid connection id", Counterparty{clientID, "InvalidConnection", commitmenttypes.NewMerklePrefix([]byte("prefix"))}, false}, + {"invalid prefix", Counterparty{clientID, connectionID2, emptyPrefix}, false}, } for i, tc := range testCases { diff --git a/x/ibc/03-connection/types/genesis_test.go b/x/ibc/03-connection/types/genesis_test.go index d1afb7dbbc97..19a4aa9775ad 100644 --- a/x/ibc/03-connection/types/genesis_test.go +++ b/x/ibc/03-connection/types/genesis_test.go @@ -5,7 +5,6 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -26,7 +25,7 @@ func TestValidateGenesis(t *testing.T) { name: "valid genesis", genState: NewGenesisState( []ConnectionEnd{ - {exported.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}}, + NewConnectionEnd(ibctypes.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}), }, []ConnectionPaths{ {clientID, []string{ibctypes.ConnectionPath(connectionID)}}, @@ -38,7 +37,7 @@ func TestValidateGenesis(t *testing.T) { name: "invalid connection", genState: NewGenesisState( []ConnectionEnd{ - NewConnectionEnd(exported.INIT, connectionID, "CLIENTIDONE", Counterparty{clientID, connectionID, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}), + NewConnectionEnd(ibctypes.INIT, connectionID, "CLIENTIDONE", Counterparty{clientID, connectionID, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}), }, []ConnectionPaths{ {clientID, []string{ibctypes.ConnectionPath(connectionID)}}, @@ -50,7 +49,7 @@ func TestValidateGenesis(t *testing.T) { name: "invalid client id", genState: NewGenesisState( []ConnectionEnd{ - {exported.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}}, + NewConnectionEnd(ibctypes.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}), }, []ConnectionPaths{ {"CLIENTIDONE", []string{ibctypes.ConnectionPath(connectionID)}}, @@ -62,7 +61,7 @@ func TestValidateGenesis(t *testing.T) { name: "invalid path", genState: NewGenesisState( []ConnectionEnd{ - {exported.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}}, + NewConnectionEnd(ibctypes.INIT, connectionID, clientID, Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}, []string{"1.0.0"}), }, []ConnectionPaths{ {clientID, []string{connectionID}}, diff --git a/x/ibc/03-connection/types/msgs.go b/x/ibc/03-connection/types/msgs.go index 9fb96cc3734e..425c32d4e0d1 100644 --- a/x/ibc/03-connection/types/msgs.go +++ b/x/ibc/03-connection/types/msgs.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" @@ -13,19 +12,10 @@ import ( var _ sdk.Msg = MsgConnectionOpenInit{} -// MsgConnectionOpenInit defines the msg sent by an account on Chain A to -// initialize a connection with Chain B. -type MsgConnectionOpenInit struct { - ConnectionID string `json:"connection_id"` - ClientID string `json:"client_id"` - Counterparty Counterparty `json:"counterparty"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgConnectionOpenInit creates a new MsgConnectionOpenInit instance func NewMsgConnectionOpenInit( connectionID, clientID, counterpartyConnectionID, - counterpartyClientID string, counterpartyPrefix commitmentexported.Prefix, + counterpartyClientID string, counterpartyPrefix commitmenttypes.MerklePrefix, signer sdk.AccAddress, ) MsgConnectionOpenInit { counterparty := NewCounterparty(counterpartyClientID, counterpartyConnectionID, counterpartyPrefix) @@ -73,25 +63,11 @@ func (msg MsgConnectionOpenInit) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgConnectionOpenTry{} -// MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a connection -// on Chain B. -type MsgConnectionOpenTry struct { - ConnectionID string `json:"connection_id"` - ClientID string `json:"client_id"` - Counterparty Counterparty `json:"counterparty"` - CounterpartyVersions []string `json:"counterparty_versions"` - ProofInit commitmentexported.Proof `json:"proof_init"` // proof of the initialization the connection on Chain A: `none -> INIT` - ProofConsensus commitmentexported.Proof `json:"proof_consensus"` // proof of client consensus state - ProofHeight uint64 `json:"proof_height"` - ConsensusHeight uint64 `json:"consensus_height"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgConnectionOpenTry creates a new MsgConnectionOpenTry instance func NewMsgConnectionOpenTry( connectionID, clientID, counterpartyConnectionID, - counterpartyClientID string, counterpartyPrefix commitmentexported.Prefix, - counterpartyVersions []string, proofInit, proofConsensus commitmentexported.Proof, + counterpartyClientID string, counterpartyPrefix commitmenttypes.MerklePrefix, + counterpartyVersions []string, proofInit, proofConsensus commitmenttypes.MerkleProof, proofHeight, consensusHeight uint64, signer sdk.AccAddress, ) MsgConnectionOpenTry { counterparty := NewCounterparty(counterpartyClientID, counterpartyConnectionID, counterpartyPrefix) @@ -134,7 +110,7 @@ func (msg MsgConnectionOpenTry) ValidateBasic() error { return sdkerrors.Wrap(ibctypes.ErrInvalidVersion, "version can't be blank") } } - if msg.ProofInit == nil || msg.ProofConsensus == nil { + if msg.ProofInit.IsEmpty() || msg.ProofConsensus.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.ProofInit.ValidateBasic(); err != nil { @@ -167,21 +143,9 @@ func (msg MsgConnectionOpenTry) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgConnectionOpenAck{} -// MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to acknowledge -// the change of connection state to TRYOPEN on Chain B. -type MsgConnectionOpenAck struct { - ConnectionID string `json:"connection_id"` - ProofTry commitmentexported.Proof `json:"proof_try"` // proof for the change of the connection state on Chain B: `none -> TRYOPEN` - ProofConsensus commitmentexported.Proof `json:"proof_consensus"` // proof of client consensus state - ProofHeight uint64 `json:"proof_height"` - ConsensusHeight uint64 `json:"consensus_height"` - Version string `json:"version"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgConnectionOpenAck creates a new MsgConnectionOpenAck instance func NewMsgConnectionOpenAck( - connectionID string, proofTry, proofConsensus commitmentexported.Proof, + connectionID string, proofTry, proofConsensus commitmenttypes.MerkleProof, proofHeight, consensusHeight uint64, version string, signer sdk.AccAddress, ) MsgConnectionOpenAck { @@ -214,7 +178,7 @@ func (msg MsgConnectionOpenAck) ValidateBasic() error { if strings.TrimSpace(msg.Version) == "" { return sdkerrors.Wrap(ibctypes.ErrInvalidVersion, "version can't be blank") } - if msg.ProofTry == nil || msg.ProofConsensus == nil { + if msg.ProofTry.IsEmpty() || msg.ProofConsensus.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.ProofTry.ValidateBasic(); err != nil { @@ -247,18 +211,9 @@ func (msg MsgConnectionOpenAck) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgConnectionOpenConfirm{} -// MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to acknowledge -// the change of connection state to OPEN on Chain A. -type MsgConnectionOpenConfirm struct { - ConnectionID string `json:"connection_id"` - ProofAck commitmentexported.Proof `json:"proof_ack"` // proof for the change of the connection state on Chain A: `INIT -> OPEN` - ProofHeight uint64 `json:"proof_height"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgConnectionOpenConfirm creates a new MsgConnectionOpenConfirm instance func NewMsgConnectionOpenConfirm( - connectionID string, proofAck commitmentexported.Proof, proofHeight uint64, + connectionID string, proofAck commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, ) MsgConnectionOpenConfirm { return MsgConnectionOpenConfirm{ @@ -284,7 +239,7 @@ func (msg MsgConnectionOpenConfirm) ValidateBasic() error { if err := host.DefaultConnectionIdentifierValidator(msg.ConnectionID); err != nil { return sdkerrors.Wrap(err, "invalid connection ID") } - if msg.ProofAck == nil { + if msg.ProofAck.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.ProofAck.ValidateBasic(); err != nil { diff --git a/x/ibc/03-connection/types/msgs_test.go b/x/ibc/03-connection/types/msgs_test.go index 26c88868837f..bc542e1be405 100644 --- a/x/ibc/03-connection/types/msgs_test.go +++ b/x/ibc/03-connection/types/msgs_test.go @@ -16,6 +16,11 @@ import ( commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) +var ( + emptyPrefix = commitmenttypes.MerklePrefix{} + emptyProof = commitmenttypes.MerkleProof{Proof: nil} +) + type MsgTestSuite struct { suite.Suite @@ -56,7 +61,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { NewMsgConnectionOpenInit("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, signer), NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "test/conn1", "clienttotest", prefix, signer), NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "test/conn1", prefix, signer), - NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", nil, signer), + NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", emptyPrefix, signer), NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, nil), NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "connectiontotest", "clienttotest", prefix, signer), } @@ -94,12 +99,10 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { NewMsgConnectionOpenTry("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "ibc/test", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "test/conn1", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), - NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", nil, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), + NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", emptyPrefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{}, suite.proof, suite.proof, 10, 10, signer), - NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, nil, suite.proof, 10, 10, signer), - NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, commitmenttypes.MerkleProof{Proof: nil}, suite.proof, 10, 10, signer), - NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, nil, 10, 10, signer), - NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, commitmenttypes.MerkleProof{Proof: nil}, 10, 10, signer), + NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, emptyProof, suite.proof, 10, 10, signer), + NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, emptyProof, 10, 10, signer), NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 0, 10, signer), NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 0, signer), NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, nil), @@ -118,13 +121,11 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { {testMsgs[4], false, "empty counterparty prefix"}, {testMsgs[5], false, "empty counterpartyVersions"}, {testMsgs[6], false, "empty proofInit"}, - {testMsgs[7], false, "empty proofInit"}, - {testMsgs[8], false, "empty proofConsensus"}, - {testMsgs[9], false, "empty proofConsensus"}, - {testMsgs[10], false, "invalid proofHeight"}, - {testMsgs[11], false, "invalid consensusHeight"}, - {testMsgs[12], false, "empty singer"}, - {testMsgs[13], true, "success"}, + {testMsgs[7], false, "empty proofConsensus"}, + {testMsgs[8], false, "invalid proofHeight"}, + {testMsgs[9], false, "invalid consensusHeight"}, + {testMsgs[10], false, "empty singer"}, + {testMsgs[11], true, "success"}, } for i, tc := range testCases { @@ -142,10 +143,8 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { testMsgs := []MsgConnectionOpenAck{ NewMsgConnectionOpenAck("test/conn1", suite.proof, suite.proof, 10, 10, "1.0.0", signer), - NewMsgConnectionOpenAck("ibcconntest", nil, suite.proof, 10, 10, "1.0.0", signer), - NewMsgConnectionOpenAck("ibcconntest", commitmenttypes.MerkleProof{Proof: nil}, suite.proof, 10, 10, "1.0.0", signer), - NewMsgConnectionOpenAck("ibcconntest", suite.proof, nil, 10, 10, "1.0.0", signer), - NewMsgConnectionOpenAck("ibcconntest", suite.proof, commitmenttypes.MerkleProof{Proof: nil}, 10, 10, "1.0.0", signer), + NewMsgConnectionOpenAck("ibcconntest", emptyProof, suite.proof, 10, 10, "1.0.0", signer), + NewMsgConnectionOpenAck("ibcconntest", suite.proof, emptyProof, 10, 10, "1.0.0", signer), NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 0, 10, "1.0.0", signer), NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 0, "1.0.0", signer), NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "", signer), @@ -159,14 +158,12 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { }{ {testMsgs[0], false, "invalid connection ID"}, {testMsgs[1], false, "empty proofTry"}, - {testMsgs[2], false, "empty proofTry"}, - {testMsgs[3], false, "empty proofConsensus"}, - {testMsgs[4], false, "empty proofConsensus"}, - {testMsgs[5], false, "invalid proofHeight"}, - {testMsgs[6], false, "invalid consensusHeight"}, - {testMsgs[7], false, "invalid version"}, - {testMsgs[8], false, "empty signer"}, - {testMsgs[9], true, "success"}, + {testMsgs[2], false, "empty proofConsensus"}, + {testMsgs[3], false, "invalid proofHeight"}, + {testMsgs[4], false, "invalid consensusHeight"}, + {testMsgs[5], false, "invalid version"}, + {testMsgs[6], false, "empty signer"}, + {testMsgs[7], true, "success"}, } for i, tc := range testCases { @@ -184,8 +181,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { testMsgs := []MsgConnectionOpenConfirm{ NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 10, signer), - NewMsgConnectionOpenConfirm("ibcconntest", nil, 10, signer), - NewMsgConnectionOpenConfirm("ibcconntest", commitmenttypes.MerkleProof{Proof: nil}, 10, signer), + NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 10, signer), NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 0, signer), NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, nil), NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 10, signer), @@ -198,10 +194,9 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { }{ {testMsgs[0], false, "invalid connection ID"}, {testMsgs[1], false, "empty proofTry"}, - {testMsgs[2], false, "empty proofTry"}, - {testMsgs[3], false, "invalid proofHeight"}, - {testMsgs[4], false, "empty signer"}, - {testMsgs[5], true, "success"}, + {testMsgs[2], false, "invalid proofHeight"}, + {testMsgs[3], false, "empty signer"}, + {testMsgs[4], true, "success"}, } for i, tc := range testCases { diff --git a/x/ibc/03-connection/types/types.pb.go b/x/ibc/03-connection/types/types.pb.go new file mode 100644 index 000000000000..78acde8a0702 --- /dev/null +++ b/x/ibc/03-connection/types/types.pb.go @@ -0,0 +1,2642 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/ibc/03-connection/types/types.proto + +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" + types1 "github.com/cosmos/cosmos-sdk/x/ibc/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgConnectionOpenInit defines the msg sent by an account on Chain A to +// initialize a connection with Chain B. +type MsgConnectionOpenInit struct { + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + ConnectionID string `protobuf:"bytes,2,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` + Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` + 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"` +} + +func (m *MsgConnectionOpenInit) Reset() { *m = MsgConnectionOpenInit{} } +func (m *MsgConnectionOpenInit) String() string { return proto.CompactTextString(m) } +func (*MsgConnectionOpenInit) ProtoMessage() {} +func (*MsgConnectionOpenInit) Descriptor() ([]byte, []int) { + return fileDescriptor_30ee50c03d1fbe43, []int{0} +} +func (m *MsgConnectionOpenInit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConnectionOpenInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConnectionOpenInit.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgConnectionOpenInit) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConnectionOpenInit.Merge(m, src) +} +func (m *MsgConnectionOpenInit) XXX_Size() int { + return m.Size() +} +func (m *MsgConnectionOpenInit) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConnectionOpenInit.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgConnectionOpenInit proto.InternalMessageInfo + +func (m *MsgConnectionOpenInit) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *MsgConnectionOpenInit) GetConnectionID() string { + if m != nil { + return m.ConnectionID + } + return "" +} + +func (m *MsgConnectionOpenInit) GetCounterparty() Counterparty { + if m != nil { + return m.Counterparty + } + return Counterparty{} +} + +func (m *MsgConnectionOpenInit) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a connection +// on Chain B. +type MsgConnectionOpenTry struct { + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + ConnectionID string `protobuf:"bytes,2,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` + 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"` + // proof of client consensus state + ProofConsensus types.MerkleProof `protobuf:"bytes,7,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus" 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"` +} + +func (m *MsgConnectionOpenTry) Reset() { *m = MsgConnectionOpenTry{} } +func (m *MsgConnectionOpenTry) String() string { return proto.CompactTextString(m) } +func (*MsgConnectionOpenTry) ProtoMessage() {} +func (*MsgConnectionOpenTry) Descriptor() ([]byte, []int) { + return fileDescriptor_30ee50c03d1fbe43, []int{1} +} +func (m *MsgConnectionOpenTry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConnectionOpenTry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConnectionOpenTry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgConnectionOpenTry) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConnectionOpenTry.Merge(m, src) +} +func (m *MsgConnectionOpenTry) XXX_Size() int { + return m.Size() +} +func (m *MsgConnectionOpenTry) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConnectionOpenTry.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgConnectionOpenTry proto.InternalMessageInfo + +func (m *MsgConnectionOpenTry) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *MsgConnectionOpenTry) GetConnectionID() string { + if m != nil { + return m.ConnectionID + } + return "" +} + +func (m *MsgConnectionOpenTry) GetCounterparty() Counterparty { + if m != nil { + return m.Counterparty + } + return Counterparty{} +} + +func (m *MsgConnectionOpenTry) GetCounterpartyVersions() []string { + if m != nil { + return m.CounterpartyVersions + } + return nil +} + +func (m *MsgConnectionOpenTry) GetProofInit() types.MerkleProof { + if m != nil { + return m.ProofInit + } + return types.MerkleProof{} +} + +func (m *MsgConnectionOpenTry) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgConnectionOpenTry) GetProofConsensus() types.MerkleProof { + if m != nil { + return m.ProofConsensus + } + return types.MerkleProof{} +} + +func (m *MsgConnectionOpenTry) GetConsensusHeight() uint64 { + if m != nil { + return m.ConsensusHeight + } + return 0 +} + +func (m *MsgConnectionOpenTry) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to acknowledge +// the change of connection state to TRYOPEN on Chain B. +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"` + // proof of client consensus state + ProofConsensus types.MerkleProof `protobuf:"bytes,5,opt,name=proof_consensus,json=proofConsensus,proto3" json:"proof_consensus" 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"` +} + +func (m *MsgConnectionOpenAck) Reset() { *m = MsgConnectionOpenAck{} } +func (m *MsgConnectionOpenAck) String() string { return proto.CompactTextString(m) } +func (*MsgConnectionOpenAck) ProtoMessage() {} +func (*MsgConnectionOpenAck) Descriptor() ([]byte, []int) { + return fileDescriptor_30ee50c03d1fbe43, []int{2} +} +func (m *MsgConnectionOpenAck) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConnectionOpenAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConnectionOpenAck.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgConnectionOpenAck) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConnectionOpenAck.Merge(m, src) +} +func (m *MsgConnectionOpenAck) XXX_Size() int { + return m.Size() +} +func (m *MsgConnectionOpenAck) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConnectionOpenAck.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgConnectionOpenAck proto.InternalMessageInfo + +func (m *MsgConnectionOpenAck) GetConnectionID() string { + if m != nil { + return m.ConnectionID + } + return "" +} + +func (m *MsgConnectionOpenAck) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *MsgConnectionOpenAck) GetProofTry() types.MerkleProof { + if m != nil { + return m.ProofTry + } + return types.MerkleProof{} +} + +func (m *MsgConnectionOpenAck) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgConnectionOpenAck) GetProofConsensus() types.MerkleProof { + if m != nil { + return m.ProofConsensus + } + return types.MerkleProof{} +} + +func (m *MsgConnectionOpenAck) GetConsensusHeight() uint64 { + if m != nil { + return m.ConsensusHeight + } + return 0 +} + +func (m *MsgConnectionOpenAck) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to acknowledge +// the change of connection state to OPEN on Chain A. +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"` + 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"` +} + +func (m *MsgConnectionOpenConfirm) Reset() { *m = MsgConnectionOpenConfirm{} } +func (m *MsgConnectionOpenConfirm) String() string { return proto.CompactTextString(m) } +func (*MsgConnectionOpenConfirm) ProtoMessage() {} +func (*MsgConnectionOpenConfirm) Descriptor() ([]byte, []int) { + return fileDescriptor_30ee50c03d1fbe43, []int{3} +} +func (m *MsgConnectionOpenConfirm) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConnectionOpenConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConnectionOpenConfirm.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgConnectionOpenConfirm) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConnectionOpenConfirm.Merge(m, src) +} +func (m *MsgConnectionOpenConfirm) XXX_Size() int { + return m.Size() +} +func (m *MsgConnectionOpenConfirm) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConnectionOpenConfirm.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgConnectionOpenConfirm proto.InternalMessageInfo + +func (m *MsgConnectionOpenConfirm) GetConnectionID() string { + if m != nil { + return m.ConnectionID + } + return "" +} + +func (m *MsgConnectionOpenConfirm) GetProofAck() types.MerkleProof { + if m != nil { + return m.ProofAck + } + return types.MerkleProof{} +} + +func (m *MsgConnectionOpenConfirm) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgConnectionOpenConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// ConnectionEnd defines a stateful object on a chain connected to another separate +// one. +// NOTE: there must only be 2 defined ConnectionEnds to establish a connection +// between two chains. +type ConnectionEnd struct { + // connection identifier. + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + // client associated with this connection. + ClientID string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + // opaque string which can be utilised to determine encodings or protocols for + // channels or packets utilising this connection + Versions []string `protobuf:"bytes,3,rep,name=versions,proto3" json:"versions,omitempty"` + // current state of the connection end. + State types1.State `protobuf:"varint,4,opt,name=state,proto3,enum=cosmos_sdk.x.ibc.v1.State" json:"state,omitempty"` + // counterparty chain associated with this connection. + Counterparty Counterparty `protobuf:"bytes,5,opt,name=counterparty,proto3" json:"counterparty"` +} + +func (m *ConnectionEnd) Reset() { *m = ConnectionEnd{} } +func (m *ConnectionEnd) String() string { return proto.CompactTextString(m) } +func (*ConnectionEnd) ProtoMessage() {} +func (*ConnectionEnd) Descriptor() ([]byte, []int) { + return fileDescriptor_30ee50c03d1fbe43, []int{4} +} +func (m *ConnectionEnd) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConnectionEnd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConnectionEnd.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ConnectionEnd) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConnectionEnd.Merge(m, src) +} +func (m *ConnectionEnd) XXX_Size() int { + return m.Size() +} +func (m *ConnectionEnd) XXX_DiscardUnknown() { + xxx_messageInfo_ConnectionEnd.DiscardUnknown(m) +} + +var xxx_messageInfo_ConnectionEnd proto.InternalMessageInfo + +// Counterparty defines the counterparty chain associated with a connection end. +type Counterparty struct { + // identifies the client on the counterparty chain associated with a given connection. + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + // identifies the connection end on the counterparty chain associated with a given connection. + ConnectionID string `protobuf:"bytes,2,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty" yaml:"connection_id"` + // commitment merkle prefix of the counterparty chain + Prefix types.MerklePrefix `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix"` +} + +func (m *Counterparty) Reset() { *m = Counterparty{} } +func (m *Counterparty) String() string { return proto.CompactTextString(m) } +func (*Counterparty) ProtoMessage() {} +func (*Counterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_30ee50c03d1fbe43, []int{5} +} +func (m *Counterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Counterparty.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Counterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Counterparty.Merge(m, src) +} +func (m *Counterparty) XXX_Size() int { + return m.Size() +} +func (m *Counterparty) XXX_DiscardUnknown() { + xxx_messageInfo_Counterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_Counterparty proto.InternalMessageInfo + +// ClientPaths define all the connection paths for a client state. +type ClientPaths struct { + Paths []string `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"` +} + +func (m *ClientPaths) Reset() { *m = ClientPaths{} } +func (m *ClientPaths) String() string { return proto.CompactTextString(m) } +func (*ClientPaths) ProtoMessage() {} +func (*ClientPaths) Descriptor() ([]byte, []int) { + return fileDescriptor_30ee50c03d1fbe43, []int{6} +} +func (m *ClientPaths) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ClientPaths) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ClientPaths.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ClientPaths) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClientPaths.Merge(m, src) +} +func (m *ClientPaths) XXX_Size() int { + return m.Size() +} +func (m *ClientPaths) XXX_DiscardUnknown() { + xxx_messageInfo_ClientPaths.DiscardUnknown(m) +} + +var xxx_messageInfo_ClientPaths proto.InternalMessageInfo + +func (m *ClientPaths) GetPaths() []string { + if m != nil { + return m.Paths + } + return nil +} + +func init() { + proto.RegisterType((*MsgConnectionOpenInit)(nil), "cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenInit") + proto.RegisterType((*MsgConnectionOpenTry)(nil), "cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenTry") + proto.RegisterType((*MsgConnectionOpenAck)(nil), "cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenAck") + proto.RegisterType((*MsgConnectionOpenConfirm)(nil), "cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenConfirm") + proto.RegisterType((*ConnectionEnd)(nil), "cosmos_sdk.x.ibc.connection.v1.ConnectionEnd") + proto.RegisterType((*Counterparty)(nil), "cosmos_sdk.x.ibc.connection.v1.Counterparty") + proto.RegisterType((*ClientPaths)(nil), "cosmos_sdk.x.ibc.connection.v1.ClientPaths") +} + +func init() { + proto.RegisterFile("x/ibc/03-connection/types/types.proto", fileDescriptor_30ee50c03d1fbe43) +} + +var fileDescriptor_30ee50c03d1fbe43 = []byte{ + // 812 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x96, 0x4d, 0x6f, 0xda, 0x48, + 0x18, 0xc7, 0xb1, 0x79, 0x09, 0x4c, 0xc8, 0xcb, 0x3a, 0x64, 0xe3, 0x65, 0x57, 0x36, 0xeb, 0x68, + 0x57, 0x48, 0xbb, 0x31, 0x79, 0x91, 0x7a, 0x88, 0xd4, 0x43, 0xa0, 0xad, 0x4a, 0xa5, 0xa8, 0x91, + 0xdb, 0xe6, 0xd0, 0x0b, 0x02, 0x7b, 0x02, 0x23, 0xc2, 0x0c, 0xf2, 0x4c, 0xa2, 0xf0, 0x0d, 0x7a, + 0xec, 0x37, 0x68, 0x8f, 0xfd, 0x28, 0x39, 0xe6, 0xd0, 0x43, 0x4f, 0x56, 0x45, 0xa4, 0x1e, 0x7b, + 0xe0, 0xd8, 0x53, 0xe5, 0xf1, 0x6b, 0x02, 0x4d, 0x85, 0x40, 0x6a, 0xa5, 0x5e, 0x92, 0x99, 0xc7, + 0xcf, 0x3c, 0xf3, 0x9f, 0xff, 0xfc, 0xf0, 0x63, 0xf0, 0xcf, 0x45, 0x05, 0xb5, 0xcc, 0xca, 0xf6, + 0xde, 0x96, 0x49, 0x30, 0x86, 0x26, 0x43, 0x04, 0x57, 0xd8, 0xa0, 0x0f, 0xa9, 0xf7, 0x57, 0xef, + 0xdb, 0x84, 0x11, 0x49, 0x31, 0x09, 0xed, 0x11, 0xda, 0xa0, 0x56, 0x57, 0xbf, 0xd0, 0x51, 0xcb, + 0xd4, 0xa3, 0x74, 0xfd, 0x7c, 0xa7, 0xf8, 0x2f, 0xeb, 0x20, 0xdb, 0x6a, 0xf4, 0x9b, 0x36, 0x1b, + 0x54, 0xf8, 0x92, 0x4a, 0x9b, 0xb4, 0x49, 0x34, 0xf2, 0xea, 0x14, 0xfd, 0xed, 0x76, 0xdd, 0xed, + 0x7a, 0x3d, 0xc4, 0x7a, 0x10, 0xb3, 0xf1, 0xed, 0x8a, 0x1b, 0x5e, 0xda, 0xd8, 0x03, 0xed, 0x52, + 0x04, 0xeb, 0x87, 0xb4, 0x5d, 0x0b, 0x37, 0x7f, 0xda, 0x87, 0xb8, 0x8e, 0x11, 0x93, 0xee, 0x83, + 0x9c, 0x79, 0x8a, 0x20, 0x66, 0x0d, 0x64, 0xc9, 0x42, 0x49, 0x28, 0xe7, 0xaa, 0xa5, 0xa1, 0xa3, + 0x66, 0x6b, 0x3c, 0x58, 0x7f, 0x30, 0x72, 0xd4, 0xd5, 0x41, 0xb3, 0x77, 0xba, 0xaf, 0x85, 0x69, + 0x9a, 0x91, 0xf5, 0xc6, 0x75, 0x4b, 0x3a, 0x04, 0x4b, 0xd1, 0x89, 0xdc, 0x12, 0x22, 0x2f, 0x51, + 0x1e, 0x3a, 0x6a, 0x3e, 0xda, 0x8d, 0x97, 0x29, 0xf8, 0x65, 0xe2, 0xe9, 0x9a, 0x91, 0x8f, 0xe6, + 0x75, 0x4b, 0x3a, 0x06, 0x79, 0x93, 0x9c, 0x61, 0x06, 0x6d, 0x6e, 0x89, 0x9c, 0x2c, 0x09, 0xe5, + 0xc5, 0xdd, 0xff, 0xf5, 0xbb, 0x6d, 0xd4, 0x6b, 0xb1, 0x35, 0xd5, 0xd4, 0xa5, 0xa3, 0x26, 0x8c, + 0x1b, 0x75, 0xa4, 0x3a, 0xc8, 0x50, 0xd4, 0xc6, 0xd0, 0x96, 0x53, 0x25, 0xa1, 0x9c, 0xaf, 0xee, + 0x7c, 0x71, 0xd4, 0xad, 0x36, 0x62, 0x9d, 0xb3, 0x96, 0x6e, 0x92, 0x5e, 0xc5, 0xab, 0xef, 0xff, + 0xdb, 0xa2, 0x56, 0xd7, 0x77, 0xef, 0xc0, 0x34, 0x0f, 0x2c, 0xcb, 0x86, 0x94, 0x1a, 0x7e, 0x01, + 0xed, 0x53, 0x1a, 0x14, 0xc6, 0xac, 0x7c, 0x6e, 0x0f, 0x7e, 0x11, 0x27, 0x5f, 0x80, 0xf5, 0xf8, + 0xbc, 0x71, 0x0e, 0x6d, 0x8a, 0x08, 0xa6, 0x72, 0xaa, 0x94, 0x74, 0x4f, 0x3c, 0x72, 0xd4, 0xbf, + 0x02, 0x79, 0x13, 0xd2, 0x34, 0xa3, 0x10, 0x8f, 0x1f, 0xfb, 0x61, 0x09, 0x02, 0xd0, 0xb7, 0x09, + 0x39, 0x69, 0x20, 0x8c, 0x98, 0x9c, 0xe6, 0x62, 0xff, 0x9b, 0x24, 0x36, 0xa0, 0xdf, 0x15, 0x7b, + 0x08, 0xed, 0xee, 0x29, 0x3c, 0x72, 0xd7, 0x55, 0xff, 0x70, 0xb5, 0x8e, 0x1c, 0xf5, 0x37, 0x6f, + 0xf3, 0xa8, 0x98, 0x66, 0xe4, 0xf8, 0x84, 0xd3, 0xfe, 0x37, 0xc8, 0x7b, 0x4f, 0x3a, 0x10, 0xb5, + 0x3b, 0x4c, 0xce, 0x94, 0x84, 0x72, 0xca, 0x58, 0xe4, 0xb1, 0xc7, 0x3c, 0x24, 0x31, 0xb0, 0xe2, + 0xa5, 0x98, 0x04, 0x53, 0x88, 0xe9, 0x19, 0x95, 0x17, 0xa6, 0x97, 0xa3, 0xf8, 0x72, 0x7e, 0x8f, + 0xcb, 0x09, 0x2b, 0x6a, 0xc6, 0x32, 0x8f, 0xd4, 0x82, 0x80, 0xf4, 0x08, 0xac, 0x86, 0x4f, 0x03, + 0x71, 0x59, 0x57, 0x5c, 0xf5, 0xcf, 0x91, 0xa3, 0x6e, 0x84, 0x17, 0x7e, 0x23, 0x43, 0x33, 0x56, + 0xc2, 0x90, 0xaf, 0x3e, 0x02, 0x3d, 0x37, 0x2b, 0xe8, 0xef, 0x52, 0x13, 0x40, 0x3f, 0x30, 0xbb, + 0xe3, 0xa4, 0x0a, 0x33, 0x91, 0x2a, 0x83, 0x05, 0x9f, 0x0e, 0x0f, 0x79, 0x23, 0x98, 0x4a, 0x2d, + 0xe0, 0x5d, 0x5d, 0x83, 0xd9, 0x01, 0xc0, 0x53, 0x5d, 0x82, 0xec, 0x5f, 0xc2, 0x6a, 0xfc, 0x12, + 0x98, 0x3d, 0xd0, 0x8c, 0x2c, 0x1f, 0xbb, 0xbf, 0xda, 0xfd, 0x5b, 0x44, 0xa4, 0xb8, 0xe9, 0x1b, + 0x23, 0x47, 0x5d, 0x8b, 0xaf, 0x0a, 0x0c, 0xff, 0x1e, 0x2a, 0xe9, 0x1f, 0x83, 0x4a, 0x66, 0x26, + 0x54, 0x16, 0x66, 0x45, 0xe5, 0xbd, 0x08, 0xe4, 0x31, 0x54, 0x6a, 0x04, 0x9f, 0x20, 0xbb, 0x37, + 0x6f, 0x5c, 0x42, 0x28, 0x9a, 0x66, 0x97, 0x03, 0x33, 0x0f, 0x28, 0x9a, 0x66, 0x37, 0x80, 0xc2, + 0x25, 0xfc, 0x36, 0x14, 0xc9, 0x29, 0xa0, 0x98, 0x63, 0xab, 0x79, 0x23, 0x82, 0xa5, 0xc8, 0xa1, + 0x87, 0xd8, 0x92, 0x36, 0x81, 0x18, 0x1a, 0xb8, 0x36, 0x74, 0x54, 0x91, 0xdb, 0x96, 0xf3, 0x44, + 0xb9, 0x5e, 0x89, 0xc8, 0xba, 0xd9, 0x88, 0xc4, 0xa9, 0x1b, 0x51, 0x11, 0x64, 0xc3, 0x97, 0x7a, + 0xd2, 0x7d, 0xa9, 0x1b, 0xe1, 0x5c, 0xda, 0x06, 0x69, 0xca, 0x9a, 0x0c, 0xf2, 0xb3, 0x2d, 0xef, + 0x16, 0xc7, 0x8d, 0x3f, 0xdf, 0xd1, 0x9f, 0xb9, 0x19, 0x86, 0x97, 0x38, 0xd6, 0x87, 0xd2, 0xf3, + 0xe9, 0x43, 0xfb, 0xa9, 0x57, 0x6f, 0xd5, 0x84, 0xf6, 0x59, 0x00, 0xf9, 0x78, 0xea, 0x4f, 0xd6, + 0x84, 0x9f, 0x80, 0x4c, 0xdf, 0x86, 0x27, 0xe8, 0xe2, 0xae, 0xf6, 0x3b, 0x09, 0x54, 0x77, 0x8d, + 0x7f, 0x6c, 0xbf, 0x82, 0x7f, 0xe0, 0x4d, 0xb0, 0xe8, 0x1d, 0xe5, 0xa8, 0xc9, 0x3a, 0x54, 0x2a, + 0x80, 0x74, 0xdf, 0x1d, 0xc8, 0x02, 0xbf, 0x28, 0x6f, 0x52, 0x3d, 0xba, 0x1c, 0x2a, 0xc2, 0xd5, + 0x50, 0x11, 0x3e, 0x0e, 0x15, 0xe1, 0xf5, 0xb5, 0x92, 0xb8, 0xba, 0x56, 0x12, 0x1f, 0xae, 0x95, + 0xc4, 0xcb, 0x7b, 0x77, 0x82, 0xf8, 0xcd, 0x6f, 0xda, 0x56, 0x86, 0x7f, 0x46, 0xee, 0x7d, 0x0d, + 0x00, 0x00, 0xff, 0xff, 0x86, 0x13, 0x13, 0x09, 0xf7, 0x0a, 0x00, 0x00, +} + +func (m *MsgConnectionOpenInit) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgConnectionOpenInit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConnectionOpenInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ConnectionID) > 0 { + i -= len(m.ConnectionID) + copy(dAtA[i:], m.ConnectionID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ConnectionID))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgConnectionOpenTry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgConnectionOpenTry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConnectionOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x4a + } + if m.ConsensusHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ConsensusHeight)) + 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)) + } + 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)) + } + i-- + dAtA[i] = 0x2a + if len(m.CounterpartyVersions) > 0 { + for iNdEx := len(m.CounterpartyVersions) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.CounterpartyVersions[iNdEx]) + copy(dAtA[i:], m.CounterpartyVersions[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.CounterpartyVersions[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ConnectionID) > 0 { + i -= len(m.ConnectionID) + copy(dAtA[i:], m.ConnectionID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ConnectionID))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgConnectionOpenAck) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgConnectionOpenAck) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConnectionOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x3a + } + if m.ConsensusHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ConsensusHeight)) + 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)) + } + 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)) + } + i-- + dAtA[i] = 0x1a + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x12 + } + if len(m.ConnectionID) > 0 { + i -= len(m.ConnectionID) + copy(dAtA[i:], m.ConnectionID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ConnectionID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgConnectionOpenConfirm) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgConnectionOpenConfirm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConnectionOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if m.ProofHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) + 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)) + } + i-- + dAtA[i] = 0x12 + if len(m.ConnectionID) > 0 { + i -= len(m.ConnectionID) + copy(dAtA[i:], m.ConnectionID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ConnectionID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ConnectionEnd) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ConnectionEnd) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConnectionEnd) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if m.State != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.State)) + i-- + dAtA[i] = 0x20 + } + if len(m.Versions) > 0 { + for iNdEx := len(m.Versions) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Versions[iNdEx]) + copy(dAtA[i:], m.Versions[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Versions[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0x12 + } + if len(m.ID) > 0 { + i -= len(m.ID) + copy(dAtA[i:], m.ID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Counterparty) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Counterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Prefix.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ConnectionID) > 0 { + i -= len(m.ConnectionID) + copy(dAtA[i:], m.ConnectionID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ConnectionID))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ClientPaths) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ClientPaths) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClientPaths) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Paths) > 0 { + for iNdEx := len(m.Paths) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Paths[iNdEx]) + copy(dAtA[i:], m.Paths[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Paths[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgConnectionOpenInit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ConnectionID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Counterparty.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgConnectionOpenTry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ConnectionID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Counterparty.Size() + n += 1 + l + sovTypes(uint64(l)) + if len(m.CounterpartyVersions) > 0 { + for _, s := range m.CounterpartyVersions { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + l = m.ProofInit.Size() + 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)) + if m.ConsensusHeight != 0 { + n += 1 + sovTypes(uint64(m.ConsensusHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgConnectionOpenAck) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConnectionID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.ProofTry.Size() + 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)) + if m.ConsensusHeight != 0 { + n += 1 + sovTypes(uint64(m.ConsensusHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgConnectionOpenConfirm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConnectionID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.ProofAck.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *ConnectionEnd) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.Versions) > 0 { + for _, s := range m.Versions { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + if m.State != 0 { + n += 1 + sovTypes(uint64(m.State)) + } + l = m.Counterparty.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *Counterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ConnectionID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Prefix.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *ClientPaths) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Paths) > 0 { + for _, s := range m.Paths { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgConnectionOpenInit) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgConnectionOpenInit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConnectionOpenInit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgConnectionOpenTry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgConnectionOpenTry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConnectionOpenTry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyVersions", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyVersions = append(m.CounterpartyVersions, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofConsensus", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofConsensus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusHeight", wireType) + } + m.ConsensusHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ConsensusHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgConnectionOpenAck) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgConnectionOpenAck: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConnectionOpenAck: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofTry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofTry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofConsensus", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofConsensus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusHeight", wireType) + } + m.ConsensusHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ConsensusHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgConnectionOpenConfirm) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgConnectionOpenConfirm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConnectionOpenConfirm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofAck", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofAck.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConnectionEnd) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConnectionEnd: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConnectionEnd: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Versions", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Versions = append(m.Versions, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + m.State = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.State |= types1.State(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Counterparty) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Counterparty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Prefix.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ClientPaths) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ClientPaths: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ClientPaths: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Paths", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Paths = append(m.Paths, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/03-connection/types/types.proto b/x/ibc/03-connection/types/types.proto new file mode 100644 index 000000000000..bf196ea33504 --- /dev/null +++ b/x/ibc/03-connection/types/types.proto @@ -0,0 +1,101 @@ +syntax = "proto3"; +package cosmos_sdk.x.ibc.connection.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"; + +import "third_party/proto/gogoproto/gogo.proto"; +import "x/ibc/23-commitment/types/types.proto"; +import "x/ibc/types/types.proto"; + +// MsgConnectionOpenInit defines the msg sent by an account on Chain A to +// initialize a connection with Chain B. +message MsgConnectionOpenInit { + string client_id = 1 [(gogoproto.customname) = "ClientID", (gogoproto.moretags) = "yaml:\"client_id\""]; + string connection_id = 2 [(gogoproto.customname) = "ConnectionID", (gogoproto.moretags) = "yaml:\"connection_id\""]; + Counterparty counterparty = 3 [(gogoproto.nullable) = false]; + bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a connection +// on Chain B. +message MsgConnectionOpenTry { + string client_id = 1 [(gogoproto.customname) = "ClientID", (gogoproto.moretags) = "yaml:\"client_id\""]; + string connection_id = 2 [(gogoproto.customname) = "ConnectionID", (gogoproto.moretags) = "yaml:\"connection_id\""]; + 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\""]; + 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\""]; + uint64 consensus_height = 8 [(gogoproto.moretags) = "yaml:\"consensus_height\""]; + bytes signer = 9 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to acknowledge +// the change of connection state to TRYOPEN on Chain B. +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\""]; + 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\""]; + uint64 consensus_height = 6 [(gogoproto.moretags) = "yaml:\"consensus_height\""]; + bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to acknowledge +// the change of connection state to OPEN on Chain A. +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\""]; + uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// ICS03 - Connection Data Structures as defined in +// https://github.com/cosmos/ics/tree/master/spec/ics-003-connection-semantics#data-structures + +// ConnectionEnd defines a stateful object on a chain connected to another separate +// one. +// NOTE: there must only be 2 defined ConnectionEnds to establish a connection +// between two chains. +message ConnectionEnd { + option (gogoproto.goproto_getters) = false; + // connection identifier. + string id = 1 [(gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\""]; + // client associated with this connection. + string client_id = 2 [(gogoproto.customname) = "ClientID", (gogoproto.moretags) = "yaml:\"client_id\""]; + // opaque string which can be utilised to determine encodings or protocols for + // channels or packets utilising this connection + repeated string versions = 3; + // current state of the connection end. + cosmos_sdk.x.ibc.v1.State state = 4; + // counterparty chain associated with this connection. + Counterparty counterparty = 5 [(gogoproto.nullable) = false]; +} + +// Counterparty defines the counterparty chain associated with a connection end. +message Counterparty { + option (gogoproto.goproto_getters) = false; + + // identifies the client on the counterparty chain associated with a given connection. + string client_id = 1 [(gogoproto.customname) = "ClientID", (gogoproto.moretags) = "yaml:\"client_id\""]; + // identifies the connection end on the counterparty chain associated with a given connection. + string connection_id = 2 [(gogoproto.customname) = "ConnectionID", (gogoproto.moretags) = "yaml:\"connection_id\""]; + // commitment merkle prefix of the counterparty chain + cosmos_sdk.x.ibc.commitment.v1.MerklePrefix prefix = 3 [(gogoproto.nullable) = false]; +} + +// ClientPaths define all the connection paths for a client state. +message ClientPaths { + repeated string paths = 1; +} diff --git a/x/ibc/04-channel/alias.go b/x/ibc/04-channel/alias.go index 697f2338e8ce..c4284b5127af 100644 --- a/x/ibc/04-channel/alias.go +++ b/x/ibc/04-channel/alias.go @@ -30,6 +30,7 @@ var ( NewCounterparty = types.NewCounterparty NewIdentifiedChannel = types.NewIdentifiedChannel RegisterCodec = types.RegisterCodec + RegisterInterfaces = types.RegisterInterfaces ErrChannelExists = types.ErrChannelExists ErrChannelNotFound = types.ErrChannelNotFound ErrInvalidCounterparty = types.ErrInvalidCounterparty diff --git a/x/ibc/04-channel/client/cli/tx.go b/x/ibc/04-channel/client/cli/tx.go index 16183ae2ec04..db4565fc34a6 100644 --- a/x/ibc/04-channel/client/cli/tx.go +++ b/x/ibc/04-channel/client/cli/tx.go @@ -14,8 +14,8 @@ import ( authclient "github.com/cosmos/cosmos-sdk/x/auth/client" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" connectionutils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) // IBC Channel flags @@ -243,9 +243,9 @@ func GetMsgChannelCloseConfirmCmd(storeKey string, cdc *codec.Codec) *cobra.Comm } } -func channelOrder() exported.Order { +func channelOrder() ibctypes.Order { if viper.GetBool(FlagOrdered) { - return exported.ORDERED + return ibctypes.ORDERED } - return exported.UNORDERED + return ibctypes.UNORDERED } diff --git a/x/ibc/04-channel/client/rest/rest.go b/x/ibc/04-channel/client/rest/rest.go index 2d65fc2d5817..4bb45ad24338 100644 --- a/x/ibc/04-channel/client/rest/rest.go +++ b/x/ibc/04-channel/client/rest/rest.go @@ -5,9 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/types/rest" - "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" + commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) const ( @@ -27,7 +27,7 @@ type ChannelOpenInitReq struct { PortID string `json:"port_id" yaml:"port_id"` ChannelID string `json:"channel_id" yaml:"channel_id"` Version string `json:"version" yaml:"version"` - ChannelOrder exported.Order `json:"channel_order" yaml:"channel_order"` + ChannelOrder ibctypes.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"` @@ -35,32 +35,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 exported.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 commitmentexported.Proof `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 ibctypes.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"` } // 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 commitmentexported.Proof `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 commitmenttypes.MerkleProof `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 commitmentexported.Proof `json:"proof_ack" yaml:"proof_ack"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + 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"` } // ConnectionOpenInitReq defines the properties of a channel close init request's body. @@ -70,15 +70,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 commitmentexported.Proof `json:"proof_init" yaml:"proof_init"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` + 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"` } // 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 commitmentexported.Proof `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 commitmenttypes.MerkleProof `json:"proofs" yaml:"proofs"` + Height uint64 `json:"height" yaml:"height"` } diff --git a/x/ibc/04-channel/exported/exported.go b/x/ibc/04-channel/exported/exported.go index 7ba92b5c9172..ed1dbc531d92 100644 --- a/x/ibc/04-channel/exported/exported.go +++ b/x/ibc/04-channel/exported/exported.go @@ -1,14 +1,13 @@ package exported import ( - "encoding/json" - "fmt" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) // ChannelI defines the standard interface for a channel end. type ChannelI interface { - GetState() State - GetOrdering() Order + GetState() ibctypes.State + GetOrdering() ibctypes.Order GetCounterparty() CounterpartyI GetConnectionHops() []string GetVersion() string @@ -35,137 +34,3 @@ type PacketI interface { GetData() []byte ValidateBasic() error } - -// Order defines if a channel is ORDERED or UNORDERED -type Order byte - -// string representation of the channel ordering -const ( - NONE Order = iota // zero-value for channel ordering - UNORDERED // packets can be delivered in any order, which may differ from the order in which they were sent. - ORDERED // packets are delivered exactly in the order which they were sent -) - -// channel order types -const ( - OrderNone string = "" - OrderUnordered string = "UNORDERED" - OrderOrdered string = "ORDERED" -) - -// String implements the Stringer interface -func (o Order) String() string { - switch o { - case UNORDERED: - return OrderUnordered - case ORDERED: - return OrderOrdered - default: - return OrderNone - } -} - -// MarshalJSON marshal to JSON using string. -func (o Order) MarshalJSON() ([]byte, error) { - return json.Marshal(o.String()) -} - -// UnmarshalJSON decodes from JSON. -func (o *Order) UnmarshalJSON(data []byte) error { - var s string - err := json.Unmarshal(data, &s) - if err != nil { - return err - } - - order := OrderFromString(s) - if order == 0 { - return fmt.Errorf("invalid order '%s'", s) - } - - *o = order - return nil -} - -// OrderFromString parses a string into a channel order byte -func OrderFromString(order string) Order { - switch order { - case OrderUnordered: - return UNORDERED - case OrderOrdered: - return ORDERED - default: - return NONE - } -} - -// State defines if a channel is in one of the following states: -// CLOSED, INIT, OPENTRY or OPEN -type State byte - -// channel state types -const ( - UNINITIALIZED State = iota // Default State - INIT // A channel end has just started the opening handshake. - TRYOPEN // A channel end has acknowledged the handshake step on the counterparty chain. - OPEN // A channel end has completed the handshake and is ready to send and receive packets. - CLOSED // A channel end has been closed and can no longer be used to send or receive packets. -) - -// string representation of the channel states -const ( - StateUninitialized string = "UNINITIALIZED" - StateInit string = "INIT" - StateTryOpen string = "TRYOPEN" - StateOpen string = "OPEN" - StateClosed string = "CLOSED" -) - -// String implements the Stringer interface -func (s State) String() string { - switch s { - case INIT: - return StateInit - case TRYOPEN: - return StateTryOpen - case OPEN: - return StateOpen - case CLOSED: - return StateClosed - default: - return StateUninitialized - } -} - -// MarshalJSON marshal to JSON using string. -func (s State) MarshalJSON() ([]byte, error) { - return json.Marshal(s.String()) -} - -// UnmarshalJSON decodes from JSON. -func (s *State) UnmarshalJSON(data []byte) error { - var stateStr string - err := json.Unmarshal(data, &stateStr) - if err != nil { - return err - } - - *s = StateFromString(stateStr) - return nil -} - -// StateFromString parses a string into a channel state byte -func StateFromString(state string) State { - switch state { - case StateClosed: - return CLOSED - case StateInit: - return INIT - case StateTryOpen: - return TRYOPEN - case StateOpen: - return OPEN - default: - return UNINITIALIZED - } -} diff --git a/x/ibc/04-channel/exported/exported_test.go b/x/ibc/04-channel/exported/exported_test.go deleted file mode 100644 index 51d94bfdebb1..000000000000 --- a/x/ibc/04-channel/exported/exported_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package exported - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestChannelStateString(t *testing.T) { - cases := []struct { - name string - state State - }{ - {StateUninitialized, UNINITIALIZED}, - {StateInit, INIT}, - {StateTryOpen, TRYOPEN}, - {StateOpen, OPEN}, - {StateClosed, CLOSED}, - } - - for _, tt := range cases { - tt := tt - require.Equal(t, tt.state, StateFromString(tt.name)) - require.Equal(t, tt.name, tt.state.String()) - } -} - -func TestChannelStateMarshalJSON(t *testing.T) { - cases := []struct { - name string - state State - }{ - {StateUninitialized, UNINITIALIZED}, - {StateInit, INIT}, - {StateTryOpen, TRYOPEN}, - {StateOpen, OPEN}, - {StateClosed, CLOSED}, - } - - for _, tt := range cases { - tt := tt - bz, err := tt.state.MarshalJSON() - require.NoError(t, err) - var state State - require.NoError(t, state.UnmarshalJSON(bz)) - require.Equal(t, tt.name, state.String()) - } -} - -func TestOrderString(t *testing.T) { - cases := []struct { - name string - order Order - }{ - {OrderNone, NONE}, - {OrderUnordered, UNORDERED}, - {OrderOrdered, ORDERED}, - } - - for _, tt := range cases { - tt := tt - require.Equal(t, tt.order, OrderFromString(tt.name)) - require.Equal(t, tt.name, tt.order.String()) - } -} - -func TestOrderMarshalJSON(t *testing.T) { - cases := []struct { - msg string - name string - order Order - expectPass bool - }{ - {"none ordering should have failed", OrderNone, NONE, false}, - {"unordered should have passed", OrderUnordered, UNORDERED, true}, - {"ordered should have passed", OrderOrdered, ORDERED, true}, - } - - for _, tt := range cases { - tt := tt - bz, err := tt.order.MarshalJSON() - require.NoError(t, err) - var order Order - if tt.expectPass { - require.NoError(t, order.UnmarshalJSON(bz), tt.msg) - require.Equal(t, tt.name, order.String(), tt.msg) - } else { - require.Error(t, order.UnmarshalJSON(bz), tt.msg) - } - } -} diff --git a/x/ibc/04-channel/keeper/handshake.go b/x/ibc/04-channel/keeper/handshake.go index 1c311cca8d80..5ab7042c076e 100644 --- a/x/ibc/04-channel/keeper/handshake.go +++ b/x/ibc/04-channel/keeper/handshake.go @@ -5,9 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/capability" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "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" @@ -35,7 +33,7 @@ func (k Keeper) CounterpartyHops(ctx sdk.Context, ch types.Channel) ([]string, b // a module on another chain. func (k Keeper) ChanOpenInit( ctx sdk.Context, - order exported.Order, + order ibctypes.Order, connectionHops []string, portID, channelID string, @@ -54,7 +52,7 @@ func (k Keeper) ChanOpenInit( return nil, sdkerrors.Wrap(connection.ErrConnectionNotFound, connectionHops[0]) } - if connectionEnd.GetState() == connectionexported.UNINITIALIZED { + if connectionEnd.GetState() == ibctypes.UNINITIALIZED { return nil, sdkerrors.Wrap( connection.ErrInvalidConnectionState, "connection state cannot be UNINITIALIZED", @@ -65,7 +63,7 @@ func (k Keeper) ChanOpenInit( return nil, sdkerrors.Wrap(porttypes.ErrInvalidPort, "caller does not own port capability") } - channel := types.NewChannel(exported.INIT, order, counterparty, connectionHops, version) + channel := types.NewChannel(ibctypes.INIT, order, counterparty, connectionHops, version) k.SetChannel(ctx, portID, channelID, channel) capKey, err := k.scopedKeeper.NewCapability(ctx, ibctypes.ChannelCapabilityPath(portID, channelID)) @@ -84,7 +82,7 @@ func (k Keeper) ChanOpenInit( // handshake initiated by a module on another chain. func (k Keeper) ChanOpenTry( ctx sdk.Context, - order exported.Order, + order ibctypes.Order, connectionHops []string, portID, channelID string, @@ -97,7 +95,7 @@ func (k Keeper) ChanOpenTry( ) (*capability.Capability, error) { // channel identifier and connection hop length checked on msg.ValidateBasic() previousChannel, found := k.GetChannel(ctx, portID, channelID) - if found && !(previousChannel.State == exported.INIT && + if found && !(previousChannel.State == ibctypes.INIT && previousChannel.Ordering == order && previousChannel.Counterparty.PortID == counterparty.PortID && previousChannel.Counterparty.ChannelID == counterparty.ChannelID && @@ -115,7 +113,7 @@ func (k Keeper) ChanOpenTry( return nil, sdkerrors.Wrap(connection.ErrConnectionNotFound, connectionHops[0]) } - if connectionEnd.GetState() != connectionexported.OPEN { + if connectionEnd.GetState() != ibctypes.OPEN { return nil, sdkerrors.Wrapf( connection.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.GetState().String(), @@ -124,7 +122,7 @@ func (k Keeper) ChanOpenTry( // NOTE: this step has been switched with the one below to reverse the connection // hops - channel := types.NewChannel(exported.TRYOPEN, order, counterparty, connectionHops, version) + channel := types.NewChannel(ibctypes.TRYOPEN, order, counterparty, connectionHops, version) counterpartyHops, found := k.CounterpartyHops(ctx, channel) if !found { @@ -136,7 +134,7 @@ func (k Keeper) ChanOpenTry( // (i.e self) expectedCounterparty := types.NewCounterparty(portID, channelID) expectedChannel := types.NewChannel( - exported.INIT, channel.Ordering, expectedCounterparty, + ibctypes.INIT, channel.Ordering, expectedCounterparty, counterpartyHops, counterpartyVersion, ) @@ -177,7 +175,7 @@ func (k Keeper) ChanOpenAck( return sdkerrors.Wrap(types.ErrChannelNotFound, channelID) } - if !(channel.State == exported.INIT || channel.State == exported.TRYOPEN) { + if !(channel.State == ibctypes.INIT || channel.State == ibctypes.TRYOPEN) { return sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel state should be INIT or TRYOPEN (got %s)", channel.State.String(), @@ -193,7 +191,7 @@ func (k Keeper) ChanOpenAck( return sdkerrors.Wrap(connection.ErrConnectionNotFound, channel.ConnectionHops[0]) } - if connectionEnd.GetState() != connectionexported.OPEN { + if connectionEnd.GetState() != ibctypes.OPEN { return sdkerrors.Wrapf( connection.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.GetState().String(), @@ -209,7 +207,7 @@ func (k Keeper) ChanOpenAck( // counterparty of the counterparty channel end (i.e self) expectedCounterparty := types.NewCounterparty(portID, channelID) expectedChannel := types.NewChannel( - exported.TRYOPEN, channel.Ordering, expectedCounterparty, + ibctypes.TRYOPEN, channel.Ordering, expectedCounterparty, counterpartyHops, counterpartyVersion, ) @@ -221,7 +219,7 @@ func (k Keeper) ChanOpenAck( return err } - channel.State = exported.OPEN + channel.State = ibctypes.OPEN channel.Version = counterpartyVersion k.SetChannel(ctx, portID, channelID, channel) @@ -244,7 +242,7 @@ func (k Keeper) ChanOpenConfirm( return sdkerrors.Wrap(types.ErrChannelNotFound, channelID) } - if channel.State != exported.TRYOPEN { + if channel.State != ibctypes.TRYOPEN { return sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel state is not TRYOPEN (got %s)", channel.State.String(), @@ -260,7 +258,7 @@ func (k Keeper) ChanOpenConfirm( return sdkerrors.Wrap(connection.ErrConnectionNotFound, channel.ConnectionHops[0]) } - if connectionEnd.GetState() != connectionexported.OPEN { + if connectionEnd.GetState() != ibctypes.OPEN { return sdkerrors.Wrapf( connection.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.GetState().String(), @@ -275,7 +273,7 @@ func (k Keeper) ChanOpenConfirm( counterparty := types.NewCounterparty(portID, channelID) expectedChannel := types.NewChannel( - exported.OPEN, channel.Ordering, counterparty, + ibctypes.OPEN, channel.Ordering, counterparty, counterpartyHops, channel.Version, ) @@ -287,7 +285,7 @@ func (k Keeper) ChanOpenConfirm( return err } - channel.State = exported.OPEN + channel.State = ibctypes.OPEN k.SetChannel(ctx, portID, channelID, channel) k.Logger(ctx).Info("channel (port-id: %s, channel-id: %s) state updated: TRYOPEN -> OPEN", portID, channelID) @@ -316,7 +314,7 @@ func (k Keeper) ChanCloseInit( return sdkerrors.Wrap(types.ErrChannelNotFound, channelID) } - if channel.State == exported.CLOSED { + if channel.State == ibctypes.CLOSED { return sdkerrors.Wrap(types.ErrInvalidChannelState, "channel is already CLOSED") } @@ -325,7 +323,7 @@ func (k Keeper) ChanCloseInit( return sdkerrors.Wrap(connection.ErrConnectionNotFound, channel.ConnectionHops[0]) } - if connectionEnd.GetState() != connectionexported.OPEN { + if connectionEnd.GetState() != ibctypes.OPEN { return sdkerrors.Wrapf( connection.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.GetState().String(), @@ -334,7 +332,7 @@ func (k Keeper) ChanCloseInit( k.Logger(ctx).Info("channel (port-id: %s, channel-id: %s) state updated: %s -> CLOSED", portID, channelID, channel.State) - channel.State = exported.CLOSED + channel.State = ibctypes.CLOSED k.SetChannel(ctx, portID, channelID, channel) return nil @@ -359,7 +357,7 @@ func (k Keeper) ChanCloseConfirm( return sdkerrors.Wrap(types.ErrChannelNotFound, channelID) } - if channel.State == exported.CLOSED { + if channel.State == ibctypes.CLOSED { return sdkerrors.Wrap(types.ErrInvalidChannelState, "channel is already CLOSED") } @@ -368,7 +366,7 @@ func (k Keeper) ChanCloseConfirm( return sdkerrors.Wrap(connection.ErrConnectionNotFound, channel.ConnectionHops[0]) } - if connectionEnd.GetState() != connectionexported.OPEN { + if connectionEnd.GetState() != ibctypes.OPEN { return sdkerrors.Wrapf( connection.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.GetState().String(), @@ -383,7 +381,7 @@ func (k Keeper) ChanCloseConfirm( counterparty := types.NewCounterparty(portID, channelID) expectedChannel := types.NewChannel( - exported.CLOSED, channel.Ordering, counterparty, + ibctypes.CLOSED, channel.Ordering, counterparty, counterpartyHops, channel.Version, ) @@ -397,7 +395,7 @@ func (k Keeper) ChanCloseConfirm( k.Logger(ctx).Info("channel (port-id: %s, channel-id: %s) state updated: %s -> CLOSED", portID, channelID, channel.State) - channel.State = exported.CLOSED + channel.State = ibctypes.CLOSED k.SetChannel(ctx, portID, channelID, channel) return nil diff --git a/x/ibc/04-channel/keeper/handshake_test.go b/x/ibc/04-channel/keeper/handshake_test.go index eefb7a30cf4d..afe923078966 100644 --- a/x/ibc/04-channel/keeper/handshake_test.go +++ b/x/ibc/04-channel/keeper/handshake_test.go @@ -4,10 +4,7 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/x/capability" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" - porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -19,26 +16,26 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { {"success", func() { suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, - connectionexported.INIT, + ibctypes.INIT, ) }, true}, {"channel already exists", func() { suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.INIT, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.INIT, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"connection doesn't exist", func() {}, false}, {"connection is UNINITIALIZED", func() { suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, - connectionexported.UNINITIALIZED, + ibctypes.UNINITIALIZED, ) }, false}, {"capability is incorrect", func() { suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, - connectionexported.INIT, + ibctypes.INIT, ) portCap = capability.NewCapability(3) }, false}, @@ -52,13 +49,13 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { var err error portCap, err = suite.chainA.App.ScopedIBCKeeper.NewCapability( - suite.chainA.GetContext(), porttypes.PortPath(testPort1), + suite.chainA.GetContext(), ibctypes.PortPath(testPort1), ) suite.Require().NoError(err, "could not create capability") tc.malleate() cap, err := suite.chainA.App.IBCKeeper.ChannelKeeper.ChanOpenInit( - suite.chainA.GetContext(), exported.ORDERED, []string{testConnectionIDA}, + suite.chainA.GetContext(), ibctypes.ORDERED, []string{testConnectionIDA}, testPort1, testChannel1, portCap, counterparty, testChannelVersion, ) @@ -89,36 +86,36 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) suite.chainB.createConnection( - testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.INIT, exported.ORDERED, testConnectionIDA) + testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.INIT, ibctypes.ORDERED, testConnectionIDA) }, true}, {"previous channel with invalid state", func() { _ = suite.chainA.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.UNINITIALIZED, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.UNINITIALIZED, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"connection doesn't exist", func() {}, false}, {"connection is not OPEN", func() { _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.INIT, + ibctypes.INIT, ) }, false}, {"consensus state not found", func() { _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) }, false}, {"channel verification failed", func() { suite.chainA.CreateClient(suite.chainB) _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) }, false}, {"port capability not found", func() { @@ -126,11 +123,11 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) suite.chainB.createConnection( - testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.INIT, exported.ORDERED, testConnectionIDA) + testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.INIT, ibctypes.ORDERED, testConnectionIDA) portCap = capability.NewCapability(3) }, false}, } @@ -142,7 +139,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { suite.SetupTest() // reset var err error - portCap, err = suite.chainA.App.ScopedIBCKeeper.NewCapability(suite.chainA.GetContext(), porttypes.PortPath(testPort2)) + portCap, err = suite.chainA.App.ScopedIBCKeeper.NewCapability(suite.chainA.GetContext(), ibctypes.PortPath(testPort2)) suite.Require().NoError(err, "could not create capability") tc.malleate() @@ -153,7 +150,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { if tc.expPass { cap, err := suite.chainA.App.IBCKeeper.ChannelKeeper.ChanOpenTry( - suite.chainA.GetContext(), exported.ORDERED, []string{testConnectionIDB}, + suite.chainA.GetContext(), ibctypes.ORDERED, []string{testConnectionIDB}, testPort2, testChannel2, portCap, counterparty, testChannelVersion, testChannelVersion, proof, proofHeight+1, ) @@ -167,7 +164,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { suite.Require().Equal(chanCap.String(), cap.String(), "channel capability is not correct") } else { _, err := suite.chainA.App.IBCKeeper.ChannelKeeper.ChanOpenTry( - suite.chainA.GetContext(), exported.ORDERED, []string{testConnectionIDB}, + suite.chainA.GetContext(), ibctypes.ORDERED, []string{testConnectionIDB}, testPort2, testChannel2, portCap, counterparty, testChannelVersion, testChannelVersion, invalidProof{}, proofHeight, ) @@ -187,63 +184,63 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { suite.chainB.CreateClient(suite.chainA) suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.INIT, - exported.ORDERED, testConnectionIDB, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.INIT, + ibctypes.ORDERED, testConnectionIDB, ) suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.TRYOPEN, - exported.ORDERED, testConnectionIDA, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, true}, {"channel doesn't exist", func() {}, false}, {"channel state is not INIT or TRYOPEN", func() { _ = suite.chainB.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.UNINITIALIZED, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.UNINITIALIZED, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"connection not found", func() { _ = suite.chainB.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.TRYOPEN, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"connection is not OPEN", func() { _ = suite.chainB.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.TRYOPEN, + ibctypes.TRYOPEN, ) _ = suite.chainB.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.TRYOPEN, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"consensus state not found", func() { _ = suite.chainB.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.TRYOPEN, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"channel verification failed", func() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainB.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.TRYOPEN, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"channel capability not found", func() { @@ -251,19 +248,19 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { suite.chainB.CreateClient(suite.chainA) suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.INIT, - exported.ORDERED, testConnectionIDB, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.INIT, + ibctypes.ORDERED, testConnectionIDB, ) suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.TRYOPEN, - exported.ORDERED, testConnectionIDA, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDA, ) channelCap = capability.NewCapability(3) }, false}, @@ -312,61 +309,61 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.TRYOPEN, + ibctypes.TRYOPEN, ) - suite.chainB.createConnection( + _ = suite.chainB.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDB, ) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, - exported.TRYOPEN, exported.ORDERED, testConnectionIDA) + _ = suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, + ibctypes.TRYOPEN, ibctypes.ORDERED, testConnectionIDA) }, true}, {"channel doesn't exist", func() {}, false}, {"channel state is not TRYOPEN", func() { _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.UNINITIALIZED, - exported.ORDERED, testConnectionIDB, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.UNINITIALIZED, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"connection not found", func() { _ = suite.chainA.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.TRYOPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"connection is not OPEN", func() { _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.TRYOPEN, + ibctypes.TRYOPEN, ) _ = suite.chainA.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.TRYOPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"consensus state not found", func() { _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.TRYOPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"channel verification failed", func() { suite.chainA.CreateClient(suite.chainB) _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.TRYOPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.TRYOPEN, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"channel capability not found", func() { @@ -374,18 +371,18 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainA.createConnection( testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, - connectionexported.TRYOPEN, + ibctypes.TRYOPEN, ) suite.chainB.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDB, ) suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, - exported.TRYOPEN, exported.ORDERED, testConnectionIDA) + ibctypes.TRYOPEN, ibctypes.ORDERED, testConnectionIDA) channelCap = capability.NewCapability(3) }, false}, } @@ -430,45 +427,45 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, true}, {"channel doesn't exist", func() {}, false}, {"channel state is CLOSED", func() { _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, - exported.ORDERED, testConnectionIDB, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.CLOSED, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"connection not found", func() { _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"connection is not OPEN", func() { _ = suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.TRYOPEN, + ibctypes.TRYOPEN, ) _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.UNINITIALIZED, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.UNINITIALIZED, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"channel capability not found", func() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDA, ) channelCap = capability.NewCapability(3) }, false}, @@ -508,63 +505,63 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainB.createConnection( testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDB, ) suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.CLOSED, + ibctypes.ORDERED, testConnectionIDA, ) }, true}, {"channel doesn't exist", func() {}, false}, {"channel state is CLOSED", func() { _ = suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.CLOSED, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.CLOSED, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"connection not found", func() { _ = suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDA, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, {"connection is not OPEN", func() { _ = suite.chainB.createConnection( testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, - connectionexported.TRYOPEN, + ibctypes.TRYOPEN, ) _ = suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"consensus state not found", func() { _ = suite.chainB.createConnection( testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"channel verification failed", func() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainB.createConnection( testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDB, ) }, false}, {"channel capability not found", func() { @@ -572,19 +569,19 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { suite.chainB.CreateClient(suite.chainA) _ = suite.chainB.createConnection( testConnectionIDB, testConnectionIDA, testClientIDA, testClientIDB, - connectionexported.OPEN, + ibctypes.OPEN, ) suite.chainA.createConnection( testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, - connectionexported.OPEN, + ibctypes.OPEN, ) _ = suite.chainB.createChannel( - testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, - exported.ORDERED, testConnectionIDB, + testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, + ibctypes.ORDERED, testConnectionIDB, ) suite.chainA.createChannel( - testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, - exported.ORDERED, testConnectionIDA, + testPort1, testChannel1, testPort2, testChannel2, ibctypes.CLOSED, + ibctypes.ORDERED, testConnectionIDA, ) }, false}, } diff --git a/x/ibc/04-channel/keeper/keeper.go b/x/ibc/04-channel/keeper/keeper.go index c2716fc8dcc8..8526bb78f227 100644 --- a/x/ibc/04-channel/keeper/keeper.go +++ b/x/ibc/04-channel/keeper/keeper.go @@ -19,7 +19,7 @@ import ( // Keeper defines the IBC channel keeper type Keeper struct { storeKey sdk.StoreKey - cdc *codec.Codec + cdc codec.Marshaler clientKeeper types.ClientKeeper connectionKeeper types.ConnectionKeeper portKeeper types.PortKeeper @@ -28,7 +28,7 @@ type Keeper struct { // NewKeeper creates a new IBC channel Keeper instance func NewKeeper( - cdc *codec.Codec, key sdk.StoreKey, + cdc codec.Marshaler, key sdk.StoreKey, clientKeeper types.ClientKeeper, connectionKeeper types.ConnectionKeeper, portKeeper types.PortKeeper, scopedKeeper capability.ScopedKeeper, ) Keeper { @@ -63,7 +63,7 @@ func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Cha // SetChannel sets a channel to the store func (k Keeper) SetChannel(ctx sdk.Context, portID, channelID string, channel types.Channel) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryBare(channel) + bz := k.cdc.MustMarshalBinaryBare(&channel) store.Set(ibctypes.KeyChannel(portID, channelID), bz) } diff --git a/x/ibc/04-channel/keeper/keeper_test.go b/x/ibc/04-channel/keeper/keeper_test.go index 633f1380e0d2..63f777ae58a8 100644 --- a/x/ibc/04-channel/keeper/keeper_test.go +++ b/x/ibc/04-channel/keeper/keeper_test.go @@ -14,9 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - 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" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" @@ -41,7 +39,7 @@ const ( testChannel2 = "secondchannel" testChannel3 = "thirdchannel" - testChannelOrder = exported.ORDERED + testChannelOrder = ibctypes.ORDERED testChannelVersion = "1.0" trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 @@ -77,7 +75,7 @@ func (suite *KeeperTestSuite) TestSetChannel() { counterparty2 := types.NewCounterparty(testPort2, testChannel2) channel := types.NewChannel( - exported.INIT, testChannelOrder, + ibctypes.INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion, ) suite.chainB.App.IBCKeeper.ChannelKeeper.SetChannel(ctx, testPort1, testChannel1, channel) @@ -94,15 +92,15 @@ func (suite KeeperTestSuite) TestGetAllChannels() { counterparty3 := types.NewCounterparty(testPort3, testChannel3) channel1 := types.NewChannel( - exported.INIT, testChannelOrder, + ibctypes.INIT, testChannelOrder, counterparty3, []string{testConnectionIDA}, testChannelVersion, ) channel2 := types.NewChannel( - exported.INIT, testChannelOrder, + ibctypes.INIT, testChannelOrder, counterparty1, []string{testConnectionIDA}, testChannelVersion, ) channel3 := types.NewChannel( - exported.CLOSED, testChannelOrder, + ibctypes.CLOSED, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion, ) @@ -287,7 +285,7 @@ func NewTestChain(clientID string) *TestChain { // Creates simple context for testing purposes func (chain *TestChain) GetContext() sdk.Context { - return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.ChainID, Height: chain.Header.Height}) + return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: int64(chain.Header.GetHeight())}) } // createClient will create a client for clientChain on targetChain @@ -296,7 +294,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { // Commit and create a new block on appTarget to get a fresh CommitID client.App.Commit() commitID := client.App.LastCommitID() - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: int64(client.Header.GetHeight()), Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -312,7 +310,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, int64(client.Header.GetHeight()), histInfo) // Create target ctx ctxTarget := chain.GetContext() @@ -357,7 +355,7 @@ func (chain *TestChain) updateClient(client *TestChain) { commitID := client.App.LastCommitID() client.Header = nextHeader(client) - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: int64(client.Header.GetHeight()), Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -373,17 +371,17 @@ func (chain *TestChain) updateClient(client *TestChain) { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, int64(client.Header.GetHeight()), histInfo) consensusState := ibctmtypes.ConsensusState{ - Height: uint64(client.Header.Height), + Height: client.Header.GetHeight(), Timestamp: client.Header.Time, Root: commitmenttypes.NewMerkleRoot(commitID.Hash), ValidatorSet: client.Vals, } chain.App.IBCKeeper.ClientKeeper.SetClientConsensusState( - ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, + ctxTarget, client.ClientID, client.Header.GetHeight(), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), @@ -404,9 +402,9 @@ func (chain *TestChain) updateClient(client *TestChain) { func (chain *TestChain) createConnection( connID, counterpartyConnID, clientID, counterpartyClientID string, - state connectionexported.State, + state ibctypes.State, ) connectiontypes.ConnectionEnd { - counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) + counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) connection := connectiontypes.ConnectionEnd{ State: state, ClientID: clientID, @@ -420,7 +418,7 @@ func (chain *TestChain) createConnection( func (chain *TestChain) createChannel( portID, channelID, counterpartyPortID, counterpartyChannelID string, - state exported.State, order exported.Order, connectionID string, + state ibctypes.State, order ibctypes.Order, connectionID string, ) types.Channel { counterparty := types.NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := types.NewChannel(state, order, counterparty, @@ -432,7 +430,7 @@ func (chain *TestChain) createChannel( } func nextHeader(chain *TestChain) ibctmtypes.Header { - return ibctmtypes.CreateTestHeader(chain.Header.ChainID, chain.Header.Height+1, + return ibctmtypes.CreateTestHeader(chain.Header.SignedHeader.Header.ChainID, int64(chain.Header.GetHeight())+1, chain.Header.Time.Add(time.Minute), chain.Vals, chain.Signers) } diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index 4a35e8039460..8e0e2eb32361 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/capability" client "github.com/cosmos/cosmos-sdk/x/ibc/02-client" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" "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" @@ -34,7 +33,7 @@ func (k Keeper) SendPacket( return sdkerrors.Wrap(types.ErrChannelNotFound, packet.GetSourceChannel()) } - if channel.State == exported.CLOSED { + if channel.State == ibctypes.CLOSED { return sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel is CLOSED (got %s)", channel.State.String(), @@ -65,7 +64,7 @@ func (k Keeper) SendPacket( } // NOTE: assume UNINITIALIZED is a closed connection - if connectionEnd.GetState() == connectionexported.UNINITIALIZED { + if connectionEnd.GetState() == ibctypes.UNINITIALIZED { return sdkerrors.Wrap( connection.ErrInvalidConnectionState, "connection is closed (i.e NONE)", @@ -147,7 +146,7 @@ func (k Keeper) RecvPacket( return nil, sdkerrors.Wrap(types.ErrChannelNotFound, packet.GetDestChannel()) } - if channel.State != exported.OPEN { + if channel.State != ibctypes.OPEN { return nil, sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel state is not OPEN (got %s)", channel.State.String(), @@ -177,7 +176,7 @@ func (k Keeper) RecvPacket( return nil, sdkerrors.Wrap(connection.ErrConnectionNotFound, channel.ConnectionHops[0]) } - if connectionEnd.GetState() != connectionexported.OPEN { + if connectionEnd.GetState() != ibctypes.OPEN { return nil, sdkerrors.Wrapf( connection.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.GetState().String(), @@ -226,7 +225,7 @@ func (k Keeper) PacketExecuted( } // sanity check - if channel.State != exported.OPEN { + if channel.State != ibctypes.OPEN { return sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel state is not OPEN (got %s)", channel.State.String(), @@ -238,14 +237,14 @@ func (k Keeper) PacketExecuted( return sdkerrors.Wrap(types.ErrInvalidChannelCapability, "channel capability failed authentication") } - if acknowledgement != nil || channel.Ordering == exported.UNORDERED { + if acknowledgement != nil || channel.Ordering == ibctypes.UNORDERED { k.SetPacketAcknowledgement( ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), types.CommitAcknowledgement(acknowledgement), ) } - if channel.Ordering == exported.ORDERED { + if channel.Ordering == ibctypes.ORDERED { nextSequenceRecv, found := k.GetNextSequenceRecv(ctx, packet.GetDestPort(), packet.GetDestChannel()) if !found { return types.ErrSequenceReceiveNotFound @@ -302,7 +301,7 @@ func (k Keeper) AcknowledgePacket( return nil, sdkerrors.Wrap(types.ErrChannelNotFound, packet.GetSourceChannel()) } - if channel.State != exported.OPEN { + if channel.State != ibctypes.OPEN { return nil, sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel state is not OPEN (got %s)", channel.State.String(), @@ -332,7 +331,7 @@ func (k Keeper) AcknowledgePacket( return nil, sdkerrors.Wrap(connection.ErrConnectionNotFound, channel.ConnectionHops[0]) } - if connectionEnd.GetState() != connectionexported.OPEN { + if connectionEnd.GetState() != ibctypes.OPEN { return nil, sdkerrors.Wrapf( connection.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.GetState().String(), @@ -396,7 +395,7 @@ func (k Keeper) CleanupPacket( return nil, sdkerrors.Wrap(types.ErrChannelNotFound, packet.GetSourceChannel()) } - if channel.State != exported.OPEN { + if channel.State != ibctypes.OPEN { return nil, sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel state is not OPEN (got %s)", channel.State.String(), @@ -447,13 +446,13 @@ func (k Keeper) CleanupPacket( var err error switch channel.Ordering { - case exported.ORDERED: + case ibctypes.ORDERED: // check that the recv sequence is as claimed err = k.connectionKeeper.VerifyNextSequenceRecv( ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv, ) - case exported.UNORDERED: + case ibctypes.UNORDERED: err = k.connectionKeeper.VerifyPacketAcknowledgement( ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index 5bc4e00ff3e1..05c05ee88f99 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/x/capability" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" @@ -21,8 +20,8 @@ func (suite *KeeperTestSuite) TestSendPacket() { {"success", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainB.GetContext(), testPort1, testChannel1, 1) }, true}, {"packet basic validation failed", func() { @@ -33,62 +32,62 @@ func (suite *KeeperTestSuite) TestSendPacket() { }, false}, {"channel closed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.CLOSED, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet dest port ≠ channel counterparty port", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, testPort3, counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet dest channel ID ≠ channel counterparty channel ID", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), testChannel3, timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection is UNINITIALIZED", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.UNINITIALIZED) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.UNINITIALIZED) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"client state not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"timeout height passed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) commitNBlocks(suite.chainB, 10) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"timeout timestamp passed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), disabledTimeoutHeight, timeoutTimestamp) commitBlockWithNewTimestamp(suite.chainB, timeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"next sequence send not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"next sequence wrong", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainB.GetContext(), testPort1, testChannel1, 5) }, false}, {"channel capability not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainB.GetContext(), testPort1, testChannel1, 1) channelCap = capability.NewCapability(3) }, false}, @@ -127,10 +126,10 @@ func (suite *KeeperTestSuite) TestRecvPacket() { {"success", func() { suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDB) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDB) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort2, testChannel2, 1) packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort2, testChannel2, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), testPort2, testChannel2, 1, types.CommitPacket(packet)) @@ -139,41 +138,35 @@ func (suite *KeeperTestSuite) TestRecvPacket() { {"channel not found", func() {}, false}, {"channel not open", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.INIT, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.INIT, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source port ≠ channel counterparty port", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort2, testChannel2, testPort3, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort2, testChannel2, testPort3, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source channel ID ≠ channel counterparty channel ID", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel3, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not OPEN", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT) - suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.INIT) + suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"timeout height passed", func() { commitNBlocks(suite.chainB, 10) packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) - }, false}, - {"timeout timestamp passed", func() { - commitBlockWithNewTimestamp(suite.chainB, timeoutTimestamp) - packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), disabledTimeoutHeight, timeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"validation failed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, } @@ -210,31 +203,31 @@ func (suite *KeeperTestSuite) TestPacketExecuted() { testCases := []testCase{ {"success: UNORDERED", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1) }, true}, {"success: ORDERED", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1) }, true}, {"channel not found", func() {}, false}, {"channel not OPEN", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.CLOSED, exported.ORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.CLOSED, ibctypes.ORDERED, testConnectionIDA) }, false}, {"next sequence receive not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet sequence ≠ next sequence receive", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 5) }, false}, {"capability not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), testPort2, testChannel2, 1) channelCap = capability.NewCapability(3) }, false}, @@ -276,44 +269,44 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.ORDERED, testConnectionIDB) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDB) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet)) suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), testPort2, testChannel2, 1, types.CommitAcknowledgement(ack)) }, true}, {"channel not found", func() {}, false}, {"channel not open", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.CLOSED, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source port ≠ channel counterparty port", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source channel ID ≠ channel counterparty channel ID", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not OPEN", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.INIT) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet hasn't been sent", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet ack verification failed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet)) }, false}, } @@ -358,58 +351,58 @@ func (suite *KeeperTestSuite) TestCleanupPacket() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainA.CreateClient(suite.chainB) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDB) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDB) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet)) suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), testPort2, testChannel2, 1, types.CommitAcknowledgement(ack)) }, true}, {"channel not found", func() {}, false}, {"channel not open", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.CLOSED, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source port ≠ channel counterparty port", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source channel ID ≠ channel counterparty channel ID", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not OPEN", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.INIT) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.INIT) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet already received ", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 10, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet hasn't been sent", func() { nextSeqRecv = 10 packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"next seq receive verification failed", func() { nextSeqRecv = 10 packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet)) }, false}, {"packet ack verification failed", func() { nextSeqRecv = 10 packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 1, types.CommitPacket(packet)) }, false}, } diff --git a/x/ibc/04-channel/keeper/timeout.go b/x/ibc/04-channel/keeper/timeout.go index 4ef456b927b7..2647bdefefd9 100644 --- a/x/ibc/04-channel/keeper/timeout.go +++ b/x/ibc/04-channel/keeper/timeout.go @@ -34,7 +34,7 @@ func (k Keeper) TimeoutPacket( ) } - if channel.State != exported.OPEN { + if channel.State != ibctypes.OPEN { return nil, sdkerrors.Wrapf( types.ErrInvalidChannelState, "channel state is not OPEN (got %s)", channel.State.String(), @@ -85,7 +85,7 @@ func (k Keeper) TimeoutPacket( } switch channel.Ordering { - case exported.ORDERED: + case ibctypes.ORDERED: // check that packet has not been received if nextSequenceRecv > packet.GetSequence() { return nil, sdkerrors.Wrap(types.ErrInvalidPacket, "packet already received") @@ -96,7 +96,7 @@ func (k Keeper) TimeoutPacket( ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv, ) - case exported.UNORDERED: + case ibctypes.UNORDERED: err = k.connectionKeeper.VerifyPacketAcknowledgementAbsence( ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), @@ -142,8 +142,8 @@ func (k Keeper) TimeoutExecuted(ctx sdk.Context, chanCap *capability.Capability, k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - if channel.Ordering == exported.ORDERED { - channel.State = exported.CLOSED + if channel.Ordering == ibctypes.ORDERED { + channel.State = ibctypes.CLOSED k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) } @@ -212,7 +212,7 @@ func (k Keeper) TimeoutOnClose( counterparty := types.NewCounterparty(packet.GetSourcePort(), packet.GetSourceChannel()) expectedChannel := types.NewChannel( - exported.CLOSED, channel.Ordering, counterparty, counterpartyHops, channel.Version, + ibctypes.CLOSED, channel.Ordering, counterparty, counterpartyHops, channel.Version, ) // check that the opposing channel end has closed @@ -226,13 +226,13 @@ func (k Keeper) TimeoutOnClose( var err error switch channel.Ordering { - case exported.ORDERED: + case ibctypes.ORDERED: // check that the recv sequence is as claimed err = k.connectionKeeper.VerifyNextSequenceRecv( ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv, ) - case exported.UNORDERED: + case ibctypes.UNORDERED: err = k.connectionKeeper.VerifyPacketAcknowledgementAbsence( ctx, connectionEnd, proofHeight, proof, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), diff --git a/x/ibc/04-channel/keeper/timeout_test.go b/x/ibc/04-channel/keeper/timeout_test.go index 61ab13f218fd..fa8c4027ed75 100644 --- a/x/ibc/04-channel/keeper/timeout_test.go +++ b/x/ibc/04-channel/keeper/timeout_test.go @@ -4,8 +4,6 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/x/capability" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -24,58 +22,58 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), 1, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.OPEN, exported.UNORDERED, testConnectionIDB) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainA.createConnection(testConnectionIDA, testConnectionIDB, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDB) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet)) }, true}, {"channel not found", func() {}, false}, {"channel not open", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.CLOSED, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.CLOSED, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source port ≠ channel counterparty port", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet source channel ID ≠ channel counterparty channel ID", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"timeout", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 10, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet already received ", func() { nextSeqRecv = 2 packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet hasn't been sent", func() { nextSeqRecv = 1 packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"next seq receive verification failed", func() { nextSeqRecv = 1 packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet)) }, false}, {"packet ack verification failed", func() { nextSeqRecv = 1 packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet)) }, false}, } @@ -111,14 +109,14 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { var chanCap *capability.Capability testCases := []testCase{ {"success ORDERED", func() { - packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 3, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, timeoutHeight, disabledTimeoutTimestamp) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, true}, {"channel not found", func() {}, false}, {"incorrect capability", func() { - packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, 3, disabledTimeoutTimestamp) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) - chanCap = capability.NewCapability(1) + packet = types.NewPacket(newMockTimeoutPacket().GetBytes(), 1, testPort1, testChannel1, testPort2, testChannel2, timeoutHeight, disabledTimeoutTimestamp) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) + chanCap = capability.NewCapability(100) }, false}, } @@ -160,52 +158,52 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) suite.chainA.CreateClient(suite.chainB) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA) - suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, exported.CLOSED, exported.UNORDERED, testConnectionIDB) // channel on chainA is closed + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainA.createConnection(testConnectionIDB, testConnectionIDA, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) + suite.chainA.createChannel(testPort2, testChannel2, testPort1, testChannel1, ibctypes.CLOSED, ibctypes.UNORDERED, testConnectionIDB) // channel on chainA is closed suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet)) suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv) }, true}, {"channel not found", func() {}, false}, {"packet dest port ≠ channel counterparty port", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort3, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet dest channel ID ≠ channel counterparty channel ID", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel3, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"connection not found", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"packet hasn't been sent", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) }, false}, {"channel verification failed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet)) suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv) }, false}, {"next seq receive verification failed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet)) suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv) }, false}, {"packet ack verification failed", func() { packet = types.NewPacket(mockSuccessPacket{}.GetBytes(), 2, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID(), timeoutHeight, disabledTimeoutTimestamp) suite.chainB.CreateClient(suite.chainA) - suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, connectionexported.OPEN) - suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.UNORDERED, testConnectionIDA) + suite.chainB.createConnection(testConnectionIDA, testConnectionIDB, testClientIDA, testClientIDB, ibctypes.OPEN) + suite.chainB.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.UNORDERED, testConnectionIDA) suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainB.GetContext(), testPort1, testChannel1, 2, types.CommitPacket(packet)) suite.chainB.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainB.GetContext(), testPort1, testChannel1, nextSeqRecv) }, false}, diff --git a/x/ibc/04-channel/types/channel.go b/x/ibc/04-channel/types/channel.go index a68e8ec465c3..11c5c7cb6ff1 100644 --- a/x/ibc/04-channel/types/channel.go +++ b/x/ibc/04-channel/types/channel.go @@ -9,19 +9,15 @@ import ( ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) -// Channel defines... -type Channel struct { - State exported.State `json:"state" yaml:"state"` - Ordering exported.Order `json:"ordering" yaml:"ordering"` - Counterparty Counterparty `json:"counterparty" yaml:"counterparty"` - ConnectionHops []string `json:"connection_hops" yaml:"connection_hops"` - Version string `json:"version" yaml:"version "` -} +var ( + _ exported.ChannelI = (*Channel)(nil) + _ exported.CounterpartyI = (*Counterparty)(nil) +) // NewChannel creates a new Channel instance func NewChannel( - state exported.State, ordering exported.Order, - counterparty Counterparty, hops []string, version string, + state ibctypes.State, ordering ibctypes.Order, counterparty Counterparty, + hops []string, version string, ) Channel { return Channel{ State: state, @@ -33,12 +29,12 @@ func NewChannel( } // GetState implements Channel interface. -func (ch Channel) GetState() exported.State { +func (ch Channel) GetState() ibctypes.State { return ch.State } // GetOrdering implements Channel interface. -func (ch Channel) GetOrdering() exported.Order { +func (ch Channel) GetOrdering() ibctypes.Order { return ch.Ordering } @@ -62,8 +58,8 @@ func (ch Channel) ValidateBasic() error { if ch.State.String() == "" { return sdkerrors.Wrap(ErrInvalidChannel, ErrInvalidChannelState.Error()) } - if ch.Ordering.String() == "" { - return sdkerrors.Wrap(ErrInvalidChannel, ErrInvalidChannelOrdering.Error()) + if !(ch.Ordering == ibctypes.ORDERED || ch.Ordering == ibctypes.UNORDERED) { + return sdkerrors.Wrap(ErrInvalidChannelOrdering, ch.Ordering.String()) } if len(ch.ConnectionHops) != 1 { return sdkerrors.Wrap( @@ -86,12 +82,6 @@ func (ch Channel) ValidateBasic() error { return ch.Counterparty.ValidateBasic() } -// Counterparty defines the counterparty chain's channel and port identifiers -type Counterparty struct { - PortID string `json:"port_id" yaml:"port_id"` - ChannelID string `json:"channel_id" yaml:"channel_id"` -} - // NewCounterparty returns a new Counterparty instance func NewCounterparty(portID, channelID string) Counterparty { return Counterparty{ @@ -132,8 +122,8 @@ func (c Counterparty) ValidateBasic() error { type IdentifiedChannel struct { ID string `json:"id" yaml:"id"` PortID string `json:"port_id" yaml:"port_id"` - State exported.State `json:"state" yaml:"state"` - Ordering exported.Order `json:"ordering" yaml:"ordering"` + State ibctypes.State `json:"state" yaml:"state"` + Ordering ibctypes.Order `json:"ordering" yaml:"ordering"` Counterparty Counterparty `json:"counterparty" yaml:"counterparty"` ConnectionHops []string `json:"connection_hops" yaml:"connection_hops"` Version string `json:"version" yaml:"version "` diff --git a/x/ibc/04-channel/types/codec.go b/x/ibc/04-channel/types/codec.go index 3217e9b63d59..66e0e65ac331 100644 --- a/x/ibc/04-channel/types/codec.go +++ b/x/ibc/04-channel/types/codec.go @@ -2,23 +2,13 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - client "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) -// SubModuleCdc defines the IBC channel codec. -var SubModuleCdc *codec.Codec - -func init() { - SubModuleCdc = codec.New() - commitmenttypes.RegisterCodec(SubModuleCdc) - client.RegisterCodec(SubModuleCdc) - RegisterCodec(SubModuleCdc) -} - -// RegisterCodec registers all the necessary types and interfaces for the -// IBC channel. +// RegisterCodec registers the necessary x/ibc/04-channel interfaces and concrete types +// on the provided Amino codec. These types are used for Amino JSON serialization. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.PacketI)(nil), nil) cdc.RegisterConcrete(Channel{}, "ibc/channel/Channel", nil) @@ -30,15 +20,41 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgChannelOpenConfirm{}, "ibc/channel/MsgChannelOpenConfirm", nil) cdc.RegisterConcrete(MsgChannelCloseInit{}, "ibc/channel/MsgChannelCloseInit", nil) cdc.RegisterConcrete(MsgChannelCloseConfirm{}, "ibc/channel/MsgChannelCloseConfirm", nil) - cdc.RegisterConcrete(MsgPacket{}, "ibc/channel/MsgPacket", nil) cdc.RegisterConcrete(MsgAcknowledgement{}, "ibc/channel/MsgAcknowledgement", nil) cdc.RegisterConcrete(MsgTimeout{}, "ibc/channel/MsgTimeout", nil) +} - SetSubModuleCodec(cdc) +// RegisterInterfaces register the ibc channel submodule interfaces to protobuf +// Any. +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgChannelOpenInit{}, + &MsgChannelOpenTry{}, + &MsgChannelOpenAck{}, + &MsgChannelOpenConfirm{}, + &MsgChannelCloseInit{}, + &MsgChannelCloseConfirm{}, + &MsgPacket{}, + &MsgAcknowledgement{}, + &MsgTimeout{}, + ) } -// SetSubModuleCodec sets the ibc channel codec -func SetSubModuleCodec(cdc *codec.Codec) { - SubModuleCdc = cdc +var ( + amino = codec.New() + + // SubModuleCdc references the global x/ibc/04-channel module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/ibc/04-channel and + // defined at the application level. + SubModuleCdc = codec.NewHybridCodec(amino, cdctypes.NewInterfaceRegistry()) +) + +func init() { + RegisterCodec(amino) + amino.Seal() } diff --git a/x/ibc/04-channel/types/genesis_test.go b/x/ibc/04-channel/types/genesis_test.go index dc9e55ec8b89..c96025f74f6c 100644 --- a/x/ibc/04-channel/types/genesis_test.go +++ b/x/ibc/04-channel/types/genesis_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) const ( @@ -16,7 +16,7 @@ const ( testChannel1 = "firstchannel" testChannel2 = "secondchannel" - testChannelOrder = exported.ORDERED + testChannelOrder = ibctypes.ORDERED testChannelVersion = "1.0" ) @@ -39,12 +39,12 @@ func TestValidateGenesis(t *testing.T) { []IdentifiedChannel{ NewIdentifiedChannel( testPort1, testChannel1, NewChannel( - exported.INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion, + ibctypes.INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion, ), ), NewIdentifiedChannel( testPort2, testChannel2, NewChannel( - exported.INIT, testChannelOrder, counterparty1, []string{testConnectionIDA}, testChannelVersion, + ibctypes.INIT, testChannelOrder, counterparty1, []string{testConnectionIDA}, testChannelVersion, ), ), }, @@ -69,7 +69,7 @@ func TestValidateGenesis(t *testing.T) { Channels: []IdentifiedChannel{ NewIdentifiedChannel( testPort1, "testChannel1", NewChannel( - exported.INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion, + ibctypes.INIT, testChannelOrder, counterparty2, []string{testConnectionIDA}, testChannelVersion, ), ), }, diff --git a/x/ibc/04-channel/types/msgs.go b/x/ibc/04-channel/types/msgs.go index f003bdafb627..cb2e139bd3c9 100644 --- a/x/ibc/04-channel/types/msgs.go +++ b/x/ibc/04-channel/types/msgs.go @@ -6,8 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" - commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" @@ -15,20 +13,13 @@ import ( var _ sdk.Msg = MsgChannelOpenInit{} -type MsgChannelOpenInit struct { - PortID string `json:"port_id"` - ChannelID string `json:"channel_id"` - Channel Channel `json:"channel"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgChannelOpenInit creates a new MsgChannelCloseInit MsgChannelOpenInit func NewMsgChannelOpenInit( - portID, channelID string, version string, channelOrder exported.Order, connectionHops []string, + portID, channelID string, version string, channelOrder ibctypes.Order, connectionHops []string, counterpartyPortID, counterpartyChannelID string, signer sdk.AccAddress, ) MsgChannelOpenInit { counterparty := NewCounterparty(counterpartyPortID, counterpartyChannelID) - channel := NewChannel(exported.INIT, channelOrder, counterparty, connectionHops, version) + channel := NewChannel(ibctypes.INIT, channelOrder, counterparty, connectionHops, version) return MsgChannelOpenInit{ PortID: portID, ChannelID: channelID, @@ -71,24 +62,14 @@ func (msg MsgChannelOpenInit) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgChannelOpenTry{} -type MsgChannelOpenTry struct { - PortID string `json:"port_id"` - ChannelID string `json:"channel_id"` - Channel Channel `json:"channel"` - CounterpartyVersion string `json:"counterparty_version"` - ProofInit commitmentexported.Proof `json:"proof_init"` - ProofHeight uint64 `json:"proof_height"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgChannelOpenTry creates a new MsgChannelOpenTry instance func NewMsgChannelOpenTry( - portID, channelID, version string, channelOrder exported.Order, connectionHops []string, + portID, channelID, version string, channelOrder ibctypes.Order, connectionHops []string, counterpartyPortID, counterpartyChannelID, counterpartyVersion string, - proofInit commitmentexported.Proof, proofHeight uint64, signer sdk.AccAddress, + proofInit commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, ) MsgChannelOpenTry { counterparty := NewCounterparty(counterpartyPortID, counterpartyChannelID) - channel := NewChannel(exported.INIT, channelOrder, counterparty, connectionHops, version) + channel := NewChannel(ibctypes.INIT, channelOrder, counterparty, connectionHops, version) return MsgChannelOpenTry{ PortID: portID, ChannelID: channelID, @@ -121,7 +102,7 @@ func (msg MsgChannelOpenTry) ValidateBasic() error { if strings.TrimSpace(msg.CounterpartyVersion) == "" { return sdkerrors.Wrap(ErrInvalidCounterparty, "counterparty version cannot be blank") } - if msg.ProofInit == nil { + if msg.ProofInit.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.ProofInit.ValidateBasic(); err != nil { @@ -146,18 +127,9 @@ func (msg MsgChannelOpenTry) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgChannelOpenAck{} -type MsgChannelOpenAck struct { - PortID string `json:"port_id"` - ChannelID string `json:"channel_id"` - CounterpartyVersion string `json:"counterparty_version"` - ProofTry commitmentexported.Proof `json:"proof_try"` - ProofHeight uint64 `json:"proof_height"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgChannelOpenAck creates a new MsgChannelOpenAck instance func NewMsgChannelOpenAck( - portID, channelID string, cpv string, proofTry commitmentexported.Proof, proofHeight uint64, + portID, channelID string, cpv string, proofTry commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, ) MsgChannelOpenAck { return MsgChannelOpenAck{ @@ -191,7 +163,7 @@ func (msg MsgChannelOpenAck) ValidateBasic() error { if strings.TrimSpace(msg.CounterpartyVersion) == "" { return sdkerrors.Wrap(ErrInvalidCounterparty, "counterparty version cannot be blank") } - if msg.ProofTry == nil { + if msg.ProofTry.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.ProofTry.ValidateBasic(); err != nil { @@ -216,17 +188,9 @@ func (msg MsgChannelOpenAck) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgChannelOpenConfirm{} -type MsgChannelOpenConfirm struct { - PortID string `json:"port_id"` - ChannelID string `json:"channel_id"` - ProofAck commitmentexported.Proof `json:"proof_ack"` - ProofHeight uint64 `json:"proof_height"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgChannelOpenConfirm creates a new MsgChannelOpenConfirm instance func NewMsgChannelOpenConfirm( - portID, channelID string, proofAck commitmentexported.Proof, proofHeight uint64, + portID, channelID string, proofAck commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, ) MsgChannelOpenConfirm { return MsgChannelOpenConfirm{ @@ -256,7 +220,7 @@ func (msg MsgChannelOpenConfirm) ValidateBasic() error { if err := host.DefaultChannelIdentifierValidator(msg.ChannelID); err != nil { return sdkerrors.Wrap(err, "invalid channel ID") } - if msg.ProofAck == nil { + if msg.ProofAck.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.ProofAck.ValidateBasic(); err != nil { @@ -281,14 +245,10 @@ func (msg MsgChannelOpenConfirm) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgChannelCloseInit{} -type MsgChannelCloseInit struct { - PortID string `json:"port_id"` - ChannelID string `json:"channel_id"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgChannelCloseInit creates a new MsgChannelCloseInit instance -func NewMsgChannelCloseInit(portID string, channelID string, signer sdk.AccAddress) MsgChannelCloseInit { +func NewMsgChannelCloseInit( + portID string, channelID string, signer sdk.AccAddress, +) MsgChannelCloseInit { return MsgChannelCloseInit{ PortID: portID, ChannelID: channelID, @@ -330,17 +290,9 @@ func (msg MsgChannelCloseInit) GetSigners() []sdk.AccAddress { var _ sdk.Msg = MsgChannelCloseConfirm{} -type MsgChannelCloseConfirm struct { - PortID string `json:"port_id"` - ChannelID string `json:"channel_id"` - ProofInit commitmentexported.Proof `json:"proof_init"` - ProofHeight uint64 `json:"proof_height"` - Signer sdk.AccAddress `json:"signer"` -} - // NewMsgChannelCloseConfirm creates a new MsgChannelCloseConfirm instance func NewMsgChannelCloseConfirm( - portID, channelID string, proofInit commitmentexported.Proof, proofHeight uint64, + portID, channelID string, proofInit commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, ) MsgChannelCloseConfirm { return MsgChannelCloseConfirm{ @@ -370,7 +322,7 @@ func (msg MsgChannelCloseConfirm) ValidateBasic() error { if err := host.DefaultChannelIdentifierValidator(msg.ChannelID); err != nil { return sdkerrors.Wrap(err, "invalid channel ID") } - if msg.ProofInit == nil { + if msg.ProofInit.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.ProofInit.ValidateBasic(); err != nil { @@ -393,18 +345,13 @@ func (msg MsgChannelCloseConfirm) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -// MsgPacket receives incoming IBC packet -type MsgPacket struct { - Packet `json:"packet" yaml:"packet"` - Proof commitmentexported.Proof `json:"proof" yaml:"proof"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` - Signer sdk.AccAddress `json:"signer" yaml:"signer"` -} - var _ sdk.Msg = MsgPacket{} // NewMsgPacket constructs new MsgPacket -func NewMsgPacket(packet Packet, proof commitmentexported.Proof, proofHeight uint64, signer sdk.AccAddress) MsgPacket { +func NewMsgPacket( + packet Packet, proof commitmenttypes.MerkleProof, proofHeight uint64, + signer sdk.AccAddress, +) MsgPacket { return MsgPacket{ Packet: packet, Proof: proof, @@ -420,7 +367,7 @@ func (msg MsgPacket) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgPacket) ValidateBasic() error { - if msg.Proof == nil { + if msg.Proof.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.Proof.ValidateBasic(); err != nil { @@ -444,7 +391,7 @@ func (msg MsgPacket) GetSignBytes() []byte { // GetDataSignBytes returns the base64-encoded bytes used for the // data field when signing the packet. func (msg MsgPacket) GetDataSignBytes() []byte { - s := "\"" + base64.StdEncoding.EncodeToString(msg.Data) + "\"" + s := "\"" + base64.StdEncoding.EncodeToString(msg.Packet.Data) + "\"" return []byte(s) } @@ -460,17 +407,11 @@ func (msg MsgPacket) Type() string { var _ sdk.Msg = MsgTimeout{} -// MsgTimeout receives timed-out packet -type MsgTimeout struct { - Packet `json:"packet" yaml:"packet"` - NextSequenceRecv uint64 `json:"next_sequence_recv" yaml:"next_sequence_recv"` - Proof commitmentexported.Proof `json:"proof" yaml:"proof"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` - Signer sdk.AccAddress `json:"signer" yaml:"signer"` -} - // NewMsgTimeout constructs new MsgTimeout -func NewMsgTimeout(packet Packet, nextSequenceRecv uint64, proof commitmentexported.Proof, proofHeight uint64, signer sdk.AccAddress) MsgTimeout { +func NewMsgTimeout( + packet Packet, nextSequenceRecv uint64, proof commitmenttypes.MerkleProof, + proofHeight uint64, signer sdk.AccAddress, +) MsgTimeout { return MsgTimeout{ Packet: packet, NextSequenceRecv: nextSequenceRecv, @@ -487,7 +428,7 @@ func (msg MsgTimeout) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgTimeout) ValidateBasic() error { - if msg.Proof == nil { + if msg.Proof.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.Proof.ValidateBasic(); err != nil { @@ -520,17 +461,9 @@ func (msg MsgTimeout) Type() string { var _ sdk.Msg = MsgAcknowledgement{} -// MsgAcknowledgement receives incoming IBC acknowledgement -type MsgAcknowledgement struct { - Packet `json:"packet" yaml:"packet"` - Acknowledgement []byte `json:"acknowledgement" yaml:"acknowledgement"` - Proof commitmentexported.Proof `json:"proof" yaml:"proof"` - ProofHeight uint64 `json:"proof_height" yaml:"proof_height"` - Signer sdk.AccAddress `json:"signer" yaml:"signer"` -} - // NewMsgAcknowledgement constructs a new MsgAcknowledgement -func NewMsgAcknowledgement(packet Packet, ack []byte, proof commitmentexported.Proof, proofHeight uint64, signer sdk.AccAddress) MsgAcknowledgement { +func NewMsgAcknowledgement( + packet Packet, ack []byte, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) MsgAcknowledgement { return MsgAcknowledgement{ Packet: packet, Acknowledgement: ack, @@ -547,7 +480,7 @@ func (msg MsgAcknowledgement) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgAcknowledgement) ValidateBasic() error { - if msg.Proof == nil { + if msg.Proof.IsEmpty() { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if err := msg.Proof.ValidateBasic(); err != nil { diff --git a/x/ibc/04-channel/types/msgs_test.go b/x/ibc/04-channel/types/msgs_test.go index 87687c27d468..fd6dcce9c2af 100644 --- a/x/ibc/04-channel/types/msgs_test.go +++ b/x/ibc/04-channel/types/msgs_test.go @@ -15,9 +15,9 @@ import ( "github.com/cosmos/cosmos-sdk/store/rootmulti" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) // define constants used for testing @@ -42,7 +42,7 @@ var ( invalidShortConnHops = []string{invalidShortConnection} invalidLongConnHops = []string{invalidLongConnection} - proof = commitmenttypes.MerkleProof{Proof: &merkle.Proof{}} + proof = commitmenttypes.MerkleProof{Proof: &merkle.Proof{Ops: []merkle.ProofOp{{Type: "proof", Key: []byte("key"), Data: []byte("data")}}}} addr = sdk.AccAddress("testaddr") ) @@ -81,21 +81,21 @@ func TestMsgTestSuite(t *testing.T) { // TestMsgChannelOpenInit tests ValidateBasic for MsgChannelOpenInit func (suite *MsgTestSuite) TestMsgChannelOpenInit() { testMsgs := []MsgChannelOpenInit{ - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", addr), // valid msg - NewMsgChannelOpenInit(invalidShortPort, "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short port id - NewMsgChannelOpenInit(invalidLongPort, "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long port id - NewMsgChannelOpenInit(invalidPort, "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", addr), // port id contains non-alpha - NewMsgChannelOpenInit("testportid", invalidShortChannel, "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short channel id - NewMsgChannelOpenInit("testportid", invalidLongChannel, "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long channel id - NewMsgChannelOpenInit("testportid", invalidChannel, "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", addr), // channel id contains non-alpha - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.Order(3), connHops, "testcpport", "testcpchannel", addr), // invalid channel order - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.ORDERED, invalidConnHops, "testcpport", "testcpchannel", addr), // connection hops more than 1 - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", addr), // too short connection id - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", addr), // too long connection id - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", addr), // connection id contains non-alpha - NewMsgChannelOpenInit("testportid", "testchannel", "", exported.UNORDERED, connHops, "testcpport", "testcpchannel", addr), // empty channel version - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.UNORDERED, connHops, invalidPort, "testcpchannel", addr), // invalid counterparty port id - NewMsgChannelOpenInit("testportid", "testchannel", "1.0", exported.UNORDERED, connHops, "testcpport", invalidChannel, addr), // invalid counterparty channel id + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", addr), // valid msg + NewMsgChannelOpenInit(invalidShortPort, "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short port id + NewMsgChannelOpenInit(invalidLongPort, "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long port id + NewMsgChannelOpenInit(invalidPort, "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", addr), // port id contains non-alpha + NewMsgChannelOpenInit("testportid", invalidShortChannel, "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short channel id + NewMsgChannelOpenInit("testportid", invalidLongChannel, "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long channel id + NewMsgChannelOpenInit("testportid", invalidChannel, "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", addr), // channel id contains non-alpha + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.Order(3), connHops, "testcpport", "testcpchannel", addr), // invalid channel order + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.ORDERED, invalidConnHops, "testcpport", "testcpchannel", addr), // connection hops more than 1 + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", addr), // too short connection id + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", addr), // too long connection id + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", addr), // connection id contains non-alpha + NewMsgChannelOpenInit("testportid", "testchannel", "", ibctypes.UNORDERED, connHops, "testcpport", "testcpchannel", addr), // empty channel version + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.UNORDERED, connHops, invalidPort, "testcpchannel", addr), // invalid counterparty port id + NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ibctypes.UNORDERED, connHops, "testcpport", invalidChannel, addr), // invalid counterparty channel id } testCases := []struct { @@ -133,24 +133,23 @@ func (suite *MsgTestSuite) TestMsgChannelOpenInit() { // TestMsgChannelOpenTry tests ValidateBasic for MsgChannelOpenTry func (suite *MsgTestSuite) TestMsgChannelOpenTry() { testMsgs := []MsgChannelOpenTry{ - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // valid msg - NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short port id - NewMsgChannelOpenTry(invalidLongPort, "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long port id - NewMsgChannelOpenTry(invalidPort, "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha - NewMsgChannelOpenTry("testportid", invalidShortChannel, "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short channel id - NewMsgChannelOpenTry("testportid", invalidLongChannel, "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long channel id - NewMsgChannelOpenTry("testportid", invalidChannel, "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // channel id contains non-alpha - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "", suite.proof, 1, addr), // empty counterparty version - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", nil, 1, addr), // empty suite.proof - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, addr), // suite.proof height is zero - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.Order(4), connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // invalid channel order - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.UNORDERED, invalidConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection hops more than 1 - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short connection id - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long connection id - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection id contains non-alpha - NewMsgChannelOpenTry("testportid", "testchannel", "", exported.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // empty channel version - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.UNORDERED, connHops, invalidPort, "testcpchannel", "1.0", suite.proof, 1, addr), // invalid counterparty port id - NewMsgChannelOpenTry("testportid", "testchannel", "1.0", exported.UNORDERED, connHops, "testcpport", invalidChannel, "1.0", suite.proof, 1, addr), // invalid counterparty channel id + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // valid msg + NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short port id + NewMsgChannelOpenTry(invalidLongPort, "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long port id + NewMsgChannelOpenTry(invalidPort, "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // port id contains non-alpha + NewMsgChannelOpenTry("testportid", invalidShortChannel, "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short channel id + NewMsgChannelOpenTry("testportid", invalidLongChannel, "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long channel id + NewMsgChannelOpenTry("testportid", invalidChannel, "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // channel id contains non-alpha + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "", suite.proof, 1, addr), // empty counterparty version + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 0, addr), // suite.proof height is zero + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.Order(4), connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // invalid channel order + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.UNORDERED, invalidConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection hops more than 1 + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.UNORDERED, invalidShortConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short connection id + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.UNORDERED, invalidLongConnHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long connection id + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.UNORDERED, []string{invalidConnection}, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // connection id contains non-alpha + NewMsgChannelOpenTry("testportid", "testchannel", "", ibctypes.UNORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // empty channel version + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.UNORDERED, connHops, invalidPort, "testcpchannel", "1.0", suite.proof, 1, addr), // invalid counterparty port id + NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ibctypes.UNORDERED, connHops, "testcpport", invalidChannel, "1.0", suite.proof, 1, addr), // invalid counterparty channel id } testCases := []struct { @@ -166,16 +165,15 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { {testMsgs[5], false, "too long channel id"}, {testMsgs[6], false, "channel id contains non-alpha"}, {testMsgs[7], false, "empty counterparty version"}, - {testMsgs[8], false, "empty proof"}, - {testMsgs[9], false, "proof height is zero"}, - {testMsgs[10], false, "invalid channel order"}, - {testMsgs[11], false, "connection hops more than 1 "}, - {testMsgs[12], false, "too short connection id"}, - {testMsgs[13], false, "too long connection id"}, - {testMsgs[14], false, "connection id contains non-alpha"}, - {testMsgs[15], false, "empty channel version"}, - {testMsgs[16], false, "invalid counterparty port id"}, - {testMsgs[17], false, "invalid counterparty channel id"}, + {testMsgs[8], false, "proof height is zero"}, + {testMsgs[9], false, "invalid channel order"}, + {testMsgs[10], false, "connection hops more than 1 "}, + {testMsgs[11], false, "too short connection id"}, + {testMsgs[12], false, "too long connection id"}, + {testMsgs[13], false, "connection id contains non-alpha"}, + {testMsgs[14], false, "empty channel version"}, + {testMsgs[15], false, "invalid counterparty port id"}, + {testMsgs[16], false, "invalid counterparty channel id"}, } for i, tc := range testCases { @@ -199,7 +197,6 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() { NewMsgChannelOpenAck("testportid", invalidLongChannel, "1.0", suite.proof, 1, addr), // too long channel id NewMsgChannelOpenAck("testportid", invalidChannel, "1.0", suite.proof, 1, addr), // channel id contains non-alpha NewMsgChannelOpenAck("testportid", "testchannel", "", suite.proof, 1, addr), // empty counterparty version - NewMsgChannelOpenAck("testportid", "testchannel", "1.0", nil, 1, addr), // empty proof NewMsgChannelOpenAck("testportid", "testchannel", "1.0", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 0, addr), // proof height is zero } @@ -218,8 +215,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() { {testMsgs[6], false, "channel id contains non-alpha"}, {testMsgs[7], false, "empty counterparty version"}, {testMsgs[8], false, "empty proof"}, - {testMsgs[9], false, "empty proof"}, - {testMsgs[10], false, "proof height is zero"}, + {testMsgs[9], false, "proof height is zero"}, } for i, tc := range testCases { @@ -242,7 +238,6 @@ func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { NewMsgChannelOpenConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id NewMsgChannelOpenConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id NewMsgChannelOpenConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha - NewMsgChannelOpenConfirm("testportid", "testchannel", nil, 1, addr), // empty proof NewMsgChannelOpenConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero } @@ -260,8 +255,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { {testMsgs[5], false, "too long channel id"}, {testMsgs[6], false, "channel id contains non-alpha"}, {testMsgs[7], false, "empty proof"}, - {testMsgs[8], false, "empty proof"}, - {testMsgs[9], false, "proof height is zero"}, + {testMsgs[8], false, "proof height is zero"}, } for i, tc := range testCases { @@ -320,7 +314,6 @@ func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { NewMsgChannelCloseConfirm("testportid", invalidShortChannel, suite.proof, 1, addr), // too short channel id NewMsgChannelCloseConfirm("testportid", invalidLongChannel, suite.proof, 1, addr), // too long channel id NewMsgChannelCloseConfirm("testportid", invalidChannel, suite.proof, 1, addr), // channel id contains non-alpha - NewMsgChannelCloseConfirm("testportid", "testchannel", nil, 1, addr), // empty proof NewMsgChannelCloseConfirm("testportid", "testchannel", commitmenttypes.MerkleProof{Proof: nil}, 1, addr), // empty proof NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 0, addr), // proof height is zero } @@ -338,8 +331,7 @@ func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { {testMsgs[5], false, "too long channel id"}, {testMsgs[6], false, "channel id contains non-alpha"}, {testMsgs[7], false, "empty proof"}, - {testMsgs[8], false, "empty proof"}, - {testMsgs[9], false, "proof height is zero"}, + {testMsgs[8], false, "proof height is zero"}, } for i, tc := range testCases { @@ -382,7 +374,7 @@ var ( func TestMsgPacketType(t *testing.T) { msg := NewMsgPacket(packet, proof, 1, addr1) - require.Equal(t, []byte("testdata"), msg.GetData()) + require.Equal(t, []byte("testdata"), msg.Packet.GetData()) } // TestMsgPacketValidation tests ValidateBasic for MsgPacket @@ -390,8 +382,6 @@ func TestMsgPacketValidation(t *testing.T) { testMsgs := []MsgPacket{ NewMsgPacket(packet, proof, 1, addr1), // valid msg NewMsgPacket(packet, proof, 0, addr1), // proof height is zero - NewMsgPacket(packet, nil, 1, addr1), // missing proof - NewMsgPacket(packet, invalidProofs1, 1, addr1), // missing proof NewMsgPacket(packet, invalidProofs2, 1, addr1), // proof contain empty proof NewMsgPacket(packet, proof, 1, emptyAddr), // missing signer address NewMsgPacket(unknownPacket, proof, 1, addr1), // unknown packet @@ -404,11 +394,9 @@ func TestMsgPacketValidation(t *testing.T) { }{ {testMsgs[0], true, ""}, {testMsgs[1], false, "proof height is zero"}, - {testMsgs[2], false, "missing proof"}, - {testMsgs[3], false, "missing proof"}, - {testMsgs[4], false, "proof contain empty proof"}, - {testMsgs[5], false, "missing signer address"}, - {testMsgs[6], false, "invalid packet"}, + {testMsgs[2], false, "proof contain empty proof"}, + {testMsgs[3], false, "missing signer address"}, + {testMsgs[4], false, "invalid packet"}, } for i, tc := range testCases { @@ -427,7 +415,7 @@ func TestMsgPacketGetSignBytes(t *testing.T) { 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":{"type":"ibc/commitment/MerkleProof","value":{"proof":{"ops":[]}}},"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":{"proof":{"ops":[{"data":"ZGF0YQ==","key":"a2V5","type":"proof"}]}},"proof_height":"1","signer":"cosmos1w3jhxarpv3j8yvg4ufs4x"}}`, string(msg.GetDataSignBytes()), ) require.Equal(t, expected, string(res)) @@ -445,12 +433,11 @@ func TestMsgPacketGetSigners(t *testing.T) { // TestMsgTimeout tests ValidateBasic for MsgTimeout func (suite *MsgTestSuite) TestMsgTimeout() { testMsgs := []MsgTimeout{ - NewMsgTimeout(packet, 0, proof, 1, addr), - NewMsgTimeout(packet, 0, proof, 0, addr), - NewMsgTimeout(packet, 0, proof, 1, emptyAddr), - NewMsgTimeout(packet, 0, emptyProof, 1, addr), - NewMsgTimeout(unknownPacket, 0, proof, 1, addr), - NewMsgTimeout(packet, 0, invalidProofs1, 1, addr), + NewMsgTimeout(packet, 1, proof, 1, addr), + NewMsgTimeout(packet, 1, proof, 0, addr), + NewMsgTimeout(packet, 1, proof, 1, emptyAddr), + NewMsgTimeout(packet, 1, emptyProof, 1, addr), + NewMsgTimeout(unknownPacket, 1, proof, 1, addr), } testCases := []struct { @@ -463,7 +450,6 @@ func (suite *MsgTestSuite) TestMsgTimeout() { {testMsgs[2], false, "missing signer address"}, {testMsgs[3], false, "cannot submit an empty proof"}, {testMsgs[4], false, "invalid packet"}, - {testMsgs[5], false, "cannot submit an invalid proof"}, } for i, tc := range testCases { @@ -485,7 +471,6 @@ func (suite *MsgTestSuite) TestMsgAcknowledgement() { NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, 1, addr), NewMsgAcknowledgement(unknownPacket, packet.GetData(), proof, 1, addr), NewMsgAcknowledgement(packet, invalidAck, proof, 1, addr), - NewMsgAcknowledgement(packet, packet.GetData(), invalidProofs1, 1, addr), } testCases := []struct { @@ -499,7 +484,6 @@ func (suite *MsgTestSuite) TestMsgAcknowledgement() { {testMsgs[3], false, "cannot submit an empty proof"}, {testMsgs[4], false, "invalid packet"}, {testMsgs[5], false, "invalid acknowledgement"}, - {testMsgs[6], false, "cannot submit an invalid proof"}, } for i, tc := range testCases { diff --git a/x/ibc/04-channel/types/packet.go b/x/ibc/04-channel/types/packet.go index 16c397ef38b0..626ffae89fd3 100644 --- a/x/ibc/04-channel/types/packet.go +++ b/x/ibc/04-channel/types/packet.go @@ -23,22 +23,10 @@ func CommitAcknowledgement(data []byte) []byte { return tmhash.Sum(data) } -var _ exported.PacketI = Packet{} +var _ exported.PacketI = (*Packet)(nil) -// Packet defines a type that carries data across different chains through IBC -type Packet struct { - Data []byte `json:"data" yaml:"data"` // Actual opaque bytes transferred directly to the application module - - Sequence uint64 `json:"sequence" yaml:"sequence"` // number corresponds to the order of sends and receives, where a Packet with an earlier sequence number must be sent and received before a Packet with a later sequence number. - SourcePort string `json:"source_port" yaml:"source_port"` // identifies the port on the sending chain. - SourceChannel string `json:"source_channel" yaml:"source_channel"` // identifies the channel end on the sending chain. - DestinationPort string `json:"destination_port" yaml:"destination_port"` // identifies the port on the receiving chain. - DestinationChannel string `json:"destination_channel" yaml:"destination_channel"` // identifies the channel end on the receiving chain. - TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` // block height after which the packet times out - TimeoutTimestamp uint64 `json:"timeout_timestamp" yaml:"timeout_timestamp"` // block timestamp (in nanoseconds) after which the packet times out -} - -// NewPacket creates a new Packet instance +// NewPacket creates a new Packet instance. It panics if the provided +// packet data interface is not registered. func NewPacket( data []byte, sequence uint64, sourcePort, sourceChannel, diff --git a/x/ibc/04-channel/types/types.pb.go b/x/ibc/04-channel/types/types.pb.go new file mode 100644 index 000000000000..9e002402072d --- /dev/null +++ b/x/ibc/04-channel/types/types.pb.go @@ -0,0 +1,4459 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/ibc/04-channel/types/types.proto + +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" + types1 "github.com/cosmos/cosmos-sdk/x/ibc/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It is +// called by a relayer on Chain A. +type MsgChannelOpenInit 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"` + Channel Channel `protobuf:"bytes,3,opt,name=channel,proto3" json:"channel"` + 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"` +} + +func (m *MsgChannelOpenInit) Reset() { *m = MsgChannelOpenInit{} } +func (m *MsgChannelOpenInit) String() string { return proto.CompactTextString(m) } +func (*MsgChannelOpenInit) ProtoMessage() {} +func (*MsgChannelOpenInit) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{0} +} +func (m *MsgChannelOpenInit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChannelOpenInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChannelOpenInit.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgChannelOpenInit) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChannelOpenInit.Merge(m, src) +} +func (m *MsgChannelOpenInit) XXX_Size() int { + return m.Size() +} +func (m *MsgChannelOpenInit) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChannelOpenInit.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChannelOpenInit proto.InternalMessageInfo + +func (m *MsgChannelOpenInit) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *MsgChannelOpenInit) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *MsgChannelOpenInit) GetChannel() Channel { + if m != nil { + return m.Channel + } + return Channel{} +} + +func (m *MsgChannelOpenInit) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel +// on Chain B. +type MsgChannelOpenTry 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"` + 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"` + 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"` +} + +func (m *MsgChannelOpenTry) Reset() { *m = MsgChannelOpenTry{} } +func (m *MsgChannelOpenTry) String() string { return proto.CompactTextString(m) } +func (*MsgChannelOpenTry) ProtoMessage() {} +func (*MsgChannelOpenTry) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{1} +} +func (m *MsgChannelOpenTry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChannelOpenTry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChannelOpenTry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgChannelOpenTry) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChannelOpenTry.Merge(m, src) +} +func (m *MsgChannelOpenTry) XXX_Size() int { + return m.Size() +} +func (m *MsgChannelOpenTry) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChannelOpenTry.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChannelOpenTry proto.InternalMessageInfo + +func (m *MsgChannelOpenTry) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *MsgChannelOpenTry) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *MsgChannelOpenTry) GetChannel() Channel { + if m != nil { + return m.Channel + } + return Channel{} +} + +func (m *MsgChannelOpenTry) GetCounterpartyVersion() string { + if m != nil { + return m.CounterpartyVersion + } + return "" +} + +func (m *MsgChannelOpenTry) GetProofInit() types.MerkleProof { + if m != nil { + return m.ProofInit + } + return types.MerkleProof{} +} + +func (m *MsgChannelOpenTry) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgChannelOpenTry) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge +// the change of channel state to TRYOPEN on Chain B. +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"` + 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"` +} + +func (m *MsgChannelOpenAck) Reset() { *m = MsgChannelOpenAck{} } +func (m *MsgChannelOpenAck) String() string { return proto.CompactTextString(m) } +func (*MsgChannelOpenAck) ProtoMessage() {} +func (*MsgChannelOpenAck) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{2} +} +func (m *MsgChannelOpenAck) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChannelOpenAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChannelOpenAck.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgChannelOpenAck) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChannelOpenAck.Merge(m, src) +} +func (m *MsgChannelOpenAck) XXX_Size() int { + return m.Size() +} +func (m *MsgChannelOpenAck) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChannelOpenAck.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChannelOpenAck proto.InternalMessageInfo + +func (m *MsgChannelOpenAck) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *MsgChannelOpenAck) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *MsgChannelOpenAck) GetCounterpartyVersion() string { + if m != nil { + return m.CounterpartyVersion + } + return "" +} + +func (m *MsgChannelOpenAck) GetProofTry() types.MerkleProof { + if m != nil { + return m.ProofTry + } + return types.MerkleProof{} +} + +func (m *MsgChannelOpenAck) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgChannelOpenAck) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to acknowledge +// the change of channel state to OPEN on Chain A. +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"` + 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"` +} + +func (m *MsgChannelOpenConfirm) Reset() { *m = MsgChannelOpenConfirm{} } +func (m *MsgChannelOpenConfirm) String() string { return proto.CompactTextString(m) } +func (*MsgChannelOpenConfirm) ProtoMessage() {} +func (*MsgChannelOpenConfirm) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{3} +} +func (m *MsgChannelOpenConfirm) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChannelOpenConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChannelOpenConfirm.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgChannelOpenConfirm) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChannelOpenConfirm.Merge(m, src) +} +func (m *MsgChannelOpenConfirm) XXX_Size() int { + return m.Size() +} +func (m *MsgChannelOpenConfirm) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChannelOpenConfirm.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChannelOpenConfirm proto.InternalMessageInfo + +func (m *MsgChannelOpenConfirm) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *MsgChannelOpenConfirm) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *MsgChannelOpenConfirm) GetProofAck() types.MerkleProof { + if m != nil { + return m.ProofAck + } + return types.MerkleProof{} +} + +func (m *MsgChannelOpenConfirm) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgChannelOpenConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain A +// to close a channel with Chain B. +type MsgChannelCloseInit 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"` + Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,3,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` +} + +func (m *MsgChannelCloseInit) Reset() { *m = MsgChannelCloseInit{} } +func (m *MsgChannelCloseInit) String() string { return proto.CompactTextString(m) } +func (*MsgChannelCloseInit) ProtoMessage() {} +func (*MsgChannelCloseInit) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{4} +} +func (m *MsgChannelCloseInit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChannelCloseInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChannelCloseInit.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgChannelCloseInit) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChannelCloseInit.Merge(m, src) +} +func (m *MsgChannelCloseInit) XXX_Size() int { + return m.Size() +} +func (m *MsgChannelCloseInit) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChannelCloseInit.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChannelCloseInit proto.InternalMessageInfo + +func (m *MsgChannelCloseInit) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *MsgChannelCloseInit) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *MsgChannelCloseInit) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B +// to acknowledge the change of channel state to CLOSED on Chain A. +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"` + 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"` +} + +func (m *MsgChannelCloseConfirm) Reset() { *m = MsgChannelCloseConfirm{} } +func (m *MsgChannelCloseConfirm) String() string { return proto.CompactTextString(m) } +func (*MsgChannelCloseConfirm) ProtoMessage() {} +func (*MsgChannelCloseConfirm) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{5} +} +func (m *MsgChannelCloseConfirm) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChannelCloseConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChannelCloseConfirm.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgChannelCloseConfirm) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChannelCloseConfirm.Merge(m, src) +} +func (m *MsgChannelCloseConfirm) XXX_Size() int { + return m.Size() +} +func (m *MsgChannelCloseConfirm) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChannelCloseConfirm.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChannelCloseConfirm proto.InternalMessageInfo + +func (m *MsgChannelCloseConfirm) GetPortID() string { + if m != nil { + return m.PortID + } + return "" +} + +func (m *MsgChannelCloseConfirm) GetChannelID() string { + if m != nil { + return m.ChannelID + } + return "" +} + +func (m *MsgChannelCloseConfirm) GetProofInit() types.MerkleProof { + if m != nil { + return m.ProofInit + } + return types.MerkleProof{} +} + +func (m *MsgChannelCloseConfirm) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgChannelCloseConfirm) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// 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"` + 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"` +} + +func (m *MsgPacket) Reset() { *m = MsgPacket{} } +func (m *MsgPacket) String() string { return proto.CompactTextString(m) } +func (*MsgPacket) ProtoMessage() {} +func (*MsgPacket) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{6} +} +func (m *MsgPacket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPacket.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPacket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPacket.Merge(m, src) +} +func (m *MsgPacket) XXX_Size() int { + return m.Size() +} +func (m *MsgPacket) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPacket.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPacket proto.InternalMessageInfo + +func (m *MsgPacket) GetPacket() Packet { + if m != nil { + return m.Packet + } + return Packet{} +} + +func (m *MsgPacket) GetProof() types.MerkleProof { + if m != nil { + return m.Proof + } + return types.MerkleProof{} +} + +func (m *MsgPacket) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgPacket) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// 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"` + 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"` +} + +func (m *MsgTimeout) Reset() { *m = MsgTimeout{} } +func (m *MsgTimeout) String() string { return proto.CompactTextString(m) } +func (*MsgTimeout) ProtoMessage() {} +func (*MsgTimeout) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{7} +} +func (m *MsgTimeout) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTimeout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTimeout.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgTimeout) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTimeout.Merge(m, src) +} +func (m *MsgTimeout) XXX_Size() int { + return m.Size() +} +func (m *MsgTimeout) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTimeout.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTimeout proto.InternalMessageInfo + +func (m *MsgTimeout) GetPacket() Packet { + if m != nil { + return m.Packet + } + return Packet{} +} + +func (m *MsgTimeout) GetProof() types.MerkleProof { + if m != nil { + return m.Proof + } + return types.MerkleProof{} +} + +func (m *MsgTimeout) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgTimeout) GetNextSequenceRecv() uint64 { + if m != nil { + return m.NextSequenceRecv + } + return 0 +} + +func (m *MsgTimeout) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// MsgAcknowledgement receives incoming IBC acknowledgement +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"` + 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"` +} + +func (m *MsgAcknowledgement) Reset() { *m = MsgAcknowledgement{} } +func (m *MsgAcknowledgement) String() string { return proto.CompactTextString(m) } +func (*MsgAcknowledgement) ProtoMessage() {} +func (*MsgAcknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{8} +} +func (m *MsgAcknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAcknowledgement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgAcknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAcknowledgement.Merge(m, src) +} +func (m *MsgAcknowledgement) XXX_Size() int { + return m.Size() +} +func (m *MsgAcknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAcknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAcknowledgement proto.InternalMessageInfo + +func (m *MsgAcknowledgement) GetPacket() Packet { + if m != nil { + return m.Packet + } + return Packet{} +} + +func (m *MsgAcknowledgement) GetAcknowledgement() []byte { + if m != nil { + return m.Acknowledgement + } + return nil +} + +func (m *MsgAcknowledgement) GetProof() types.MerkleProof { + if m != nil { + return m.Proof + } + return types.MerkleProof{} +} + +func (m *MsgAcknowledgement) GetProofHeight() uint64 { + if m != nil { + return m.ProofHeight + } + return 0 +} + +func (m *MsgAcknowledgement) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +// Channel defines pipeline for exactly-once packet delivery between specific +// modules on separate blockchains, which has at least one end capable of sending +// packets and one end capable of receiving packets. +type Channel struct { + // current state of the channel end + State types1.State `protobuf:"varint,1,opt,name=state,proto3,enum=cosmos_sdk.x.ibc.v1.State" json:"state,omitempty"` + // whether the channel is ordered or unordered + Ordering types1.Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=cosmos_sdk.x.ibc.v1.Order" json:"ordering,omitempty"` + // counterparty channel end + Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"` + // list of connection identifiers, in order, along which packets sent on this + // channel will travel + ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty" yaml:"connection_hops"` + // opaque channel version, which is agreed upon during the handshake + Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *Channel) Reset() { *m = Channel{} } +func (m *Channel) String() string { return proto.CompactTextString(m) } +func (*Channel) ProtoMessage() {} +func (*Channel) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{9} +} +func (m *Channel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Channel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Channel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Channel) XXX_Merge(src proto.Message) { + xxx_messageInfo_Channel.Merge(m, src) +} +func (m *Channel) XXX_Size() int { + return m.Size() +} +func (m *Channel) XXX_DiscardUnknown() { + xxx_messageInfo_Channel.DiscardUnknown(m) +} + +var xxx_messageInfo_Channel proto.InternalMessageInfo + +// Counterparty defines a channel end counterparty +type Counterparty struct { + // port on the counterparty chain which owns the other end of the channel. + PortID string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + // channel end on the counterparty chain + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` +} + +func (m *Counterparty) Reset() { *m = Counterparty{} } +func (m *Counterparty) String() string { return proto.CompactTextString(m) } +func (*Counterparty) ProtoMessage() {} +func (*Counterparty) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{10} +} +func (m *Counterparty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Counterparty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Counterparty.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Counterparty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Counterparty.Merge(m, src) +} +func (m *Counterparty) XXX_Size() int { + return m.Size() +} +func (m *Counterparty) XXX_DiscardUnknown() { + xxx_messageInfo_Counterparty.DiscardUnknown(m) +} + +var xxx_messageInfo_Counterparty proto.InternalMessageInfo + +// Packet defines a type that carries data across different chains through IBC +type Packet struct { + // number corresponds to the order of sends and receives, where a Packet with + // an earlier sequence number must be sent and received before a Packet with a + // later sequence number. + Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"` + // identifies the port on the sending chain. + SourcePort string `protobuf:"bytes,2,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty" yaml:"source_port"` + // identifies the channel end on the sending chain. + SourceChannel string `protobuf:"bytes,3,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty" yaml:"source_channel"` + // identifies the port on the receiving chain. + DestinationPort string `protobuf:"bytes,4,opt,name=destination_port,json=destinationPort,proto3" json:"destination_port,omitempty" yaml:"destination_port"` + // identifies the channel end on the receiving chain. + DestinationChannel string `protobuf:"bytes,5,opt,name=destination_channel,json=destinationChannel,proto3" json:"destination_channel,omitempty" yaml:"destination_channel"` + // actual opaque bytes transferred directly to the application module + Data []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` + // block height after which the packet times out + TimeoutHeight uint64 `protobuf:"varint,7,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty" yaml:"timeout_height"` + // block timestamp (in nanoseconds) after which the packet times out + TimeoutTimestamp uint64 `protobuf:"varint,8,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty" yaml:"timeout_timestamp"` +} + +func (m *Packet) Reset() { *m = Packet{} } +func (m *Packet) String() string { return proto.CompactTextString(m) } +func (*Packet) ProtoMessage() {} +func (*Packet) Descriptor() ([]byte, []int) { + return fileDescriptor_a69005b45bd92d03, []int{11} +} +func (m *Packet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Packet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Packet.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Packet) XXX_Merge(src proto.Message) { + xxx_messageInfo_Packet.Merge(m, src) +} +func (m *Packet) XXX_Size() int { + return m.Size() +} +func (m *Packet) XXX_DiscardUnknown() { + xxx_messageInfo_Packet.DiscardUnknown(m) +} + +var xxx_messageInfo_Packet proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgChannelOpenInit)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenInit") + proto.RegisterType((*MsgChannelOpenTry)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenTry") + proto.RegisterType((*MsgChannelOpenAck)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenAck") + proto.RegisterType((*MsgChannelOpenConfirm)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenConfirm") + proto.RegisterType((*MsgChannelCloseInit)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgChannelCloseInit") + proto.RegisterType((*MsgChannelCloseConfirm)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgChannelCloseConfirm") + proto.RegisterType((*MsgPacket)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgPacket") + proto.RegisterType((*MsgTimeout)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgTimeout") + proto.RegisterType((*MsgAcknowledgement)(nil), "cosmos_sdk.x.ibc.channel.v1.MsgAcknowledgement") + proto.RegisterType((*Channel)(nil), "cosmos_sdk.x.ibc.channel.v1.Channel") + proto.RegisterType((*Counterparty)(nil), "cosmos_sdk.x.ibc.channel.v1.Counterparty") + proto.RegisterType((*Packet)(nil), "cosmos_sdk.x.ibc.channel.v1.Packet") +} + +func init() { + proto.RegisterFile("x/ibc/04-channel/types/types.proto", fileDescriptor_a69005b45bd92d03) +} + +var fileDescriptor_a69005b45bd92d03 = []byte{ + // 1097 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xcd, 0x6f, 0x23, 0x35, + 0x14, 0x6f, 0x3e, 0x9a, 0x34, 0x6e, 0xb7, 0x1f, 0x2e, 0xdb, 0xa6, 0xe9, 0x92, 0xa9, 0x86, 0x0f, + 0x05, 0xa1, 0x26, 0xdb, 0x96, 0x0f, 0xa9, 0x27, 0x32, 0x5d, 0xc1, 0x56, 0xa8, 0x6a, 0xe5, 0x56, + 0x1c, 0xb8, 0x8c, 0xa6, 0x1e, 0xef, 0x64, 0x94, 0x66, 0x3c, 0x8c, 0xdd, 0xd2, 0xdc, 0x38, 0x72, + 0x42, 0x5c, 0xb8, 0x02, 0xff, 0x00, 0xff, 0xc7, 0x1e, 0x38, 0x2c, 0x37, 0xc4, 0x61, 0x40, 0xed, + 0x95, 0xd3, 0x1c, 0x11, 0x07, 0x34, 0xb6, 0x27, 0x99, 0x24, 0xdd, 0x4a, 0xdb, 0x54, 0x44, 0x70, + 0x49, 0xec, 0xe7, 0xdf, 0x7b, 0x7e, 0xef, 0xf7, 0xde, 0xb3, 0x9d, 0x00, 0xfd, 0xb2, 0xe1, 0x9e, + 0xe2, 0xc6, 0xe3, 0xf7, 0x36, 0x71, 0xcb, 0xf2, 0x3c, 0x72, 0xd6, 0xe0, 0x5d, 0x9f, 0x30, 0xf9, + 0x59, 0xf7, 0x03, 0xca, 0x29, 0x5c, 0xc7, 0x94, 0x75, 0x28, 0x33, 0x99, 0xdd, 0xae, 0x5f, 0xd6, + 0xdd, 0x53, 0x5c, 0x57, 0xd8, 0xfa, 0xc5, 0x56, 0xe5, 0x6d, 0xde, 0x72, 0x03, 0xdb, 0xf4, 0xad, + 0x80, 0x77, 0x1b, 0x02, 0xdf, 0x70, 0xa8, 0x43, 0xfb, 0x23, 0x69, 0xa4, 0xf2, 0x96, 0xdc, 0x68, + 0x7b, 0x67, 0x13, 0xd3, 0x4e, 0xc7, 0xe5, 0x1d, 0xe2, 0xf1, 0xd1, 0xbd, 0x2a, 0xab, 0x12, 0x36, + 0xb2, 0xa0, 0xff, 0x90, 0x05, 0xf0, 0x80, 0x39, 0x7b, 0x72, 0xe7, 0x43, 0x9f, 0x78, 0xfb, 0x9e, + 0xcb, 0xe1, 0xfb, 0xa0, 0xe8, 0xd3, 0x80, 0x9b, 0xae, 0x5d, 0xce, 0x6c, 0x64, 0x6a, 0x25, 0xe3, + 0xd1, 0x55, 0xa8, 0x15, 0x8e, 0x68, 0xc0, 0xf7, 0x9f, 0x44, 0xa1, 0x36, 0xdf, 0xb5, 0x3a, 0x67, + 0xbb, 0xba, 0x82, 0xe8, 0xa8, 0x10, 0x8f, 0xf6, 0x6d, 0xd8, 0x04, 0x40, 0xc5, 0x10, 0x6b, 0x66, + 0x85, 0xa6, 0x7e, 0x15, 0x6a, 0x25, 0x65, 0x5f, 0x28, 0x2f, 0x49, 0xe5, 0x3e, 0x50, 0x47, 0x25, + 0x35, 0xd9, 0xb7, 0xe1, 0x13, 0x50, 0x54, 0x93, 0x72, 0x6e, 0x23, 0x53, 0x9b, 0xdd, 0x7e, 0xb3, + 0x7e, 0x0b, 0x4f, 0x75, 0x65, 0xd8, 0xc8, 0x3f, 0x0f, 0xb5, 0x29, 0x94, 0xa8, 0xc2, 0x7d, 0x50, + 0x60, 0xae, 0xe3, 0x91, 0xa0, 0x9c, 0xdf, 0xc8, 0xd4, 0xe6, 0x8c, 0xad, 0xbf, 0x42, 0x6d, 0xd3, + 0x71, 0x79, 0xeb, 0xfc, 0xb4, 0x8e, 0x69, 0xa7, 0x21, 0x4d, 0xaa, 0xaf, 0x4d, 0x66, 0xb7, 0x15, + 0x29, 0x4d, 0x8c, 0x9b, 0xb6, 0x1d, 0x10, 0xc6, 0x90, 0x32, 0xa0, 0x7f, 0x97, 0x07, 0x4b, 0x83, + 0x0c, 0x9d, 0x04, 0xdd, 0xff, 0x3c, 0x41, 0x08, 0xbc, 0x86, 0xe9, 0xb9, 0xc7, 0x49, 0x20, 0x4a, + 0xcc, 0xbc, 0x20, 0x01, 0x73, 0xa9, 0x27, 0xe8, 0x2a, 0x19, 0x5a, 0x14, 0x6a, 0xeb, 0xca, 0x8b, + 0x1b, 0x50, 0x3a, 0x5a, 0x4e, 0x8b, 0x3f, 0x93, 0x52, 0x48, 0x00, 0xf0, 0x03, 0x4a, 0x9f, 0x99, + 0xae, 0xe7, 0xf2, 0xf2, 0xb4, 0x70, 0xee, 0xdd, 0x1b, 0x9c, 0xeb, 0x15, 0x6a, 0xec, 0xdf, 0x01, + 0x09, 0xda, 0x67, 0xe4, 0x28, 0xd6, 0x33, 0xd6, 0x62, 0x1f, 0xfb, 0x04, 0xf4, 0x8d, 0xe9, 0xa8, + 0x24, 0x26, 0xa2, 0x36, 0x77, 0xc1, 0x9c, 0x5c, 0x69, 0x11, 0xd7, 0x69, 0xf1, 0x72, 0x61, 0x23, + 0x53, 0xcb, 0x1b, 0xab, 0x51, 0xa8, 0x2d, 0xa7, 0xf5, 0xe4, 0xaa, 0x8e, 0x66, 0xc5, 0xf4, 0xa9, + 0x98, 0xa5, 0xea, 0xa2, 0x38, 0x6e, 0x5d, 0xfc, 0x9c, 0x1b, 0xae, 0x8b, 0x26, 0x6e, 0x4f, 0xb0, + 0x2e, 0x5e, 0x96, 0xd1, 0xdc, 0x18, 0x19, 0x3d, 0x05, 0x92, 0x77, 0x93, 0x07, 0x5d, 0x51, 0x1a, + 0xaf, 0x98, 0xd0, 0xb2, 0x4a, 0xe8, 0x62, 0x3a, 0x31, 0x3c, 0xe8, 0xea, 0x68, 0x46, 0x8c, 0xe3, + 0x4e, 0x1a, 0x4e, 0xe7, 0xf4, 0x9d, 0xd2, 0x59, 0x18, 0x37, 0x9d, 0x7f, 0x67, 0xc1, 0xc3, 0xc1, + 0x74, 0xee, 0x51, 0xef, 0x99, 0x1b, 0x74, 0x26, 0x98, 0xd2, 0x1e, 0xfd, 0x16, 0x6e, 0xab, 0x66, + 0x1f, 0x9f, 0x7e, 0x0b, 0xb7, 0x13, 0xfa, 0xe3, 0x82, 0x1d, 0xa6, 0x3f, 0x7f, 0x27, 0xfa, 0xa7, + 0xc7, 0xa5, 0xff, 0xb7, 0x0c, 0x58, 0xee, 0xd3, 0xbf, 0x77, 0x46, 0x19, 0x99, 0xf0, 0x45, 0xd4, + 0x0f, 0x2e, 0x37, 0x6e, 0x70, 0x5f, 0xe5, 0xc0, 0xca, 0x50, 0x70, 0x93, 0x2f, 0xae, 0xc1, 0xd3, + 0x3a, 0xf7, 0x6f, 0x9d, 0xd6, 0x13, 0xaa, 0xaf, 0xef, 0xb3, 0xa0, 0x74, 0xc0, 0x9c, 0x23, 0x0b, + 0xb7, 0x09, 0x87, 0x4d, 0x50, 0xf0, 0xc5, 0x48, 0x90, 0x3e, 0xbb, 0xfd, 0xc6, 0xad, 0x57, 0xa8, + 0x54, 0x52, 0x37, 0xa8, 0x52, 0x84, 0x9f, 0x80, 0x69, 0xe1, 0xaa, 0x20, 0xff, 0x15, 0x99, 0x93, + 0x96, 0xa4, 0xfe, 0x08, 0x41, 0xb9, 0x3b, 0x11, 0x34, 0xf6, 0x33, 0xe7, 0xcf, 0x2c, 0x00, 0x07, + 0xcc, 0x39, 0x71, 0x3b, 0x84, 0x9e, 0xff, 0x7f, 0x18, 0xfa, 0x14, 0x40, 0x8f, 0x5c, 0x72, 0x93, + 0x91, 0x2f, 0xce, 0x89, 0x87, 0x89, 0x19, 0x10, 0x7c, 0xa1, 0x8a, 0xf0, 0xf5, 0x28, 0xd4, 0xd6, + 0xa4, 0x85, 0x51, 0x8c, 0x8e, 0x16, 0x63, 0xe1, 0xb1, 0x92, 0x21, 0x82, 0x2f, 0xee, 0xb3, 0x1e, + 0x7f, 0x91, 0xef, 0xee, 0x26, 0x6e, 0x7b, 0xf4, 0xcb, 0x33, 0x62, 0x3b, 0x24, 0xa6, 0xe1, 0x3e, + 0x68, 0xaf, 0x81, 0x05, 0x6b, 0xd0, 0xaa, 0x48, 0xc0, 0x1c, 0x1a, 0x16, 0xf7, 0x13, 0x94, 0xbb, + 0xe7, 0x04, 0x4d, 0xa8, 0xc7, 0x7f, 0xca, 0x82, 0xa2, 0x3a, 0xff, 0xe0, 0x63, 0x30, 0xcd, 0xb8, + 0xc5, 0x89, 0xe0, 0x71, 0x7e, 0xbb, 0x32, 0x1a, 0xdb, 0xc5, 0x56, 0xfd, 0x38, 0x46, 0x20, 0x09, + 0x84, 0x1f, 0x80, 0x19, 0x1a, 0xd8, 0x24, 0x70, 0x3d, 0x47, 0x10, 0xf6, 0x32, 0xa5, 0xc3, 0x18, + 0x84, 0x7a, 0x58, 0x78, 0x0c, 0xe6, 0xd2, 0x4f, 0x27, 0x45, 0xe6, 0x3b, 0xb7, 0x3f, 0xca, 0x53, + 0x0a, 0x8a, 0xca, 0x01, 0x23, 0x70, 0x0f, 0x2c, 0x60, 0xea, 0x79, 0x04, 0x73, 0x97, 0x7a, 0x66, + 0x8b, 0xfa, 0xac, 0x9c, 0xdf, 0xc8, 0xd5, 0x4a, 0x46, 0x25, 0x0a, 0xb5, 0x95, 0xe4, 0x1d, 0x37, + 0x00, 0xd0, 0xd1, 0x7c, 0x5f, 0xf2, 0x94, 0xfa, 0x0c, 0x96, 0x41, 0x31, 0x79, 0x04, 0xc6, 0xdc, + 0x96, 0x50, 0x32, 0xdd, 0xcd, 0x7f, 0xfd, 0xa3, 0x36, 0xa5, 0x7f, 0x93, 0x01, 0x73, 0x69, 0x4f, + 0x26, 0x77, 0x19, 0x29, 0x87, 0x7e, 0xcf, 0x81, 0x82, 0x3a, 0xa1, 0x2b, 0x60, 0x26, 0x69, 0x47, + 0xe1, 0x4b, 0x1e, 0xf5, 0xe6, 0xf0, 0x43, 0x30, 0xcb, 0xe8, 0x79, 0x80, 0x89, 0x19, 0x3b, 0xa0, + 0x36, 0x5c, 0x89, 0x42, 0x0d, 0xca, 0x3d, 0x52, 0x8b, 0x3a, 0x02, 0x72, 0x16, 0x07, 0x01, 0x3f, + 0x02, 0xf3, 0x6a, 0x2d, 0xfd, 0x0b, 0xaa, 0x64, 0xac, 0x45, 0xa1, 0xf6, 0x70, 0x40, 0x57, 0xad, + 0xeb, 0xe8, 0x81, 0x14, 0x24, 0x65, 0xf5, 0x31, 0x58, 0xb4, 0x09, 0xe3, 0xae, 0x67, 0x09, 0xde, + 0xc5, 0xfe, 0xf2, 0x27, 0xd3, 0x7a, 0x14, 0x6a, 0xab, 0xd2, 0xc6, 0x30, 0x42, 0x47, 0x0b, 0x29, + 0x91, 0xf0, 0xe4, 0x10, 0x2c, 0xa7, 0x51, 0x89, 0x3b, 0x22, 0x4d, 0x46, 0x35, 0x0a, 0xb5, 0xca, + 0xa8, 0xa9, 0x9e, 0x4f, 0x30, 0x25, 0x4d, 0x1c, 0x83, 0x20, 0x6f, 0x5b, 0xdc, 0x92, 0xef, 0x60, + 0x24, 0xc6, 0x71, 0xb8, 0x5c, 0x1e, 0xe7, 0x49, 0x63, 0x16, 0x45, 0x63, 0xa6, 0xc2, 0x1d, 0x5c, + 0xd7, 0xd1, 0x03, 0x25, 0xe8, 0x35, 0xe7, 0x52, 0x82, 0x88, 0xbf, 0x19, 0xb7, 0x3a, 0x7e, 0x79, + 0x46, 0x18, 0x79, 0x14, 0x85, 0x5a, 0x79, 0xd0, 0x48, 0x0f, 0xa2, 0xa3, 0x45, 0x25, 0x3b, 0x49, + 0x44, 0x32, 0xc3, 0xc6, 0xc1, 0xf3, 0xab, 0x6a, 0xe6, 0xc5, 0x55, 0x35, 0xf3, 0xc7, 0x55, 0x35, + 0xf3, 0xed, 0x75, 0x75, 0xea, 0xc5, 0x75, 0x75, 0xea, 0xd7, 0xeb, 0xea, 0xd4, 0xe7, 0x3b, 0xb7, + 0xf6, 0xfc, 0xcd, 0x7f, 0xa7, 0x9c, 0x16, 0xc4, 0x9f, 0x18, 0x3b, 0xff, 0x04, 0x00, 0x00, 0xff, + 0xff, 0x90, 0xdf, 0x6a, 0x15, 0x6f, 0x11, 0x00, 0x00, +} + +func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgChannelOpenInit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChannelOpenInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgChannelOpenTry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgChannelOpenTry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChannelOpenTry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + 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)) + } + i-- + dAtA[i] = 0x2a + if len(m.CounterpartyVersion) > 0 { + i -= len(m.CounterpartyVersion) + copy(dAtA[i:], m.CounterpartyVersion) + i = encodeVarintTypes(dAtA, i, uint64(len(m.CounterpartyVersion))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.Channel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgChannelOpenAck) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgChannelOpenAck) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChannelOpenAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x32 + } + if m.ProofHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) + 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)) + } + i-- + dAtA[i] = 0x22 + if len(m.CounterpartyVersion) > 0 { + i -= len(m.CounterpartyVersion) + copy(dAtA[i:], m.CounterpartyVersion) + i = encodeVarintTypes(dAtA, i, uint64(len(m.CounterpartyVersion))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgChannelOpenConfirm) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgChannelOpenConfirm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChannelOpenConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if m.ProofHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) + 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)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgChannelCloseInit) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgChannelCloseInit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChannelCloseInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgChannelCloseConfirm) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgChannelCloseConfirm) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChannelCloseConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if m.ProofHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) + 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)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgPacket) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPacket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if m.ProofHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) + 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)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgTimeout) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgTimeout) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if m.NextSequenceRecv != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.NextSequenceRecv)) + i-- + dAtA[i] = 0x20 + } + if m.ProofHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) + 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)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgAcknowledgement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAcknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if m.ProofHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ProofHeight)) + 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)) + } + i-- + dAtA[i] = 0x1a + if len(m.Acknowledgement) > 0 { + i -= len(m.Acknowledgement) + copy(dAtA[i:], m.Acknowledgement) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Acknowledgement))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Packet.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Channel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Channel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x2a + } + if len(m.ConnectionHops) > 0 { + for iNdEx := len(m.ConnectionHops) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ConnectionHops[iNdEx]) + copy(dAtA[i:], m.ConnectionHops[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ConnectionHops[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + { + size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Ordering != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Ordering)) + i-- + dAtA[i] = 0x10 + } + if m.State != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.State)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Counterparty) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Counterparty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Counterparty) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ChannelID))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortID) > 0 { + i -= len(m.PortID) + copy(dAtA[i:], m.PortID) + i = encodeVarintTypes(dAtA, i, uint64(len(m.PortID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Packet) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Packet) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TimeoutTimestamp != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.TimeoutTimestamp)) + i-- + dAtA[i] = 0x40 + } + if m.TimeoutHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.TimeoutHeight)) + i-- + dAtA[i] = 0x38 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x32 + } + if len(m.DestinationChannel) > 0 { + i -= len(m.DestinationChannel) + copy(dAtA[i:], m.DestinationChannel) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DestinationChannel))) + i-- + dAtA[i] = 0x2a + } + if len(m.DestinationPort) > 0 { + i -= len(m.DestinationPort) + copy(dAtA[i:], m.DestinationPort) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DestinationPort))) + i-- + dAtA[i] = 0x22 + } + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0x12 + } + if m.Sequence != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgChannelOpenInit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Channel.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgChannelOpenTry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Channel.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.CounterpartyVersion) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.ProofInit.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgChannelOpenAck) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.CounterpartyVersion) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.ProofTry.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgChannelOpenConfirm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.ProofAck.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgChannelCloseInit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgChannelCloseConfirm) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.ProofInit.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgPacket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Packet.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Proof.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgTimeout) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Packet.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Proof.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + if m.NextSequenceRecv != 0 { + n += 1 + sovTypes(uint64(m.NextSequenceRecv)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgAcknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Packet.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.Acknowledgement) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Proof.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.ProofHeight != 0 { + n += 1 + sovTypes(uint64(m.ProofHeight)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Channel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.State != 0 { + n += 1 + sovTypes(uint64(m.State)) + } + if m.Ordering != 0 { + n += 1 + sovTypes(uint64(m.Ordering)) + } + l = m.Counterparty.Size() + n += 1 + l + sovTypes(uint64(l)) + if len(m.ConnectionHops) > 0 { + for _, s := range m.ConnectionHops { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Counterparty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ChannelID) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Packet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sequence != 0 { + n += 1 + sovTypes(uint64(m.Sequence)) + } + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.SourceChannel) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.DestinationPort) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.DestinationChannel) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.TimeoutHeight != 0 { + n += 1 + sovTypes(uint64(m.TimeoutHeight)) + } + if m.TimeoutTimestamp != 0 { + n += 1 + sovTypes(uint64(m.TimeoutTimestamp)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgChannelOpenInit) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelOpenInit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelOpenInit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgChannelOpenTry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelOpenTry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelOpenTry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Channel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Channel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgChannelOpenAck) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelOpenAck: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelOpenAck: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofTry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofTry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgChannelOpenConfirm) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelOpenConfirm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelOpenConfirm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofAck", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofAck.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgChannelCloseInit) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelCloseInit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelCloseInit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgChannelCloseConfirm) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgChannelCloseConfirm: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChannelCloseConfirm: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofInit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProofInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPacket) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPacket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPacket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgTimeout) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgTimeout: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTimeout: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextSequenceRecv", wireType) + } + m.NextSequenceRecv = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextSequenceRecv |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgAcknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Packet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Packet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Acknowledgement", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Acknowledgement = append(m.Acknowledgement[:0], dAtA[iNdEx:postIndex]...) + if m.Acknowledgement == nil { + m.Acknowledgement = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", wireType) + } + m.ProofHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProofHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Channel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Channel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Channel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + m.State = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.State |= types1.State(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ordering", wireType) + } + m.Ordering = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Ordering |= types1.Order(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectionHops", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectionHops = append(m.ConnectionHops, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Counterparty) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Counterparty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Counterparty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Packet) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Packet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Packet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourcePort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationPort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationPort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DestinationChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) + } + m.TimeoutHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) + } + m.TimeoutTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/04-channel/types/types.proto b/x/ibc/04-channel/types/types.proto new file mode 100644 index 000000000000..0d447a37362a --- /dev/null +++ b/x/ibc/04-channel/types/types.proto @@ -0,0 +1,151 @@ +syntax = "proto3"; +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"; +import "x/ibc/types/types.proto"; + +// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It is +// called by a relayer on Chain A. +message MsgChannelOpenInit { + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; + Channel channel = 3 [(gogoproto.nullable) = false]; + bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel +// on Chain B. +message MsgChannelOpenTry { + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + 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\""]; + uint64 proof_height = 6 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge +// the change of channel state to TRYOPEN on Chain B. +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\""]; + uint64 proof_height = 5 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 6 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to acknowledge +// the change of channel state to OPEN on Chain A. +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\""]; + uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain A +// to close a channel with Chain B. +message MsgChannelCloseInit { + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; + bytes signer = 3 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B +// to acknowledge the change of channel state to CLOSED on Chain A. +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\""]; + uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// 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]; + uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// 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]; + 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"]; +} + +// MsgAcknowledgement receives incoming IBC acknowledgement +message MsgAcknowledgement { + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes acknowledgement = 2; + cosmos_sdk.x.ibc.commitment.v1.MerkleProof proof = 3 [(gogoproto.nullable) = false]; + uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""]; + bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// Channel defines pipeline for exactly-once packet delivery between specific +// modules on separate blockchains, which has at least one end capable of sending +// packets and one end capable of receiving packets. +message Channel { + option (gogoproto.goproto_getters) = false; + + // current state of the channel end + cosmos_sdk.x.ibc.v1.State state = 1; + // whether the channel is ordered or unordered + cosmos_sdk.x.ibc.v1.Order ordering = 2; + // counterparty channel end + Counterparty counterparty = 3 [(gogoproto.nullable) = false]; + // list of connection identifiers, in order, along which packets sent on this + // channel will travel + repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; + // opaque channel version, which is agreed upon during the handshake + string version = 5; +} + +// Counterparty defines a channel end counterparty +message Counterparty { + option (gogoproto.goproto_getters) = false; + + // port on the counterparty chain which owns the other end of the channel. + string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""]; + // channel end on the counterparty chain + string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""]; +} + +// Packet defines a type that carries data across different chains through IBC +message Packet { + option (gogoproto.goproto_getters) = false; + + // number corresponds to the order of sends and receives, where a Packet with + // an earlier sequence number must be sent and received before a Packet with a + // later sequence number. + uint64 sequence = 1; + // identifies the port on the sending chain. + string source_port = 2 [(gogoproto.moretags) = "yaml:\"source_port\""]; + // identifies the channel end on the sending chain. + string source_channel = 3 [(gogoproto.moretags) = "yaml:\"source_channel\""]; + // identifies the port on the receiving chain. + string destination_port = 4 [(gogoproto.moretags) = "yaml:\"destination_port\""]; + // identifies the channel end on the receiving chain. + string destination_channel = 5 [(gogoproto.moretags) = "yaml:\"destination_channel\""]; + // actual opaque bytes transferred directly to the application module + bytes data = 6; + // block height after which the packet times out + uint64 timeout_height = 7 [(gogoproto.moretags) = "yaml:\"timeout_height\""]; + // block timestamp (in nanoseconds) after which the packet times out + uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""]; +} diff --git a/x/ibc/05-port/alias.go b/x/ibc/05-port/alias.go index 31dd696ea206..5aa03309b5e7 100644 --- a/x/ibc/05-port/alias.go +++ b/x/ibc/05-port/alias.go @@ -26,8 +26,6 @@ var ( ErrPortNotFound = types.ErrPortNotFound ErrInvalidPort = types.ErrInvalidPort ErrInvalidRoute = types.ErrInvalidRoute - PortPath = types.PortPath - KeyPort = types.KeyPort ) type ( diff --git a/x/ibc/05-port/keeper/keeper.go b/x/ibc/05-port/keeper/keeper.go index 39bf7dc9be82..5882b6048ba9 100644 --- a/x/ibc/05-port/keeper/keeper.go +++ b/x/ibc/05-port/keeper/keeper.go @@ -31,7 +31,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // isBounded checks a given port ID is already bounded. func (k Keeper) isBound(ctx sdk.Context, portID string) bool { - _, ok := k.scopedKeeper.GetCapability(ctx, types.PortPath(portID)) + _, ok := k.scopedKeeper.GetCapability(ctx, ibctypes.PortPath(portID)) return ok } @@ -48,7 +48,7 @@ func (k *Keeper) BindPort(ctx sdk.Context, portID string) *capability.Capability panic(fmt.Sprintf("port %s is already bound", portID)) } - key, err := k.scopedKeeper.NewCapability(ctx, types.PortPath(portID)) + key, err := k.scopedKeeper.NewCapability(ctx, ibctypes.PortPath(portID)) if err != nil { panic(err.Error()) } @@ -66,12 +66,12 @@ func (k Keeper) Authenticate(ctx sdk.Context, key *capability.Capability, portID panic(err.Error()) } - return k.scopedKeeper.AuthenticateCapability(ctx, key, types.PortPath(portID)) + return k.scopedKeeper.AuthenticateCapability(ctx, key, ibctypes.PortPath(portID)) } // LookupModuleByPort will return the IBCModule along with the capability associated with a given portID func (k Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *capability.Capability, bool) { - modules, cap, ok := k.scopedKeeper.LookupModules(ctx, types.PortPath(portID)) + modules, cap, ok := k.scopedKeeper.LookupModules(ctx, ibctypes.PortPath(portID)) if !ok { return "", nil, false } diff --git a/x/ibc/05-port/keeper/keeper_test.go b/x/ibc/05-port/keeper/keeper_test.go index 8afa3295c2b7..4e9c26ed188d 100644 --- a/x/ibc/05-port/keeper/keeper_test.go +++ b/x/ibc/05-port/keeper/keeper_test.go @@ -8,7 +8,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/ibc/05-port/keeper" @@ -22,7 +21,6 @@ var ( type KeeperTestSuite struct { suite.Suite - cdc *codec.Codec ctx sdk.Context keeper *keeper.Keeper } @@ -31,7 +29,6 @@ func (suite *KeeperTestSuite) SetupTest() { isCheckTx := false app := simapp.Setup(isCheckTx) - suite.cdc = app.Codec() suite.ctx = app.BaseApp.NewContext(isCheckTx, abci.Header{}) suite.keeper = &app.IBCKeeper.PortKeeper } diff --git a/x/ibc/05-port/types/keys.go b/x/ibc/05-port/types/keys.go index b1250e0e4463..6e79bb535066 100644 --- a/x/ibc/05-port/types/keys.go +++ b/x/ibc/05-port/types/keys.go @@ -1,9 +1,5 @@ package types -import ( - "fmt" -) - const ( // SubModuleName defines the IBC port name SubModuleName = "port" @@ -17,15 +13,3 @@ const ( // QuerierRoute is the querier route for IBC ports QuerierRoute = SubModuleName ) - -// The following paths are the keys to the store as defined in https://github.com/cosmos/ics/tree/master/spec/ics-005-port-allocation#store-paths - -// PortPath defines the path under which ports paths are stored -func PortPath(portID string) string { - return fmt.Sprintf("ports/%s", portID) -} - -// KeyPort returns the store key for a particular port -func KeyPort(portID string) []byte { - return []byte(PortPath(portID)) -} diff --git a/x/ibc/05-port/types/module.go b/x/ibc/05-port/types/module.go index 013fac6a37b3..4499cbd81774 100644 --- a/x/ibc/05-port/types/module.go +++ b/x/ibc/05-port/types/module.go @@ -4,8 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/capability" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) // IBCModule defines an interface that implements all the callbacks @@ -13,7 +13,7 @@ import ( type IBCModule interface { OnChanOpenInit( ctx sdk.Context, - order channelexported.Order, + order ibctypes.Order, connectionHops []string, portID string, channelID string, @@ -24,7 +24,7 @@ type IBCModule interface { OnChanOpenTry( ctx sdk.Context, - order channelexported.Order, + order ibctypes.Order, connectionHops []string, portID, channelID string, diff --git a/x/ibc/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index 8d93ba6bb898..dbbdb19c9966 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -11,6 +11,7 @@ import ( clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" + connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" @@ -168,7 +169,7 @@ func (cs ClientState) VerifyClientConsensusState( // VerifyConnectionState verifies a proof of the connection state of the // specified connection end stored on the target machine. func (cs ClientState) VerifyConnectionState( - cdc *codec.Codec, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, proof commitmentexported.Proof, @@ -185,7 +186,12 @@ func (cs ClientState) VerifyConnectionState( return err } - bz, err := cdc.MarshalBinaryBare(connectionEnd) + connection, ok := connectionEnd.(connectiontypes.ConnectionEnd) + if !ok { + return fmt.Errorf("invalid connection type %T", connectionEnd) + } + + bz, err := cdc.MarshalBinaryBare(&connection) if err != nil { return err } @@ -200,7 +206,7 @@ func (cs ClientState) VerifyConnectionState( // VerifyChannelState verifies a proof of the channel state of the specified // channel end, under the specified port, stored on the target machine. func (cs ClientState) VerifyChannelState( - cdc *codec.Codec, + cdc codec.Marshaler, height uint64, prefix commitmentexported.Prefix, proof commitmentexported.Proof, @@ -218,7 +224,12 @@ func (cs ClientState) VerifyChannelState( return err } - bz, err := cdc.MarshalBinaryBare(channel) + channelEnd, ok := channel.(channeltypes.Channel) + if !ok { + return fmt.Errorf("invalid channel type %T", channel) + } + + bz, err := cdc.MarshalBinaryBare(&channelEnd) if err != nil { return err } diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index 3b88105708fc..e2a4c71b12e1 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -2,12 +2,11 @@ package types_test import ( connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) const ( @@ -129,7 +128,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { tc := tc err := tc.clientState.VerifyClientConsensusState( - suite.cdc, tc.consensusState.Root, height, "chainA", tc.consensusState.GetHeight(), tc.prefix, tc.proof, tc.consensusState, + suite.aminoCdc, tc.consensusState.Root, height, "chainA", tc.consensusState.GetHeight(), tc.prefix, tc.proof, tc.consensusState, ) if tc.expPass { @@ -142,7 +141,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { func (suite *TendermintTestSuite) TestVerifyConnectionState() { counterparty := connection.NewCounterparty("clientB", testConnectionID, commitmenttypes.NewMerklePrefix([]byte("ibc"))) - conn := connection.NewConnectionEnd(connectionexported.OPEN, testConnectionID, "clientA", counterparty, []string{"1.0.0"}) + conn := connection.NewConnectionEnd(ibctypes.OPEN, testConnectionID, "clientA", counterparty, []string{"1.0.0"}) testCases := []struct { name string @@ -225,7 +224,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { func (suite *TendermintTestSuite) TestVerifyChannelState() { counterparty := channel.NewCounterparty(testPortID, testChannelID) - ch := channel.NewChannel(channelexported.OPEN, channelexported.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") + ch := channel.NewChannel(ibctypes.OPEN, ibctypes.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") testCases := []struct { name string @@ -295,7 +294,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { tc := tc err := tc.clientState.VerifyChannelState( - suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, tc.channel, tc.consensusState, + suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, &tc.channel, tc.consensusState, ) if tc.expPass { diff --git a/x/ibc/07-tendermint/types/tendermint_test.go b/x/ibc/07-tendermint/types/tendermint_test.go index 3deeadccef45..0516a2487079 100644 --- a/x/ibc/07-tendermint/types/tendermint_test.go +++ b/x/ibc/07-tendermint/types/tendermint_test.go @@ -9,8 +9,8 @@ import ( tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) const ( @@ -24,18 +24,20 @@ const ( type TendermintTestSuite struct { suite.Suite - cdc *codec.Codec - privVal tmtypes.PrivValidator - valSet *tmtypes.ValidatorSet - header ibctmtypes.Header - now time.Time + aminoCdc *codec.Codec + cdc codec.Marshaler + privVal tmtypes.PrivValidator + valSet *tmtypes.ValidatorSet + header ibctmtypes.Header + now time.Time } func (suite *TendermintTestSuite) SetupTest() { - suite.cdc = codec.New() - codec.RegisterCrypto(suite.cdc) - ibctmtypes.RegisterCodec(suite.cdc) - commitmenttypes.RegisterCodec(suite.cdc) + checkTx := false + app := simapp.Setup(checkTx) + + suite.aminoCdc = app.Codec() + suite.cdc = app.AppCodec() suite.now = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) suite.privVal = tmtypes.NewMockPV() diff --git a/x/ibc/09-localhost/types/client_state.go b/x/ibc/09-localhost/types/client_state.go index b325d30f6945..d3d6fa536563 100644 --- a/x/ibc/09-localhost/types/client_state.go +++ b/x/ibc/09-localhost/types/client_state.go @@ -14,7 +14,9 @@ import ( clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" + connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" + channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" @@ -125,7 +127,7 @@ func (cs ClientState) VerifyClientConsensusState( // VerifyConnectionState verifies a proof of the connection state of the // specified connection end stored locally. func (cs ClientState) VerifyConnectionState( - cdc *codec.Codec, + cdc codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, _ commitmentexported.Proof, @@ -143,12 +145,13 @@ func (cs ClientState) VerifyConnectionState( return sdkerrors.Wrapf(clienttypes.ErrFailedConnectionStateVerification, "not found for path %s", path) } - var prevConnection connectionexported.ConnectionI - if err := cdc.UnmarshalBinaryBare(bz, &prevConnection); err != nil { + var prevConnection connectiontypes.ConnectionEnd + err = cdc.UnmarshalBinaryBare(bz, &prevConnection) + if err != nil { return err } - if connectionEnd != prevConnection { + if connectionEnd != &prevConnection { return sdkerrors.Wrapf( clienttypes.ErrFailedConnectionStateVerification, "connection end ≠ previous stored connection: \n%v\n≠\n%v", connectionEnd, prevConnection, @@ -161,7 +164,7 @@ func (cs ClientState) VerifyConnectionState( // VerifyChannelState verifies a proof of the channel state of the specified // channel end, under the specified port, stored on the local machine. func (cs ClientState) VerifyChannelState( - cdc *codec.Codec, + cdc codec.Marshaler, _ uint64, prefix commitmentexported.Prefix, _ commitmentexported.Proof, @@ -180,11 +183,13 @@ func (cs ClientState) VerifyChannelState( return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "not found for path %s", path) } - var prevChannel channelexported.ChannelI - if err := cdc.UnmarshalBinaryBare(bz, &prevChannel); err != nil { + var prevChannel channeltypes.Channel + err = cdc.UnmarshalBinaryBare(bz, &prevChannel) + if err != nil { return err } - if channel != prevChannel { + + if channel != &prevChannel { return sdkerrors.Wrapf( clienttypes.ErrFailedChannelStateVerification, "channel end ≠ previous stored channel: \n%v\n≠\n%v", channel, prevChannel, diff --git a/x/ibc/09-localhost/types/client_state_test.go b/x/ibc/09-localhost/types/client_state_test.go index ed3063a97e81..df9ea88f425e 100644 --- a/x/ibc/09-localhost/types/client_state_test.go +++ b/x/ibc/09-localhost/types/client_state_test.go @@ -2,11 +2,10 @@ package types_test import ( connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) const ( @@ -81,7 +80,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientConsensusState() { tc := tc err := tc.clientState.VerifyClientConsensusState( - suite.cdc, nil, height, "chainA", 0, tc.prefix, tc.proof, nil, + suite.aminoCdc, nil, height, "chainA", 0, tc.prefix, tc.proof, nil, // suite.cdc, height, tc.prefix, tc.proof, nil, ) @@ -96,7 +95,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientConsensusState() { func (suite *LocalhostTestSuite) TestVerifyConnectionState() { counterparty := connection.NewCounterparty("clientB", testConnectionID, commitmenttypes.NewMerklePrefix([]byte("ibc"))) - conn := connection.NewConnectionEnd(connectionexported.OPEN, testConnectionID, "clientA", counterparty, []string{"1.0.0"}) + conn := connection.NewConnectionEnd(ibctypes.OPEN, testConnectionID, "clientA", counterparty, []string{"1.0.0"}) testCases := []struct { name string @@ -127,7 +126,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() { tc := tc err := tc.clientState.VerifyConnectionState( - suite.cdc, height, tc.prefix, tc.proof, testConnectionID, tc.connection, nil, + suite.cdc, height, tc.prefix, tc.proof, testConnectionID, &tc.connection, nil, ) if tc.expPass { @@ -140,7 +139,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() { func (suite *LocalhostTestSuite) TestVerifyChannelState() { counterparty := channel.NewCounterparty(testPortID, testChannelID) - ch := channel.NewChannel(channelexported.OPEN, channelexported.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") + ch := channel.NewChannel(ibctypes.OPEN, ibctypes.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") testCases := []struct { name string @@ -178,7 +177,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { tc := tc err := tc.clientState.VerifyChannelState( - suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, tc.channel, nil, + suite.cdc, height, tc.prefix, tc.proof, testPortID, testChannelID, &tc.channel, nil, ) if tc.expPass { diff --git a/x/ibc/09-localhost/types/localhost_test.go b/x/ibc/09-localhost/types/localhost_test.go index fc3a0f6dc0b1..2e7b785ae169 100644 --- a/x/ibc/09-localhost/types/localhost_test.go +++ b/x/ibc/09-localhost/types/localhost_test.go @@ -8,9 +8,9 @@ import ( dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store/cachekv" "github.com/cosmos/cosmos-sdk/store/dbadapter" - commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) const ( @@ -20,14 +20,17 @@ const ( type LocalhostTestSuite struct { suite.Suite - cdc *codec.Codec - store *cachekv.Store + aminoCdc *codec.Codec + cdc codec.Marshaler + store *cachekv.Store } func (suite *LocalhostTestSuite) SetupTest() { - suite.cdc = codec.New() - codec.RegisterCrypto(suite.cdc) - commitmenttypes.RegisterCodec(suite.cdc) + checkTx := false + app := simapp.Setup(checkTx) + + suite.aminoCdc = app.Codec() + suite.cdc = app.AppCodec() mem := dbadapter.Store{DB: dbm.NewMemDB()} suite.store = cachekv.NewStore(mem) diff --git a/x/ibc/20-transfer/alias.go b/x/ibc/20-transfer/alias.go index 6eabf4f509a8..f8569d02e0a8 100644 --- a/x/ibc/20-transfer/alias.go +++ b/x/ibc/20-transfer/alias.go @@ -37,6 +37,7 @@ var ( GetDenomPrefix = types.GetDenomPrefix GetModuleAccountName = types.GetModuleAccountName NewMsgTransfer = types.NewMsgTransfer + RegisterInterfaces = types.RegisterInterfaces // variable aliases ModuleCdc = types.ModuleCdc diff --git a/x/ibc/20-transfer/handler.go b/x/ibc/20-transfer/handler.go index 63a31d930738..9f34ef6388c2 100644 --- a/x/ibc/20-transfer/handler.go +++ b/x/ibc/20-transfer/handler.go @@ -20,7 +20,7 @@ func NewHandler(k Keeper) sdk.Handler { // See createOutgoingPacket in spec:https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay func handleMsgTransfer(ctx sdk.Context, k Keeper, msg MsgTransfer) (*sdk.Result, error) { if err := k.SendTransfer( - ctx, msg.SourcePort, msg.SourceChannel, msg.DestHeight, msg.Amount, msg.Sender, msg.Receiver, + ctx, msg.SourcePort, msg.SourceChannel, msg.DestinationHeight, msg.Amount, msg.Sender, msg.Receiver, ); err != nil { return nil, err } diff --git a/x/ibc/20-transfer/handler_test.go b/x/ibc/20-transfer/handler_test.go index 221b051920d3..0839d0c356ab 100644 --- a/x/ibc/20-transfer/handler_test.go +++ b/x/ibc/20-transfer/handler_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/stretchr/testify/suite" + abci "github.com/tendermint/tendermint/abci/types" tmtypes "github.com/tendermint/tendermint/types" @@ -13,9 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" transfer "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer" @@ -85,8 +84,8 @@ func (suite *HandlerTestSuite) TestHandleMsgTransfer() { // Setup channel from A to B suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnection) res, err = handler(ctx, msg) suite.Require().Error(err) @@ -158,7 +157,7 @@ func NewTestChain(clientID string) *TestChain { // Creates simple context for testing purposes func (chain *TestChain) GetContext() sdk.Context { - return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.ChainID, Height: chain.Header.Height}) + return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height}) } // createClient will create a client for clientChain on targetChain @@ -167,7 +166,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { // Commit and create a new block on appTarget to get a fresh CommitID client.App.Commit() commitID := client.App.LastCommitID() - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -183,7 +182,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo) // Create target ctx ctxTarget := chain.GetContext() @@ -229,7 +228,7 @@ func (chain *TestChain) updateClient(client *TestChain) { commitID := client.App.LastCommitID() client.Header = nextHeader(client) - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -245,17 +244,17 @@ func (chain *TestChain) updateClient(client *TestChain) { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo) consensusState := ibctmtypes.ConsensusState{ - Height: uint64(client.Header.Height), + Height: uint64(client.Header.SignedHeader.Header.Height), Timestamp: client.Header.Time, Root: commitmenttypes.NewMerkleRoot(commitID.Hash), ValidatorSet: client.Vals, } chain.App.IBCKeeper.ClientKeeper.SetClientConsensusState( - ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, + ctxTarget, client.ClientID, uint64(client.Header.SignedHeader.Header.Height), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), @@ -276,9 +275,9 @@ func (chain *TestChain) updateClient(client *TestChain) { func (chain *TestChain) createConnection( connID, counterpartyConnID, clientID, counterpartyClientID string, - state connectionexported.State, + state ibctypes.State, ) connectiontypes.ConnectionEnd { - counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) + counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) connection := connectiontypes.ConnectionEnd{ State: state, ClientID: clientID, @@ -293,7 +292,7 @@ func (chain *TestChain) createConnection( // nolint: unused func (chain *TestChain) createChannel( portID, channelID, counterpartyPortID, counterpartyChannelID string, - state channelexported.State, order channelexported.Order, connectionID string, + state ibctypes.State, order ibctypes.Order, connectionID string, ) channeltypes.Channel { counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := channeltypes.NewChannel(state, order, counterparty, @@ -305,6 +304,6 @@ func (chain *TestChain) createChannel( } func nextHeader(chain *TestChain) ibctmtypes.Header { - return ibctmtypes.CreateTestHeader(chain.Header.ChainID, chain.Header.Height+1, + return ibctmtypes.CreateTestHeader(chain.Header.SignedHeader.Header.ChainID, chain.Header.SignedHeader.Header.Height+1, chain.Header.Time.Add(time.Minute), chain.Vals, chain.Signers) } diff --git a/x/ibc/20-transfer/keeper/keeper.go b/x/ibc/20-transfer/keeper/keeper.go index 4ec6f06f3dbe..ce9cc0add178 100644 --- a/x/ibc/20-transfer/keeper/keeper.go +++ b/x/ibc/20-transfer/keeper/keeper.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/capability" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" - porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types" "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -30,7 +29,7 @@ const ( // Keeper defines the IBC transfer keeper type Keeper struct { storeKey sdk.StoreKey - cdc *codec.Codec + cdc codec.Marshaler channelKeeper types.ChannelKeeper portKeeper types.PortKeeper @@ -41,7 +40,7 @@ type Keeper struct { // NewKeeper creates a new IBC transfer Keeper instance func NewKeeper( - cdc *codec.Codec, key sdk.StoreKey, + cdc codec.Marshaler, key sdk.StoreKey, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capability.ScopedKeeper, ) Keeper { @@ -96,7 +95,7 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { // IsBound checks if the transfer module is already bound to the desired port func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { - _, ok := k.scopedKeeper.GetCapability(ctx, porttypes.PortPath(portID)) + _, ok := k.scopedKeeper.GetCapability(ctx, ibctypes.PortPath(portID)) return ok } @@ -108,7 +107,7 @@ func (k Keeper) BindPort(ctx sdk.Context, portID string) error { store.Set([]byte(types.PortKey), []byte(portID)) cap := k.portKeeper.BindPort(ctx, portID) - return k.ClaimCapability(ctx, cap, porttypes.PortPath(portID)) + return k.ClaimCapability(ctx, cap, ibctypes.PortPath(portID)) } // GetPort returns the portID for the transfer module. Used in ExportGenesis diff --git a/x/ibc/20-transfer/keeper/keeper_test.go b/x/ibc/20-transfer/keeper/keeper_test.go index b3a0c512fda8..bbc8d8b9b982 100644 --- a/x/ibc/20-transfer/keeper/keeper_test.go +++ b/x/ibc/20-transfer/keeper/keeper_test.go @@ -13,9 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types" @@ -135,7 +133,7 @@ func NewTestChain(clientID string) *TestChain { // Creates simple context for testing purposes func (chain *TestChain) GetContext() sdk.Context { - return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.ChainID, Height: chain.Header.Height}) + return chain.App.BaseApp.NewContext(false, abci.Header{ChainID: chain.Header.SignedHeader.Header.ChainID, Height: chain.Header.SignedHeader.Header.Height}) } // createClient will create a client for clientChain on targetChain @@ -144,7 +142,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { // Commit and create a new block on appTarget to get a fresh CommitID client.App.Commit() commitID := client.App.LastCommitID() - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -160,7 +158,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo) // Create target ctx ctxTarget := chain.GetContext() @@ -206,7 +204,7 @@ func (chain *TestChain) updateClient(client *TestChain) { commitID := client.App.LastCommitID() client.Header = nextHeader(client) - client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.Height, Time: client.Header.Time}}) + client.App.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{Height: client.Header.SignedHeader.Header.Height, Time: client.Header.Time}}) // Set HistoricalInfo on client chain after Commit ctxClient := client.GetContext() @@ -222,17 +220,17 @@ func (chain *TestChain) updateClient(client *TestChain) { }, Valset: validators, } - client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.Height, histInfo) + client.App.StakingKeeper.SetHistoricalInfo(ctxClient, client.Header.SignedHeader.Header.Height, histInfo) consensusState := ibctmtypes.ConsensusState{ - Height: uint64(client.Header.Height), + Height: client.Header.GetHeight(), Timestamp: client.Header.Time, Root: commitmenttypes.NewMerkleRoot(commitID.Hash), ValidatorSet: client.Vals, } chain.App.IBCKeeper.ClientKeeper.SetClientConsensusState( - ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, + ctxTarget, client.ClientID, client.Header.GetHeight(), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), @@ -253,9 +251,9 @@ func (chain *TestChain) updateClient(client *TestChain) { func (chain *TestChain) createConnection( connID, counterpartyConnID, clientID, counterpartyClientID string, - state connectionexported.State, + state ibctypes.State, ) connectiontypes.ConnectionEnd { - counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) + counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) connection := connectiontypes.ConnectionEnd{ State: state, ClientID: clientID, @@ -269,7 +267,7 @@ func (chain *TestChain) createConnection( func (chain *TestChain) createChannel( portID, channelID, counterpartyPortID, counterpartyChannelID string, - state channelexported.State, order channelexported.Order, connectionID string, + state ibctypes.State, order ibctypes.Order, connectionID string, ) channeltypes.Channel { counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := channeltypes.NewChannel(state, order, counterparty, @@ -281,6 +279,6 @@ func (chain *TestChain) createChannel( } func nextHeader(chain *TestChain) ibctmtypes.Header { - return ibctmtypes.CreateTestHeader(chain.Header.ChainID, chain.Header.Height+1, + return ibctmtypes.CreateTestHeader(chain.Header.SignedHeader.Header.ChainID, chain.Header.SignedHeader.Header.Height+1, chain.Header.Time.Add(time.Minute), chain.Vals, chain.Signers) } diff --git a/x/ibc/20-transfer/keeper/relay.go b/x/ibc/20-transfer/keeper/relay.go index e0d66e458bd0..6d6fb7b01cac 100644 --- a/x/ibc/20-transfer/keeper/relay.go +++ b/x/ibc/20-transfer/keeper/relay.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" + channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) @@ -31,16 +31,16 @@ func (k Keeper) SendTransfer( ) error { sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) if !found { - return sdkerrors.Wrap(channel.ErrChannelNotFound, sourceChannel) + return sdkerrors.Wrap(channeltypes.ErrChannelNotFound, sourceChannel) } - destinationPort := sourceChannelEnd.Counterparty.PortID - destinationChannel := sourceChannelEnd.Counterparty.ChannelID + destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() + destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() // get the next sequence sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel) if !found { - return channel.ErrSequenceSendNotFound + return channeltypes.ErrSequenceSendNotFound } return k.createOutgoingPacket(ctx, sequence, sourcePort, sourceChannel, destinationPort, destinationChannel, destHeight, amount, sender, receiver) @@ -59,7 +59,7 @@ func (k Keeper) createOutgoingPacket( ) error { channelCap, ok := k.scopedKeeper.GetCapability(ctx, ibctypes.ChannelCapabilityPath(sourcePort, sourceChannel)) if !ok { - return sdkerrors.Wrap(channel.ErrChannelCapabilityNotFound, "module does not own channel capability") + return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") } // NOTE: // - Coins transferred from the destination chain should have their denomination @@ -127,7 +127,7 @@ func (k Keeper) createOutgoingPacket( amount, sender.String(), receiver, ) - packet := channel.NewPacket( + packet := channeltypes.NewPacket( packetData.GetBytes(), seq, sourcePort, @@ -141,7 +141,7 @@ func (k Keeper) createOutgoingPacket( return k.channelKeeper.SendPacket(ctx, channelCap, packet) } -func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channel.Packet, data types.FungibleTokenPacketData) error { +func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketData) error { // NOTE: packet data type already checked in handler.go if len(data.Amount) != 1 { @@ -190,18 +190,18 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channel.Packet, data types. return k.bankKeeper.SendCoins(ctx, escrowAddress, receiver, coins) } -func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channel.Packet, data types.FungibleTokenPacketData, ack types.FungibleTokenPacketAcknowledgement) error { +func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketData, ack types.FungibleTokenPacketAcknowledgement) error { if !ack.Success { return k.refundPacketAmount(ctx, packet, data) } return nil } -func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channel.Packet, data types.FungibleTokenPacketData) error { +func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketData) error { return k.refundPacketAmount(ctx, packet, data) } -func (k Keeper) refundPacketAmount(ctx sdk.Context, packet channel.Packet, data types.FungibleTokenPacketData) error { +func (k Keeper) refundPacketAmount(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketData) error { // NOTE: packet data type already checked in handler.go if len(data.Amount) != 1 { diff --git a/x/ibc/20-transfer/keeper/relay_test.go b/x/ibc/20-transfer/keeper/relay_test.go index 16df8202c32d..490af4148602 100644 --- a/x/ibc/20-transfer/keeper/relay_test.go +++ b/x/ibc/20-transfer/keeper/relay_test.go @@ -5,8 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types" ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" @@ -27,8 +25,8 @@ func (suite *KeeperTestSuite) TestSendTransfer() { func() { suite.chainA.App.BankKeeper.AddCoins(suite.chainA.GetContext(), testAddr1, testCoins) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnection) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort1, testChannel1, 1) }, true, true}, {"successful transfer from external chain", prefixCoins, @@ -37,8 +35,8 @@ func (suite *KeeperTestSuite) TestSendTransfer() { _, err := suite.chainA.App.BankKeeper.AddCoins(suite.chainA.GetContext(), testAddr1, prefixCoins) suite.Require().NoError(err) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnection) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort1, testChannel1, 1) }, false, true}, {"source channel not found", testCoins, @@ -46,32 +44,32 @@ func (suite *KeeperTestSuite) TestSendTransfer() { {"next seq send not found", testCoins, func() { suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnection) }, true, false}, // createOutgoingPacket tests // - source chain {"send coins failed", testCoins, func() { suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnection) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort1, testChannel1, 1) }, true, false}, // - receiving chain {"send from module account failed", testCoins, func() { suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnection) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort1, testChannel1, 1) }, false, false}, {"channel capability not found", testCoins, func() { suite.chainA.App.BankKeeper.AddCoins(suite.chainA.GetContext(), testAddr1, testCoins) suite.chainA.CreateClient(suite.chainB) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainA.createChannel(testPort1, testChannel1, testPort2, testChannel2, ibctypes.OPEN, ibctypes.ORDERED, testConnection) suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), testPort1, testChannel1, 1) // Release channel capability cap, _ := suite.chainA.App.ScopedTransferKeeper.GetCapability(suite.chainA.GetContext(), capName) diff --git a/x/ibc/20-transfer/module.go b/x/ibc/20-transfer/module.go index cb50f0d25d7c..dac2528b1486 100644 --- a/x/ibc/20-transfer/module.go +++ b/x/ibc/20-transfer/module.go @@ -11,12 +11,12 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/capability" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" port "github.com/cosmos/cosmos-sdk/x/ibc/05-port" porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types" @@ -71,6 +71,11 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return cli.GetQueryCmd(cdc, QuerierRoute) } +// RegisterInterfaceTypes registers module concrete types into protobuf Any. +func (AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegistry) { + RegisterInterfaces(registry) +} + // AppModule represents the AppModule for this module type AppModule struct { AppModuleBasic @@ -138,7 +143,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V // Implement IBCModule callbacks func (am AppModule) OnChanOpenInit( ctx sdk.Context, - order channelexported.Order, + order ibctypes.Order, connectionHops []string, portID string, channelID string, @@ -169,7 +174,7 @@ func (am AppModule) OnChanOpenInit( func (am AppModule) OnChanOpenTry( ctx sdk.Context, - order channelexported.Order, + order ibctypes.Order, connectionHops []string, portID, channelID string, diff --git a/x/ibc/20-transfer/types/codec.go b/x/ibc/20-transfer/types/codec.go index 80c1c767b978..3e9118a1c962 100644 --- a/x/ibc/20-transfer/types/codec.go +++ b/x/ibc/20-transfer/types/codec.go @@ -2,21 +2,39 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" ) -// ModuleCdc defines the IBC transfer codec. -var ModuleCdc = codec.New() - // RegisterCodec registers the IBC transfer types func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgTransfer{}, "ibc/transfer/MsgTransfer", nil) cdc.RegisterConcrete(FungibleTokenPacketData{}, "ibc/transfer/PacketDataTransfer", nil) } +// RegisterInterfaces register the ibc transfer module interfaces to protobuf +// Any. +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgTransfer{}) +} + +var ( + amino = codec.New() + + // ModuleCdc references the global x/ibc/20-transfer module codec. Note, the codec + // should ONLY be used in certain instances of tests and for JSON encoding as Amino + // is still used for that purpose. + // + // The actual codec used for serialization should be provided to x/ibc/20-transfer and + // defined at the application level. + ModuleCdc = codec.NewHybridCodec(amino, cdctypes.NewInterfaceRegistry()) +) + func init() { - RegisterCodec(ModuleCdc) - channel.RegisterCodec(ModuleCdc) - commitmenttypes.RegisterCodec(ModuleCdc) + RegisterCodec(amino) + channel.RegisterCodec(amino) + commitmenttypes.RegisterCodec(amino) + amino.Seal() } diff --git a/x/ibc/20-transfer/types/expected_keepers.go b/x/ibc/20-transfer/types/expected_keepers.go index 1bb41ea225bd..a9d96eee8144 100644 --- a/x/ibc/20-transfer/types/expected_keepers.go +++ b/x/ibc/20-transfer/types/expected_keepers.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/capability" clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" - channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" + channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ) // AccountKeeper defines the contract required for account APIs. @@ -27,7 +27,7 @@ type BankKeeper interface { // ChannelKeeper defines the expected IBC channel keeper type ChannelKeeper interface { - GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channel.Channel, found bool) + GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) SendPacket(ctx sdk.Context, channelCap *capability.Capability, packet channelexported.PacketI) error PacketExecuted(ctx sdk.Context, chanCap *capability.Capability, packet channelexported.PacketI, acknowledgement []byte) error diff --git a/x/ibc/20-transfer/types/msgs.go b/x/ibc/20-transfer/types/msgs.go index 35ffe8dd072f..5dc814d59d16 100644 --- a/x/ibc/20-transfer/types/msgs.go +++ b/x/ibc/20-transfer/types/msgs.go @@ -6,28 +6,22 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between ICS20 enabled chains. -// See ICS Spec here: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures -type MsgTransfer struct { - SourcePort string `json:"source_port" yaml:"source_port"` // the port on which the packet will be sent - SourceChannel string `json:"source_channel" yaml:"source_channel"` // the channel by which the packet will be sent - DestHeight uint64 `json:"dest_height" yaml:"dest_height"` // the current height of the destination chain - Amount sdk.Coins `json:"amount" yaml:"amount"` // the tokens to be transferred - Sender sdk.AccAddress `json:"sender" yaml:"sender"` // the sender address - Receiver string `json:"receiver" yaml:"receiver"` // the recipient address on the destination chain -} +// msg types +const ( + TypeMsgTransfer = "transfer" +) // NewMsgTransfer creates a new MsgTransfer instance func NewMsgTransfer( sourcePort, sourceChannel string, destHeight uint64, amount sdk.Coins, sender sdk.AccAddress, receiver string, ) MsgTransfer { return MsgTransfer{ - SourcePort: sourcePort, - SourceChannel: sourceChannel, - DestHeight: destHeight, - Amount: amount, - Sender: sender, - Receiver: receiver, + SourcePort: sourcePort, + SourceChannel: sourceChannel, + DestinationHeight: destHeight, + Amount: amount, + Sender: sender, + Receiver: receiver, } } @@ -38,7 +32,7 @@ func (MsgTransfer) Route() string { // Type implements sdk.Msg func (MsgTransfer) Type() string { - return "transfer" + return TypeMsgTransfer } // ValidateBasic implements sdk.Msg diff --git a/x/ibc/20-transfer/types/msgs_test.go b/x/ibc/20-transfer/types/msgs_test.go index 679613561bde..a53b6e3e57f9 100644 --- a/x/ibc/20-transfer/types/msgs_test.go +++ b/x/ibc/20-transfer/types/msgs_test.go @@ -96,7 +96,7 @@ func TestMsgTransferGetSignBytes(t *testing.T) { msg := NewMsgTransfer(validPort, validChannel, 10, coins, addr1, addr2) res := msg.GetSignBytes() - expected := `{"type":"ibc/transfer/MsgTransfer","value":{"amount":[{"amount":"100","denom":"atom"}],"dest_height":"10","receiver":"cosmos1w3jhxarpv3j8yvs7f9y7g","sender":"cosmos1w3jhxarpv3j8yvg4ufs4x","source_channel":"testchannel","source_port":"testportid"}}` + expected := `{"type":"ibc/transfer/MsgTransfer","value":{"amount":[{"amount":"100","denom":"atom"}],"destination_height":"10","receiver":"cosmos1w3jhxarpv3j8yvs7f9y7g","sender":"cosmos1w3jhxarpv3j8yvg4ufs4x","source_channel":"testchannel","source_port":"testportid"}}` require.Equal(t, expected, string(res)) } diff --git a/x/ibc/20-transfer/types/packet.go b/x/ibc/20-transfer/types/packet.go index 6e7f74c089e3..5ce4a4dfc4b5 100644 --- a/x/ibc/20-transfer/types/packet.go +++ b/x/ibc/20-transfer/types/packet.go @@ -1,20 +1,10 @@ package types import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// FungibleTokenPacketData defines a struct for the packet payload -// See FungibleTokenPacketData spec: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures -type FungibleTokenPacketData struct { - Amount sdk.Coins `json:"amount" yaml:"amount"` // the tokens to be transferred - Sender string `json:"sender" yaml:"sender"` // the sender address - Receiver string `json:"receiver" yaml:"receiver"` // the recipient address on the destination chain -} - // NewFungibleTokenPacketData contructs a new FungibleTokenPacketData instance func NewFungibleTokenPacketData( amount sdk.Coins, sender, receiver string) FungibleTokenPacketData { @@ -25,18 +15,6 @@ func NewFungibleTokenPacketData( } } -// String returns a string representation of FungibleTokenPacketData -func (ftpd FungibleTokenPacketData) String() string { - return fmt.Sprintf(`FungibleTokenPacketData: - Amount: %s - Sender: %s - Receiver: %s`, - ftpd.Amount.String(), - ftpd.Sender, - ftpd.Receiver, - ) -} - // ValidateBasic is used for validating the token transfer func (ftpd FungibleTokenPacketData) ValidateBasic() error { if !ftpd.Amount.IsAllPositive() { @@ -59,14 +37,6 @@ func (ftpd FungibleTokenPacketData) GetBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(ftpd)) } -// FungibleTokenPacketAcknowledgement contains a boolean success flag and an optional error msg -// error msg is empty string on success -// See spec for onAcknowledgePacket: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay -type FungibleTokenPacketAcknowledgement struct { - Success bool `json:"success" yaml:"success"` - Error string `json:"error" yaml:"error"` -} - // GetBytes is a helper for serialising func (ack FungibleTokenPacketAcknowledgement) GetBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(ack)) diff --git a/x/ibc/20-transfer/types/types.pb.go b/x/ibc/20-transfer/types/types.pb.go new file mode 100644 index 000000000000..b2b4304a6801 --- /dev/null +++ b/x/ibc/20-transfer/types/types.pb.go @@ -0,0 +1,1111 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/ibc/20-transfer/types/types.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between ICS20 enabled chains. +// See ICS Spec here: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +type MsgTransfer struct { + // the port on which the packet will be sent + SourcePort string `protobuf:"bytes,1,opt,name=source_port,json=sourcePort,proto3" json:"source_port,omitempty" yaml:"source_port"` + // the channel by which the packet will be sent + SourceChannel string `protobuf:"bytes,2,opt,name=source_channel,json=sourceChannel,proto3" json:"source_channel,omitempty" yaml:"source_channel"` + // the current height of the destination chain + DestinationHeight uint64 `protobuf:"varint,3,opt,name=destination_height,json=destinationHeight,proto3" json:"destination_height,omitempty" yaml:"destination_height"` + // the tokens to be transferred + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` + // the sender address + Sender github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=sender,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"sender,omitempty"` + // the recipient address on the destination chain + Receiver string `protobuf:"bytes,6,opt,name=receiver,proto3" json:"receiver,omitempty"` +} + +func (m *MsgTransfer) Reset() { *m = MsgTransfer{} } +func (m *MsgTransfer) String() string { return proto.CompactTextString(m) } +func (*MsgTransfer) ProtoMessage() {} +func (*MsgTransfer) Descriptor() ([]byte, []int) { + return fileDescriptor_2979e3085e18bdce, []int{0} +} +func (m *MsgTransfer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTransfer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTransfer.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgTransfer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTransfer.Merge(m, src) +} +func (m *MsgTransfer) XXX_Size() int { + return m.Size() +} +func (m *MsgTransfer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTransfer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTransfer proto.InternalMessageInfo + +func (m *MsgTransfer) GetSourcePort() string { + if m != nil { + return m.SourcePort + } + return "" +} + +func (m *MsgTransfer) GetSourceChannel() string { + if m != nil { + return m.SourceChannel + } + return "" +} + +func (m *MsgTransfer) GetDestinationHeight() uint64 { + if m != nil { + return m.DestinationHeight + } + return 0 +} + +func (m *MsgTransfer) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func (m *MsgTransfer) GetSender() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Sender + } + return nil +} + +func (m *MsgTransfer) GetReceiver() string { + if m != nil { + return m.Receiver + } + return "" +} + +// FungibleTokenPacketData defines a struct for the packet payload +// See FungibleTokenPacketData spec: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +type FungibleTokenPacketData struct { + // the tokens to be transferred + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` + // the sender address + Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` + // the recipient address on the destination chain + Receiver string `protobuf:"bytes,3,opt,name=receiver,proto3" json:"receiver,omitempty"` +} + +func (m *FungibleTokenPacketData) Reset() { *m = FungibleTokenPacketData{} } +func (m *FungibleTokenPacketData) String() string { return proto.CompactTextString(m) } +func (*FungibleTokenPacketData) ProtoMessage() {} +func (*FungibleTokenPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_2979e3085e18bdce, []int{1} +} +func (m *FungibleTokenPacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FungibleTokenPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FungibleTokenPacketData.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FungibleTokenPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_FungibleTokenPacketData.Merge(m, src) +} +func (m *FungibleTokenPacketData) XXX_Size() int { + return m.Size() +} +func (m *FungibleTokenPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_FungibleTokenPacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_FungibleTokenPacketData proto.InternalMessageInfo + +func (m *FungibleTokenPacketData) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func (m *FungibleTokenPacketData) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *FungibleTokenPacketData) GetReceiver() string { + if m != nil { + return m.Receiver + } + return "" +} + +// FungibleTokenPacketAcknowledgement contains a boolean success flag and an optional error msg +// error msg is empty string on success +// See spec for onAcknowledgePacket: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay +type FungibleTokenPacketAcknowledgement struct { + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` +} + +func (m *FungibleTokenPacketAcknowledgement) Reset() { *m = FungibleTokenPacketAcknowledgement{} } +func (m *FungibleTokenPacketAcknowledgement) String() string { return proto.CompactTextString(m) } +func (*FungibleTokenPacketAcknowledgement) ProtoMessage() {} +func (*FungibleTokenPacketAcknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_2979e3085e18bdce, []int{2} +} +func (m *FungibleTokenPacketAcknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FungibleTokenPacketAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FungibleTokenPacketAcknowledgement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FungibleTokenPacketAcknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_FungibleTokenPacketAcknowledgement.Merge(m, src) +} +func (m *FungibleTokenPacketAcknowledgement) XXX_Size() int { + return m.Size() +} +func (m *FungibleTokenPacketAcknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_FungibleTokenPacketAcknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_FungibleTokenPacketAcknowledgement proto.InternalMessageInfo + +func (m *FungibleTokenPacketAcknowledgement) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +func (m *FungibleTokenPacketAcknowledgement) GetError() string { + if m != nil { + return m.Error + } + return "" +} + +func init() { + proto.RegisterType((*MsgTransfer)(nil), "cosmos_sdk.x.ibc.transfer.v1.MsgTransfer") + proto.RegisterType((*FungibleTokenPacketData)(nil), "cosmos_sdk.x.ibc.transfer.v1.FungibleTokenPacketData") + proto.RegisterType((*FungibleTokenPacketAcknowledgement)(nil), "cosmos_sdk.x.ibc.transfer.v1.FungibleTokenPacketAcknowledgement") +} + +func init() { + proto.RegisterFile("x/ibc/20-transfer/types/types.proto", fileDescriptor_2979e3085e18bdce) +} + +var fileDescriptor_2979e3085e18bdce = []byte{ + // 487 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x8d, 0x49, 0x1b, 0xca, 0x06, 0x90, 0xba, 0x40, 0x71, 0x23, 0xb0, 0x23, 0x23, 0x21, 0x5f, + 0x62, 0x37, 0x05, 0x09, 0x89, 0x13, 0x71, 0x11, 0x02, 0x09, 0x50, 0x65, 0xe5, 0x84, 0x84, 0x22, + 0x7b, 0x3d, 0xd8, 0x2b, 0xc7, 0xbb, 0xd1, 0xee, 0x3a, 0x34, 0x7f, 0xc1, 0x07, 0xf0, 0x05, 0x88, + 0x0f, 0xe9, 0xb1, 0x47, 0x4e, 0x06, 0x25, 0x7f, 0x90, 0x23, 0x27, 0x54, 0xdb, 0x29, 0x81, 0x16, + 0xc4, 0x85, 0x8b, 0xed, 0x37, 0x33, 0xef, 0x79, 0xde, 0xec, 0x2c, 0xba, 0x77, 0xe4, 0xd2, 0x90, + 0xb8, 0xfb, 0x7b, 0x3d, 0x25, 0x02, 0x26, 0xdf, 0x81, 0x70, 0xd5, 0x6c, 0x02, 0xb2, 0x7a, 0x3a, + 0x13, 0xc1, 0x15, 0xc7, 0x77, 0x08, 0x97, 0x19, 0x97, 0x23, 0x19, 0xa5, 0xce, 0x91, 0x43, 0x43, + 0xe2, 0xac, 0x8a, 0x9d, 0x69, 0xbf, 0x73, 0x5f, 0x25, 0x54, 0x44, 0xa3, 0x49, 0x20, 0xd4, 0xcc, + 0x2d, 0x09, 0x6e, 0xcc, 0x63, 0xfe, 0xf3, 0xab, 0x52, 0xe9, 0x6c, 0x9f, 0x13, 0xb6, 0x3e, 0x36, + 0x51, 0xfb, 0x95, 0x8c, 0x87, 0xb5, 0x1a, 0x7e, 0x84, 0xda, 0x92, 0xe7, 0x82, 0xc0, 0x68, 0xc2, + 0x85, 0xd2, 0xb5, 0xae, 0x66, 0x5f, 0xf1, 0x76, 0x96, 0x85, 0x89, 0x67, 0x41, 0x36, 0x7e, 0x6c, + 0xad, 0x25, 0x2d, 0x1f, 0x55, 0xe8, 0x90, 0x0b, 0x85, 0x9f, 0xa0, 0xeb, 0x75, 0x8e, 0x24, 0x01, + 0x63, 0x30, 0xd6, 0x2f, 0x95, 0xdc, 0xdd, 0x65, 0x61, 0xde, 0xfa, 0x85, 0x5b, 0xe7, 0x2d, 0xff, + 0x5a, 0x15, 0x38, 0xa8, 0x30, 0x7e, 0x89, 0x70, 0x04, 0x52, 0x51, 0x16, 0x28, 0xca, 0xd9, 0x28, + 0x01, 0x1a, 0x27, 0x4a, 0x6f, 0x76, 0x35, 0x7b, 0xc3, 0xbb, 0xbb, 0x2c, 0xcc, 0xdd, 0x4a, 0xe5, + 0x7c, 0x8d, 0xe5, 0x6f, 0xaf, 0x05, 0x9f, 0x97, 0x31, 0xfc, 0x16, 0xb5, 0x82, 0x8c, 0xe7, 0x4c, + 0xe9, 0x1b, 0xdd, 0xa6, 0xdd, 0xde, 0xbf, 0xe1, 0xac, 0x8d, 0x70, 0xda, 0x77, 0x0e, 0x38, 0x65, + 0xde, 0xde, 0x71, 0x61, 0x36, 0x3e, 0x7d, 0x35, 0xed, 0x98, 0xaa, 0x24, 0x0f, 0x1d, 0xc2, 0x33, + 0xb7, 0x2a, 0xab, 0x5f, 0x3d, 0x19, 0xa5, 0xf5, 0xbc, 0x4e, 0x09, 0xd2, 0xaf, 0x45, 0xf1, 0x0b, + 0xd4, 0x92, 0xc0, 0x22, 0x10, 0xfa, 0x66, 0x57, 0xb3, 0xaf, 0x7a, 0xfd, 0xef, 0x85, 0xd9, 0xfb, + 0x07, 0x95, 0x01, 0x21, 0x83, 0x28, 0x12, 0x20, 0xa5, 0x5f, 0x0b, 0xe0, 0x0e, 0xda, 0x12, 0x40, + 0x80, 0x4e, 0x41, 0xe8, 0xad, 0xd3, 0x99, 0xf9, 0x67, 0xd8, 0xfa, 0xac, 0xa1, 0xdb, 0xcf, 0x72, + 0x16, 0xd3, 0x70, 0x0c, 0x43, 0x9e, 0x02, 0x3b, 0x0c, 0x48, 0x0a, 0xea, 0x69, 0xa0, 0x82, 0x35, + 0x87, 0xda, 0xff, 0x70, 0xb8, 0x73, 0xe6, 0xb0, 0x3c, 0xc8, 0x0b, 0xdb, 0x6d, 0xfe, 0xd6, 0xee, + 0x10, 0x59, 0x17, 0x74, 0x3b, 0x20, 0x29, 0xe3, 0xef, 0xc7, 0x10, 0xc5, 0x90, 0x01, 0x53, 0x58, + 0x47, 0x97, 0x65, 0x4e, 0x08, 0x48, 0x59, 0xee, 0xd7, 0x96, 0xbf, 0x82, 0xf8, 0x26, 0xda, 0x04, + 0x21, 0xf8, 0xea, 0x97, 0x15, 0xf0, 0x5e, 0x1f, 0xcf, 0x0d, 0xed, 0x64, 0x6e, 0x68, 0xdf, 0xe6, + 0x86, 0xf6, 0x61, 0x61, 0x34, 0x4e, 0x16, 0x46, 0xe3, 0xcb, 0xc2, 0x68, 0xbc, 0x79, 0xf8, 0x57, + 0x57, 0x7f, 0xb8, 0x58, 0x61, 0xab, 0x5c, 0xfd, 0x07, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x05, + 0x59, 0xe4, 0x6c, 0x7a, 0x03, 0x00, 0x00, +} + +func (m *MsgTransfer) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgTransfer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Receiver) > 0 { + i -= len(m.Receiver) + copy(dAtA[i:], m.Receiver) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Receiver))) + i-- + dAtA[i] = 0x32 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0x2a + } + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.DestinationHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.DestinationHeight)) + i-- + dAtA[i] = 0x18 + } + if len(m.SourceChannel) > 0 { + i -= len(m.SourceChannel) + copy(dAtA[i:], m.SourceChannel) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SourceChannel))) + i-- + dAtA[i] = 0x12 + } + if len(m.SourcePort) > 0 { + i -= len(m.SourcePort) + copy(dAtA[i:], m.SourcePort) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SourcePort))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FungibleTokenPacketData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FungibleTokenPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FungibleTokenPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Receiver) > 0 { + i -= len(m.Receiver) + copy(dAtA[i:], m.Receiver) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Receiver))) + i-- + dAtA[i] = 0x1a + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0x12 + } + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *FungibleTokenPacketAcknowledgement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FungibleTokenPacketAcknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FungibleTokenPacketAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x12 + } + if m.Success { + i-- + if m.Success { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgTransfer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SourcePort) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.SourceChannel) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.DestinationHeight != 0 { + n += 1 + sovTypes(uint64(m.DestinationHeight)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Receiver) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *FungibleTokenPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Receiver) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *FungibleTokenPacketAcknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Success { + n += 2 + } + l = len(m.Error) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgTransfer) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgTransfer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTransfer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePort", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourcePort = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DestinationHeight", wireType) + } + m.DestinationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DestinationHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = append(m.Sender[:0], dAtA[iNdEx:postIndex]...) + if m.Sender == nil { + m.Sender = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receiver", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Receiver = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FungibleTokenPacketData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FungibleTokenPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FungibleTokenPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receiver", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Receiver = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FungibleTokenPacketAcknowledgement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FungibleTokenPacketAcknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FungibleTokenPacketAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Success = bool(v != 0) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/20-transfer/types/types.proto b/x/ibc/20-transfer/types/types.proto new file mode 100644 index 000000000000..2dbe03e73dcf --- /dev/null +++ b/x/ibc/20-transfer/types/types.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package cosmos_sdk.x.ibc.transfer.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/20-transfer/types"; + +import "third_party/proto/gogoproto/gogo.proto"; +import "types/types.proto"; + +// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between ICS20 enabled chains. +// See ICS Spec here: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +message MsgTransfer { + // the port on which the packet will be sent + string source_port = 1 [ + (gogoproto.moretags) = "yaml:\"source_port\"" + ]; + // the channel by which the packet will be sent + string source_channel = 2 [ + (gogoproto.moretags) = "yaml:\"source_channel\"" + ]; + // the current height of the destination chain + uint64 destination_height = 3 [ + (gogoproto.moretags) = "yaml:\"destination_height\"" + ]; + // the tokens to be transferred + repeated cosmos_sdk.v1.Coin amount = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // the sender address + bytes sender = 5 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + // the recipient address on the destination chain + string receiver = 6; +} + +// FungibleTokenPacketData defines a struct for the packet payload +// See FungibleTokenPacketData spec: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +message FungibleTokenPacketData { + // the tokens to be transferred + repeated cosmos_sdk.v1.Coin amount = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // the sender address + string sender = 2; + // the recipient address on the destination chain + string receiver = 3; +} + +// FungibleTokenPacketAcknowledgement contains a boolean success flag and an optional error msg +// error msg is empty string on success +// See spec for onAcknowledgePacket: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay +message FungibleTokenPacketAcknowledgement { + bool success = 1; + string error = 2; +} \ No newline at end of file diff --git a/x/ibc/23-commitment/types/codec.go b/x/ibc/23-commitment/types/codec.go index e7e761867fc8..a1579a944dc4 100644 --- a/x/ibc/23-commitment/types/codec.go +++ b/x/ibc/23-commitment/types/codec.go @@ -2,12 +2,12 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" ) -var SubModuleCdc *codec.Codec - -// RegisterCodec registers types declared in this package +// RegisterCodec registers the necessary x/ibc/23-commitment interfaces and concrete types +// on the provided Amino codec. These types are used for Amino JSON serialization. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.Root)(nil), nil) cdc.RegisterInterface((*exported.Prefix)(nil), nil) @@ -18,10 +18,21 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MerklePrefix{}, "ibc/commitment/MerklePrefix", nil) cdc.RegisterConcrete(MerklePath{}, "ibc/commitment/MerklePath", nil) cdc.RegisterConcrete(MerkleProof{}, "ibc/commitment/MerkleProof", nil) - - SetSubModuleCodec(cdc) } -func SetSubModuleCodec(cdc *codec.Codec) { - SubModuleCdc = cdc +var ( + amino = codec.New() + + // SubModuleCdc references the global x/ibc/23-commitmentl module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/ibc/23-commitmentl and + // defined at the application level. + SubModuleCdc = codec.NewHybridCodec(amino, cdctypes.NewInterfaceRegistry()) +) + +func init() { + RegisterCodec(amino) + amino.Seal() } diff --git a/x/ibc/23-commitment/types/key_path.go b/x/ibc/23-commitment/types/key_path.go new file mode 100644 index 000000000000..4d79e2e726e2 --- /dev/null +++ b/x/ibc/23-commitment/types/key_path.go @@ -0,0 +1,28 @@ +package types + +import ( + fmt "fmt" + "net/url" +) + +// AppendKey appends a new key to a KeyPath +func (pth KeyPath) AppendKey(key []byte, enc KeyEncoding) KeyPath { + pth.Keys = append(pth.Keys, &Key{name: key, enc: enc}) + return pth +} + +// String implements the fmt.Stringer interface +func (pth *KeyPath) String() string { + res := "" + for _, key := range pth.Keys { + switch key.enc { + case URL: + res += "/" + url.PathEscape(string(key.name)) + case HEX: + res += "/x:" + fmt.Sprintf("%X", key.name) + default: + panic("unexpected key encoding type") + } + } + return res +} diff --git a/x/ibc/23-commitment/types/merkle.go b/x/ibc/23-commitment/types/merkle.go index 74f6353f339a..5da657892ec2 100644 --- a/x/ibc/23-commitment/types/merkle.go +++ b/x/ibc/23-commitment/types/merkle.go @@ -4,11 +4,11 @@ import ( "errors" "net/url" - "github.com/tendermint/tendermint/crypto/merkle" - "github.com/cosmos/cosmos-sdk/store/rootmulti" "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" + + "github.com/tendermint/tendermint/crypto/merkle" ) // ICS 023 Merkle Types Implementation @@ -17,13 +17,7 @@ import ( // Merkle proof implementation of the Proof interface // Applied on SDK-based IBC implementation -var _ exported.Root = MerkleRoot{} - -// MerkleRoot defines a merkle root hash. -// In the Cosmos SDK, the AppHash of a block header becomes the root. -type MerkleRoot struct { - Hash []byte `json:"hash" yaml:"hash"` -} +var _ exported.Root = (*MerkleRoot)(nil) // NewMerkleRoot constructs a new MerkleRoot func NewMerkleRoot(hash []byte) MerkleRoot { @@ -32,28 +26,22 @@ func NewMerkleRoot(hash []byte) MerkleRoot { } } -// GetCommitmentType implements RootI interface -func (MerkleRoot) GetCommitmentType() exported.Type { - return exported.Merkle -} - // GetHash implements RootI interface func (mr MerkleRoot) GetHash() []byte { return mr.Hash } +// GetCommitmentType implements RootI interface +func (MerkleRoot) GetCommitmentType() exported.Type { + return exported.Merkle +} + // IsEmpty returns true if the root is empty func (mr MerkleRoot) IsEmpty() bool { return len(mr.GetHash()) == 0 } -var _ exported.Prefix = MerklePrefix{} - -// MerklePrefix is merkle path prefixed to the key. -// The constructed key from the Path and the key will be append(Path.KeyPath, append(Path.KeyPrefix, key...)) -type MerklePrefix struct { - KeyPrefix []byte `json:"key_prefix" yaml:"key_prefix"` // byte slice prefixed before the key -} +var _ exported.Prefix = (*MerklePrefix)(nil) // NewMerklePrefix constructs new MerklePrefix instance func NewMerklePrefix(keyPrefix []byte) MerklePrefix { @@ -77,19 +65,13 @@ func (mp MerklePrefix) IsEmpty() bool { return len(mp.Bytes()) == 0 } -var _ exported.Path = MerklePath{} - -// MerklePath is the path used to verify commitment proofs, which can be an arbitrary -// structured object (defined by a commitment type). -type MerklePath struct { - KeyPath merkle.KeyPath `json:"key_path" yaml:"key_path"` // byte slice prefixed before the key -} +var _ exported.Path = (*MerklePath)(nil) // NewMerklePath creates a new MerklePath instance func NewMerklePath(keyPathStr []string) MerklePath { - merkleKeyPath := merkle.KeyPath{} + merkleKeyPath := KeyPath{} for _, keyStr := range keyPathStr { - merkleKeyPath = merkleKeyPath.AppendKey([]byte(keyStr), merkle.KeyEncodingURL) + merkleKeyPath = merkleKeyPath.AppendKey([]byte(keyStr), URL) } return MerklePath{ @@ -118,7 +100,7 @@ func (mp MerklePath) Pretty() string { // IsEmpty returns true if the path is empty func (mp MerklePath) IsEmpty() bool { - return len(mp.KeyPath) == 0 + return len(mp.KeyPath.Keys) == 0 } // ApplyPrefix constructs a new commitment path from the arguments. It interprets @@ -138,15 +120,7 @@ func ApplyPrefix(prefix exported.Prefix, path string) (MerklePath, error) { return NewMerklePath([]string{string(prefix.Bytes()), path}), nil } -var _ exported.Proof = MerkleProof{} - -// MerkleProof is a wrapper type that contains a merkle proof. -// It demonstrates membership or non-membership for an element or set of elements, -// verifiable in conjunction with a known commitment root. Proofs should be -// succinct. -type MerkleProof struct { - Proof *merkle.Proof `json:"proof" yaml:"proof"` -} +var _ exported.Proof = (*MerkleProof)(nil) // GetCommitmentType implements ProofI func (MerkleProof) GetCommitmentType() exported.Type { @@ -175,7 +149,7 @@ func (proof MerkleProof) VerifyNonMembership(root exported.Root, path exported.P // IsEmpty returns true if the root is empty func (proof MerkleProof) IsEmpty() bool { - return (proof == MerkleProof{}) || proof.Proof == nil + return proof.Proof.Equal(nil) || proof.Equal(MerkleProof{}) || proof.Proof.Equal(nil) || proof.Proof.Equal(merkle.Proof{}) } // ValidateBasic checks if the proof is empty. diff --git a/x/ibc/23-commitment/types/merkle_test.go b/x/ibc/23-commitment/types/merkle_test.go index 6694ef07fa7d..1c436b0743b8 100644 --- a/x/ibc/23-commitment/types/merkle_test.go +++ b/x/ibc/23-commitment/types/merkle_test.go @@ -53,7 +53,7 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { root := types.NewMerkleRoot(tc.root) path := types.NewMerklePath(tc.pathArr) - err := proof.VerifyMembership(root, path, tc.value) + err := proof.VerifyMembership(&root, path, tc.value) if tc.shouldPass { // nolint: scopelint @@ -108,7 +108,7 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { root := types.NewMerkleRoot(tc.root) path := types.NewMerklePath(tc.pathArr) - err := proof.VerifyNonMembership(root, path) + err := proof.VerifyNonMembership(&root, path) if tc.shouldPass { // nolint: scopelint diff --git a/x/ibc/23-commitment/types/types.pb.go b/x/ibc/23-commitment/types/types.pb.go new file mode 100644 index 000000000000..3c60a5c696b4 --- /dev/null +++ b/x/ibc/23-commitment/types/types.pb.go @@ -0,0 +1,1304 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/ibc/23-commitment/types/types.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + merkle "github.com/tendermint/tendermint/crypto/merkle" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// KeyEncoding defines the encoding format of a key's bytes. +type KeyEncoding int32 + +const ( + // URL encoding + URL KeyEncoding = 0 + // Hex encoding + HEX KeyEncoding = 1 +) + +var KeyEncoding_name = map[int32]string{ + 0: "KEY_ENCODING_URL_UNSPECIFIED", + 1: "KEY_ENCODING_HEX", +} + +var KeyEncoding_value = map[string]int32{ + "KEY_ENCODING_URL_UNSPECIFIED": 0, + "KEY_ENCODING_HEX": 1, +} + +func (KeyEncoding) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_1004b8837466efb9, []int{0} +} + +// MerkleRoot defines a merkle root hash. +// In the Cosmos SDK, the AppHash of a block header becomes the root. +type MerkleRoot struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *MerkleRoot) Reset() { *m = MerkleRoot{} } +func (m *MerkleRoot) String() string { return proto.CompactTextString(m) } +func (*MerkleRoot) ProtoMessage() {} +func (*MerkleRoot) Descriptor() ([]byte, []int) { + return fileDescriptor_1004b8837466efb9, []int{0} +} +func (m *MerkleRoot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MerkleRoot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MerkleRoot.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MerkleRoot) XXX_Merge(src proto.Message) { + xxx_messageInfo_MerkleRoot.Merge(m, src) +} +func (m *MerkleRoot) XXX_Size() int { + return m.Size() +} +func (m *MerkleRoot) XXX_DiscardUnknown() { + xxx_messageInfo_MerkleRoot.DiscardUnknown(m) +} + +var xxx_messageInfo_MerkleRoot proto.InternalMessageInfo + +// MerklePrefix is merkle path prefixed to the key. +// The constructed key from the Path and the key will be append(Path.KeyPath, append(Path.KeyPrefix, key...)) +type MerklePrefix struct { + KeyPrefix []byte `protobuf:"bytes,1,opt,name=key_prefix,json=keyPrefix,proto3" json:"key_prefix,omitempty" yaml:"key_prefix"` +} + +func (m *MerklePrefix) Reset() { *m = MerklePrefix{} } +func (m *MerklePrefix) String() string { return proto.CompactTextString(m) } +func (*MerklePrefix) ProtoMessage() {} +func (*MerklePrefix) Descriptor() ([]byte, []int) { + return fileDescriptor_1004b8837466efb9, []int{1} +} +func (m *MerklePrefix) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MerklePrefix) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MerklePrefix.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MerklePrefix) XXX_Merge(src proto.Message) { + xxx_messageInfo_MerklePrefix.Merge(m, src) +} +func (m *MerklePrefix) XXX_Size() int { + return m.Size() +} +func (m *MerklePrefix) XXX_DiscardUnknown() { + xxx_messageInfo_MerklePrefix.DiscardUnknown(m) +} + +var xxx_messageInfo_MerklePrefix proto.InternalMessageInfo + +func (m *MerklePrefix) GetKeyPrefix() []byte { + if m != nil { + return m.KeyPrefix + } + return nil +} + +// MerklePath is the path used to verify commitment proofs, which can be an arbitrary +// structured object (defined by a commitment type). +type MerklePath struct { + KeyPath KeyPath `protobuf:"bytes,1,opt,name=key_path,json=keyPath,proto3" json:"key_path" yaml:"key_path"` +} + +func (m *MerklePath) Reset() { *m = MerklePath{} } +func (*MerklePath) ProtoMessage() {} +func (*MerklePath) Descriptor() ([]byte, []int) { + return fileDescriptor_1004b8837466efb9, []int{2} +} +func (m *MerklePath) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MerklePath) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MerklePath.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MerklePath) XXX_Merge(src proto.Message) { + xxx_messageInfo_MerklePath.Merge(m, src) +} +func (m *MerklePath) XXX_Size() int { + return m.Size() +} +func (m *MerklePath) XXX_DiscardUnknown() { + xxx_messageInfo_MerklePath.DiscardUnknown(m) +} + +var xxx_messageInfo_MerklePath proto.InternalMessageInfo + +func (m *MerklePath) GetKeyPath() KeyPath { + if m != nil { + return m.KeyPath + } + return KeyPath{} +} + +// MerkleProof is a wrapper type that contains a merkle proof. +// It demonstrates membership or non-membership for an element or set of elements, +// verifiable in conjunction with a known commitment root. Proofs should be +// succinct. +type MerkleProof struct { + Proof *merkle.Proof `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *MerkleProof) Reset() { *m = MerkleProof{} } +func (m *MerkleProof) String() string { return proto.CompactTextString(m) } +func (*MerkleProof) ProtoMessage() {} +func (*MerkleProof) Descriptor() ([]byte, []int) { + return fileDescriptor_1004b8837466efb9, []int{3} +} +func (m *MerkleProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MerkleProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MerkleProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MerkleProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_MerkleProof.Merge(m, src) +} +func (m *MerkleProof) XXX_Size() int { + return m.Size() +} +func (m *MerkleProof) XXX_DiscardUnknown() { + xxx_messageInfo_MerkleProof.DiscardUnknown(m) +} + +var xxx_messageInfo_MerkleProof proto.InternalMessageInfo + +func (m *MerkleProof) GetProof() *merkle.Proof { + if m != nil { + return m.Proof + } + return nil +} + +// KeyPath defines a slice of keys +type KeyPath struct { + Keys []*Key `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` +} + +func (m *KeyPath) Reset() { *m = KeyPath{} } +func (*KeyPath) ProtoMessage() {} +func (*KeyPath) Descriptor() ([]byte, []int) { + return fileDescriptor_1004b8837466efb9, []int{4} +} +func (m *KeyPath) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *KeyPath) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_KeyPath.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *KeyPath) XXX_Merge(src proto.Message) { + xxx_messageInfo_KeyPath.Merge(m, src) +} +func (m *KeyPath) XXX_Size() int { + return m.Size() +} +func (m *KeyPath) XXX_DiscardUnknown() { + xxx_messageInfo_KeyPath.DiscardUnknown(m) +} + +var xxx_messageInfo_KeyPath proto.InternalMessageInfo + +// Key defines a proof Key +type Key struct { + name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + enc KeyEncoding `protobuf:"varint,2,opt,name=enc,proto3,enum=cosmos_sdk.x.ibc.commitment.v1.KeyEncoding" json:"enc,omitempty"` +} + +func (m *Key) Reset() { *m = Key{} } +func (m *Key) String() string { return proto.CompactTextString(m) } +func (*Key) ProtoMessage() {} +func (*Key) Descriptor() ([]byte, []int) { + return fileDescriptor_1004b8837466efb9, []int{5} +} +func (m *Key) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Key) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Key.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Key) XXX_Merge(src proto.Message) { + xxx_messageInfo_Key.Merge(m, src) +} +func (m *Key) XXX_Size() int { + return m.Size() +} +func (m *Key) XXX_DiscardUnknown() { + xxx_messageInfo_Key.DiscardUnknown(m) +} + +var xxx_messageInfo_Key proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("cosmos_sdk.x.ibc.commitment.v1.KeyEncoding", KeyEncoding_name, KeyEncoding_value) + proto.RegisterType((*MerkleRoot)(nil), "cosmos_sdk.x.ibc.commitment.v1.MerkleRoot") + proto.RegisterType((*MerklePrefix)(nil), "cosmos_sdk.x.ibc.commitment.v1.MerklePrefix") + proto.RegisterType((*MerklePath)(nil), "cosmos_sdk.x.ibc.commitment.v1.MerklePath") + proto.RegisterType((*MerkleProof)(nil), "cosmos_sdk.x.ibc.commitment.v1.MerkleProof") + proto.RegisterType((*KeyPath)(nil), "cosmos_sdk.x.ibc.commitment.v1.KeyPath") + proto.RegisterType((*Key)(nil), "cosmos_sdk.x.ibc.commitment.v1.Key") +} + +func init() { + proto.RegisterFile("x/ibc/23-commitment/types/types.proto", fileDescriptor_1004b8837466efb9) +} + +var fileDescriptor_1004b8837466efb9 = []byte{ + // 534 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x6d, 0x62, 0x48, 0xb8, 0x54, 0x50, 0x4e, 0x42, 0x44, 0x51, 0xb1, 0x23, 0x23, 0x4a, + 0x00, 0xf5, 0x2c, 0x52, 0xa0, 0x52, 0xc6, 0x34, 0x2e, 0x0d, 0x09, 0x21, 0x3a, 0x14, 0xa9, 0xc0, + 0x60, 0x39, 0xce, 0x35, 0xb6, 0x5c, 0xfb, 0x8c, 0x7d, 0xa0, 0xf8, 0x1b, 0x54, 0x4c, 0x8c, 0x2c, + 0x48, 0x95, 0x60, 0xe0, 0xa3, 0x74, 0xec, 0xc8, 0x14, 0xa1, 0x64, 0x61, 0xee, 0x27, 0x40, 0xbe, + 0x73, 0x95, 0x22, 0x04, 0xea, 0xf2, 0xee, 0x3d, 0xdd, 0xef, 0x9f, 0xff, 0xcb, 0xdf, 0x36, 0xb8, + 0x3b, 0x35, 0xbc, 0x91, 0x63, 0x34, 0x36, 0x37, 0x1c, 0x1a, 0x04, 0x1e, 0x0b, 0x48, 0xc8, 0x0c, + 0x96, 0x46, 0x24, 0x11, 0x15, 0x45, 0x31, 0x65, 0x14, 0xaa, 0x0e, 0x4d, 0x02, 0x9a, 0x58, 0xc9, + 0xd8, 0x47, 0x53, 0xe4, 0x8d, 0x1c, 0xb4, 0xc4, 0xd1, 0x87, 0x47, 0xd5, 0x75, 0xe6, 0x7a, 0xf1, + 0xd8, 0x8a, 0xec, 0x98, 0xa5, 0x06, 0x97, 0x18, 0x13, 0x3a, 0xa1, 0xcb, 0x4e, 0xfc, 0x4e, 0x75, + 0xeb, 0x6f, 0x8e, 0x91, 0x70, 0x4c, 0xe2, 0xc0, 0x0b, 0x99, 0xe1, 0xc4, 0x69, 0xc4, 0xa8, 0x11, + 0x90, 0xd8, 0x3f, 0x20, 0xf9, 0x21, 0x84, 0xfa, 0x3a, 0x00, 0x2f, 0xf8, 0x8c, 0x29, 0x65, 0x10, + 0x02, 0xc5, 0xb5, 0x13, 0xb7, 0x22, 0xd7, 0xe4, 0xfa, 0x0a, 0xe6, 0x7d, 0x53, 0x39, 0x3c, 0xd2, + 0x24, 0xbd, 0x0d, 0x56, 0x04, 0x37, 0x88, 0xc9, 0xbe, 0x37, 0x85, 0x8f, 0x01, 0xf0, 0x49, 0x6a, + 0x45, 0x7c, 0x12, 0x7c, 0xeb, 0xe6, 0xe9, 0x4c, 0xbb, 0x91, 0xda, 0xc1, 0x41, 0x53, 0x5f, 0xde, + 0xe9, 0xf8, 0xaa, 0x4f, 0x52, 0xa1, 0xd2, 0xe9, 0x99, 0xdb, 0xc0, 0x66, 0x2e, 0x7c, 0x0b, 0x4a, + 0x9c, 0xb3, 0x99, 0x70, 0x2c, 0x37, 0xee, 0xa1, 0xff, 0xe7, 0x81, 0xba, 0x24, 0xcd, 0xa4, 0xad, + 0x5b, 0xc7, 0x33, 0x4d, 0x3a, 0x9d, 0x69, 0xd7, 0xcf, 0xd9, 0xd9, 0xcc, 0xd5, 0x71, 0xd1, 0x17, + 0x44, 0x53, 0xf9, 0x9c, 0xad, 0xfd, 0x1c, 0x94, 0xcf, 0xd6, 0xa6, 0x74, 0x1f, 0x3e, 0x01, 0x97, + 0xa3, 0xac, 0xc9, 0xed, 0x34, 0xb4, 0x0c, 0x09, 0x89, 0x90, 0x50, 0x9e, 0x0e, 0xe7, 0xb1, 0xa0, + 0x9b, 0xca, 0xaf, 0x23, 0x4d, 0xd6, 0x7b, 0xa0, 0x98, 0xdb, 0xc3, 0x2d, 0xa0, 0xf8, 0x24, 0x4d, + 0x2a, 0x72, 0xad, 0x50, 0x2f, 0x37, 0xee, 0x5c, 0x60, 0x6b, 0xcc, 0x05, 0xcd, 0x52, 0x16, 0x26, + 0xdf, 0xec, 0x1d, 0x28, 0x74, 0x49, 0x0a, 0xd7, 0x80, 0x12, 0xda, 0x01, 0xc9, 0x13, 0x2c, 0xcd, + 0x67, 0x1a, 0x9f, 0x31, 0xaf, 0x70, 0x07, 0x14, 0x48, 0xe8, 0x54, 0x2e, 0xd5, 0xe4, 0xfa, 0xb5, + 0xc6, 0xc3, 0x0b, 0xd8, 0x98, 0xa1, 0x43, 0xc7, 0x5e, 0x38, 0x69, 0x15, 0xe7, 0x33, 0x2d, 0xd3, + 0xe2, 0xac, 0x88, 0x67, 0xf8, 0xc0, 0x06, 0xe5, 0x73, 0x08, 0xbc, 0x0f, 0xd6, 0xba, 0xe6, 0x6b, + 0xcb, 0xec, 0x6f, 0xbf, 0x6c, 0x77, 0xfa, 0xcf, 0xac, 0x21, 0xee, 0x59, 0xc3, 0xfe, 0xab, 0x81, + 0xb9, 0xdd, 0xd9, 0xe9, 0x98, 0xed, 0x55, 0xa9, 0x5a, 0xfc, 0xf8, 0xa5, 0x56, 0x18, 0xe2, 0x1e, + 0xbc, 0x0d, 0x56, 0xff, 0x40, 0x77, 0xcd, 0xbd, 0x55, 0x59, 0x5c, 0xef, 0x9a, 0x7b, 0xd5, 0xd2, + 0xe1, 0x57, 0x55, 0xfa, 0xfe, 0x4d, 0x95, 0x5a, 0x83, 0xe3, 0xb9, 0x2a, 0x9f, 0xcc, 0x55, 0xf9, + 0xe7, 0x5c, 0x95, 0x3f, 0x2d, 0x54, 0xe9, 0x64, 0xa1, 0x4a, 0x3f, 0x16, 0xaa, 0xf4, 0xe6, 0xe9, + 0xc4, 0x63, 0xee, 0xfb, 0x51, 0xb6, 0xb2, 0x21, 0xfe, 0x47, 0x7e, 0x6c, 0x24, 0x63, 0xdf, 0xf8, + 0xe7, 0xd7, 0x32, 0xba, 0xc2, 0xdf, 0xd3, 0xcd, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x4d, + 0x65, 0x02, 0x51, 0x03, 0x00, 0x00, +} + +func (this *MerkleProof) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MerkleProof) + if !ok { + that2, ok := that.(MerkleProof) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Proof.Equal(that1.Proof) { + return false + } + return true +} +func (m *MerkleRoot) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MerkleRoot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MerkleRoot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MerklePrefix) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MerklePrefix) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MerklePrefix) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.KeyPrefix) > 0 { + i -= len(m.KeyPrefix) + copy(dAtA[i:], m.KeyPrefix) + i = encodeVarintTypes(dAtA, i, uint64(len(m.KeyPrefix))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MerklePath) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MerklePath) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MerklePath) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.KeyPath.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MerkleProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MerkleProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MerkleProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proof != nil { + { + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KeyPath) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *KeyPath) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *KeyPath) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Keys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Key) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Key) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Key) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.enc != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.enc)) + i-- + dAtA[i] = 0x10 + } + if len(m.name) > 0 { + i -= len(m.name) + copy(dAtA[i:], m.name) + i = encodeVarintTypes(dAtA, i, uint64(len(m.name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MerkleRoot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MerklePrefix) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.KeyPrefix) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MerklePath) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.KeyPath.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *MerkleProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Proof != nil { + l = m.Proof.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *KeyPath) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Keys) > 0 { + for _, e := range m.Keys { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *Key) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.name) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.enc != 0 { + n += 1 + sovTypes(uint64(m.enc)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MerkleRoot) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MerkleRoot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MerkleRoot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MerklePrefix) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MerklePrefix: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MerklePrefix: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyPrefix", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyPrefix = append(m.KeyPrefix[:0], dAtA[iNdEx:postIndex]...) + if m.KeyPrefix == nil { + m.KeyPrefix = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MerklePath) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MerklePath: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MerklePath: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyPath", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.KeyPath.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MerkleProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MerkleProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MerkleProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proof == nil { + m.Proof = &merkle.Proof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *KeyPath) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: KeyPath: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KeyPath: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Keys = append(m.Keys, &Key{}) + if err := m.Keys[len(m.Keys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Key) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Key: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Key: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field name", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.name = append(m.name[:0], dAtA[iNdEx:postIndex]...) + if m.name == nil { + m.name = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field enc", wireType) + } + m.enc = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.enc |= KeyEncoding(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/23-commitment/types/types.proto b/x/ibc/23-commitment/types/types.proto new file mode 100644 index 000000000000..5bc1792d1e06 --- /dev/null +++ b/x/ibc/23-commitment/types/types.proto @@ -0,0 +1,69 @@ +syntax = "proto3"; +package cosmos_sdk.x.ibc.commitment.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"; + +import "third_party/proto/gogoproto/gogo.proto"; +import "third_party/proto/tendermint/crypto/merkle/merkle.proto"; + +// MerkleRoot defines a merkle root hash. +// In the Cosmos SDK, the AppHash of a block header becomes the root. +message MerkleRoot { + option (gogoproto.goproto_getters) = false; + + bytes hash = 1; +} + +// MerklePrefix is merkle path prefixed to the key. +// The constructed key from the Path and the key will be append(Path.KeyPath, append(Path.KeyPrefix, key...)) +message MerklePrefix { + bytes key_prefix = 1 [(gogoproto.moretags) = "yaml:\"key_prefix\""]; +} + +// MerklePath is the path used to verify commitment proofs, which can be an arbitrary +// structured object (defined by a commitment type). +message MerklePath { + option (gogoproto.goproto_stringer) = false; + + KeyPath key_path = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"key_path\"" + ]; +} + +// MerkleProof is a wrapper type that contains a merkle proof. +// It demonstrates membership or non-membership for an element or set of elements, +// verifiable in conjunction with a known commitment root. Proofs should be +// succinct. +message MerkleProof { + option (gogoproto.equal) = true; + + tendermint.crypto.merkle.Proof proof = 1; +} + +// KeyPath defines a slice of keys +message KeyPath { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + + repeated Key keys = 1; +} + +// Key defines a proof Key +message Key { + option (gogoproto.goproto_getters) = false; + + bytes name = 1 [(gogoproto.customname) = "name"]; + KeyEncoding enc = 2 [(gogoproto.customname) = "enc"]; +} + +// KeyEncoding defines the encoding format of a key's bytes. +enum KeyEncoding { + option (gogoproto.goproto_enum_stringer) = false; + option (gogoproto.goproto_enum_prefix) = false; + + // URL encoding + KEY_ENCODING_URL_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "URL"]; + // Hex encoding + KEY_ENCODING_HEX = 1 [(gogoproto.enumvalue_customname) = "HEX"]; +} \ No newline at end of file diff --git a/x/ibc/23-commitment/verify.go b/x/ibc/23-commitment/verify.go index 4690fe9e1567..a18cac3a85c4 100644 --- a/x/ibc/23-commitment/verify.go +++ b/x/ibc/23-commitment/verify.go @@ -9,7 +9,8 @@ import ( // CalculateRoot returns the application Hash at the curretn block height as a commitment // root for proof verification. func CalculateRoot(ctx sdk.Context) exported.Root { - return types.NewMerkleRoot(ctx.BlockHeader().AppHash) + root := types.NewMerkleRoot(ctx.BlockHeader().AppHash) + return &root } // BatchVerifyMembership verifies a proof that many paths have been set to diff --git a/x/ibc/ante/ante_test.go b/x/ibc/ante/ante_test.go index bcdac9ed4b47..cfb02bf4c6bb 100644 --- a/x/ibc/ante/ante_test.go +++ b/x/ibc/ante/ante_test.go @@ -13,10 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" "github.com/cosmos/cosmos-sdk/x/staking" @@ -56,8 +54,8 @@ func (suite *HandlerTestSuite) SetupTest() { // create client and connection during setups suite.chainA.CreateClient(suite.chainB) suite.chainB.CreateClient(suite.chainA) - suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, connectionexported.OPEN) - suite.chainB.createConnection(testConnection, testConnection, testClientIDA, testClientIDB, connectionexported.OPEN) + suite.chainA.createConnection(testConnection, testConnection, testClientIDB, testClientIDA, ibctypes.OPEN) + suite.chainB.createConnection(testConnection, testConnection, testClientIDA, testClientIDB, ibctypes.OPEN) } func queryProof(chain *TestChain, key string) (proof commitmenttypes.MerkleProof, height int64) { @@ -93,12 +91,12 @@ 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, nil, 0, addr1) + msg := channel.NewMsgPacket(packet, commitmenttypes.MerkleProof{}, 0, addr1) _, err := handler(cctx, suite.newTx(msg), false) suite.Error(err, "%+v", err) // channel does not exist - suite.chainA.createChannel(cpportid, cpchanid, portid, chanid, channelexported.OPEN, channelexported.ORDERED, testConnection) - suite.chainB.createChannel(portid, chanid, cpportid, cpchanid, channelexported.OPEN, channelexported.ORDERED, testConnection) + suite.chainA.createChannel(cpportid, cpchanid, portid, chanid, ibctypes.OPEN, ibctypes.ORDERED, testConnection) + suite.chainB.createChannel(portid, chanid, cpportid, cpchanid, ibctypes.OPEN, ibctypes.ORDERED, testConnection) ctx = suite.chainA.GetContext() packetCommitmentPath := ibctypes.PacketCommitmentPath(packet.SourcePort, packet.SourceChannel, packet.Sequence) proof, proofHeight := queryProof(suite.chainB, packetCommitmentPath) @@ -152,7 +150,7 @@ func (suite *HandlerTestSuite) TestHandleMsgPacketUnordered() { // suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceSend(suite.chainA.GetContext(), packet.SourcePort, packet.SourceChannel, uint64(10)) - suite.chainA.createChannel(cpportid, cpchanid, portid, chanid, channelexported.OPEN, channelexported.UNORDERED, testConnection) + suite.chainA.createChannel(cpportid, cpchanid, portid, chanid, ibctypes.OPEN, ibctypes.UNORDERED, testConnection) suite.chainA.updateClient(suite.chainB) @@ -327,9 +325,9 @@ func (chain *TestChain) updateClient(client *TestChain) { func (chain *TestChain) createConnection( connID, counterpartyConnID, clientID, counterpartyClientID string, - state connectionexported.State, + state ibctypes.State, ) connectiontypes.ConnectionEnd { - counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix()) + counterparty := connectiontypes.NewCounterparty(counterpartyClientID, counterpartyConnID, commitmenttypes.NewMerklePrefix(chain.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes())) connection := connectiontypes.ConnectionEnd{ State: state, ClientID: clientID, @@ -343,7 +341,7 @@ func (chain *TestChain) createConnection( func (chain *TestChain) createChannel( portID, channelID, counterpartyPortID, counterpartyChannelID string, - state channelexported.State, order channelexported.Order, connectionID string, + state ibctypes.State, order ibctypes.Order, connectionID string, ) channeltypes.Channel { counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := channeltypes.NewChannel(state, order, counterparty, diff --git a/x/ibc/genesis_test.go b/x/ibc/genesis_test.go index cb53bc3df121..1065a485ee07 100644 --- a/x/ibc/genesis_test.go +++ b/x/ibc/genesis_test.go @@ -5,9 +5,7 @@ import ( client "github.com/cosmos/cosmos-sdk/x/ibc/02-client" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" - connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" localhosttypes "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" @@ -46,7 +44,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { ), ConnectionGenesis: connection.NewGenesisState( []connection.ConnectionEnd{ - connection.NewConnectionEnd(connectionexported.INIT, connectionID, clientID, connection.NewCounterparty(clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))), []string{"1.0.0"}), + connection.NewConnectionEnd(ibctypes.INIT, connectionID, clientID, connection.NewCounterparty(clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))), []string{"1.0.0"}), }, []connection.ConnectionPaths{ connection.NewConnectionPaths(clientID, []string{ibctypes.ConnectionPath(connectionID)}), @@ -56,7 +54,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { []channel.IdentifiedChannel{ channel.NewIdentifiedChannel( port1, channel1, channel.NewChannel( - channelexported.INIT, channelOrder, + ibctypes.INIT, channelOrder, channel.NewCounterparty(port2, channel2), []string{connectionID}, channelVersion, ), ), @@ -97,7 +95,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { ClientGenesis: client.DefaultGenesisState(), ConnectionGenesis: connection.NewGenesisState( []connection.ConnectionEnd{ - connection.NewConnectionEnd(connectionexported.INIT, connectionID, "CLIENTIDONE", connection.NewCounterparty(clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))), []string{"1.0.0"}), + connection.NewConnectionEnd(ibctypes.INIT, connectionID, "CLIENTIDONE", connection.NewCounterparty(clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))), []string{"1.0.0"}), }, []connection.ConnectionPaths{ connection.NewConnectionPaths(clientID, []string{ibctypes.ConnectionPath(connectionID)}), diff --git a/x/ibc/ibc_test.go b/x/ibc/ibc_test.go index 34afbe7f2ca5..30386c4a8251 100644 --- a/x/ibc/ibc_test.go +++ b/x/ibc/ibc_test.go @@ -15,8 +15,8 @@ import ( "github.com/cosmos/cosmos-sdk/store/cachekv" "github.com/cosmos/cosmos-sdk/store/dbadapter" sdk "github.com/cosmos/cosmos-sdk/types" - channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" + ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types" ) const ( @@ -31,7 +31,7 @@ const ( channel1 = "firstchannel" channel2 = "secondchannel" - channelOrder = channelexported.ORDERED + channelOrder = ibctypes.ORDERED channelVersion = "1.0" trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 diff --git a/x/ibc/keeper/keeper.go b/x/ibc/keeper/keeper.go index 7b528bbf5c88..06b2a5733a15 100644 --- a/x/ibc/keeper/keeper.go +++ b/x/ibc/keeper/keeper.go @@ -21,12 +21,12 @@ type Keeper struct { // NewKeeper creates a new ibc Keeper func NewKeeper( - cdc *codec.Codec, key sdk.StoreKey, stakingKeeper client.StakingKeeper, scopedKeeper capability.ScopedKeeper, + cdc *codec.Codec, appCodec codec.Marshaler, key sdk.StoreKey, stakingKeeper client.StakingKeeper, scopedKeeper capability.ScopedKeeper, ) *Keeper { clientKeeper := client.NewKeeper(cdc, key, stakingKeeper) - connectionKeeper := connection.NewKeeper(cdc, key, clientKeeper) + connectionKeeper := connection.NewKeeper(cdc, appCodec, key, clientKeeper) portKeeper := port.NewKeeper(scopedKeeper) - channelKeeper := channel.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) + channelKeeper := channel.NewKeeper(appCodec, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) return &Keeper{ ClientKeeper: clientKeeper, @@ -36,7 +36,8 @@ func NewKeeper( } } -// Set the Router in IBC Keeper and seal it +// SetRouter sets the Router in IBC Keeper and seals it. The method panics if +// there is an existing router that's already sealed. func (k *Keeper) SetRouter(rtr *port.Router) { if k.Router != nil && k.Router.Sealed() { panic("cannot reset a sealed router") diff --git a/x/ibc/module.go b/x/ibc/module.go index de0237ea608b..c3d829c24981 100644 --- a/x/ibc/module.go +++ b/x/ibc/module.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" client "github.com/cosmos/cosmos-sdk/x/ibc/02-client" @@ -81,6 +82,12 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return cli.GetQueryCmd(QuerierRoute, cdc) } +// RegisterInterfaceTypes registers module concrete types into protobuf Any. +func (AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegistry) { + connection.RegisterInterfaces(registry) + channel.RegisterInterfaces(registry) +} + // AppModule implements an application module for the ibc module. type AppModule struct { AppModuleBasic diff --git a/x/ibc/types/types.pb.go b/x/ibc/types/types.pb.go new file mode 100644 index 000000000000..ab52afcc610d --- /dev/null +++ b/x/ibc/types/types.pb.go @@ -0,0 +1,129 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/ibc/types/types.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Order defines if a channel is ORDERED or UNORDERED +type Order int32 + +const ( + // zero-value for channel ordering + NONE Order = 0 + // packets can be delivered in any order, which may differ from the order in which they were sent. + UNORDERED Order = 1 + // packets are delivered exactly in the order which they were sent + ORDERED Order = 2 +) + +var Order_name = map[int32]string{ + 0: "ORDER_NONE_UNSPECIFIED", + 1: "ORDER_UNORDERED", + 2: "ORDER_ORDERED", +} + +var Order_value = map[string]int32{ + "ORDER_NONE_UNSPECIFIED": 0, + "ORDER_UNORDERED": 1, + "ORDER_ORDERED": 2, +} + +func (x Order) String() string { + return proto.EnumName(Order_name, int32(x)) +} + +func (Order) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_cc2eab1776b9fb6e, []int{0} +} + +// State defines if a channel or connection is in one of the following states: +// CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. +type State int32 + +const ( + // Default State + UNINITIALIZED State = 0 + // A channel or connection end has just started the opening handshake. + INIT State = 1 + // A channel or connection end has acknowledged the handshake step on the counterparty chain. + TRYOPEN State = 2 + // A channel or connection end has completed the handshake. Open channels are + // ready to send and receive packets. + OPEN State = 3 + // A channel end has been closed and can no longer be used to send or receive packets. + CLOSED State = 4 +) + +var State_name = map[int32]string{ + 0: "STATE_UNINITIALIZED_UNSPECIFIED", + 1: "STATE_INIT", + 2: "STATE_TRYOPEN", + 3: "STATE_OPEN", + 4: "STATE_CLOSED", +} + +var State_value = map[string]int32{ + "STATE_UNINITIALIZED_UNSPECIFIED": 0, + "STATE_INIT": 1, + "STATE_TRYOPEN": 2, + "STATE_OPEN": 3, + "STATE_CLOSED": 4, +} + +func (x State) String() string { + return proto.EnumName(State_name, int32(x)) +} + +func (State) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_cc2eab1776b9fb6e, []int{1} +} + +func init() { + proto.RegisterEnum("cosmos_sdk.x.ibc.v1.Order", Order_name, Order_value) + proto.RegisterEnum("cosmos_sdk.x.ibc.v1.State", State_name, State_value) +} + +func init() { proto.RegisterFile("x/ibc/types/types.proto", fileDescriptor_cc2eab1776b9fb6e) } + +var fileDescriptor_cc2eab1776b9fb6e = []byte{ + // 339 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xaf, 0xd0, 0xcf, 0x4c, + 0x4a, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x86, 0x90, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, + 0xc2, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, 0x7a, 0x15, 0x7a, 0x99, 0x49, + 0xc9, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, 0xf1, 0x05, 0x89, 0x45, 0x25, + 0x95, 0xfa, 0x60, 0x75, 0xfa, 0xe9, 0xf9, 0xe9, 0xf9, 0x08, 0x16, 0x44, 0xb3, 0x56, 0x39, 0x17, + 0xab, 0x7f, 0x51, 0x4a, 0x6a, 0x91, 0x90, 0x0a, 0x97, 0x98, 0x7f, 0x90, 0x8b, 0x6b, 0x50, 0xbc, + 0x9f, 0xbf, 0x9f, 0x6b, 0x7c, 0xa8, 0x5f, 0x70, 0x80, 0xab, 0xb3, 0xa7, 0x9b, 0xa7, 0xab, 0x8b, + 0x00, 0x83, 0x14, 0x47, 0xd7, 0x5c, 0x05, 0x16, 0x90, 0xb8, 0x90, 0x12, 0x17, 0x3f, 0x44, 0x55, + 0xa8, 0x1f, 0x98, 0x76, 0x75, 0x11, 0x60, 0x94, 0xe2, 0xed, 0x9a, 0xab, 0xc0, 0x09, 0x17, 0x10, + 0x92, 0xe3, 0xe2, 0x85, 0xa8, 0x81, 0xa9, 0x60, 0x92, 0xe2, 0xee, 0x9a, 0xab, 0xc0, 0x0e, 0xe5, + 0x4a, 0xb1, 0x74, 0x2c, 0x96, 0x63, 0xd0, 0xda, 0xce, 0xc8, 0xc5, 0x1a, 0x5c, 0x92, 0x58, 0x92, + 0x2a, 0x64, 0xc6, 0x25, 0x1f, 0x1c, 0xe2, 0x18, 0x02, 0xb2, 0xd4, 0xd3, 0xcf, 0x33, 0xc4, 0xd3, + 0xd1, 0xc7, 0x33, 0xca, 0xd5, 0x05, 0xcd, 0x09, 0x82, 0x5d, 0x73, 0x15, 0x78, 0x51, 0x14, 0x08, + 0x49, 0x70, 0x71, 0x41, 0xf4, 0x81, 0x04, 0x05, 0x18, 0x21, 0xae, 0x04, 0xb1, 0x41, 0x2e, 0x80, + 0xc8, 0x84, 0x04, 0x45, 0xfa, 0x07, 0xb8, 0xfa, 0xc1, 0x5c, 0x00, 0xe5, 0x22, 0x74, 0x82, 0x25, + 0x99, 0x21, 0x3a, 0xc1, 0x32, 0x32, 0x5c, 0x3c, 0x10, 0x19, 0x67, 0x1f, 0xff, 0x60, 0x57, 0x17, + 0x01, 0x16, 0x29, 0xae, 0xae, 0xb9, 0x0a, 0x6c, 0x10, 0x1e, 0xc4, 0xe5, 0x4e, 0x4e, 0x27, 0x1e, + 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, + 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x91, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, + 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x89, 0x14, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x8f, 0x14, 0x7f, + 0x49, 0x6c, 0xe0, 0xd0, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xaa, 0x1c, 0xe7, 0x8b, 0xd5, + 0x01, 0x00, 0x00, +} diff --git a/x/ibc/types/types.proto b/x/ibc/types/types.proto new file mode 100644 index 000000000000..8d21e43d2059 --- /dev/null +++ b/x/ibc/types/types.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; +package cosmos_sdk.x.ibc.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/types"; + +import "third_party/proto/gogoproto/gogo.proto"; + +// Order defines if a channel is ORDERED or UNORDERED +enum Order { + option (gogoproto.goproto_enum_prefix) = false; + + // zero-value for channel ordering + ORDER_NONE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "NONE"]; + // packets can be delivered in any order, which may differ from the order in which they were sent. + ORDER_UNORDERED = 1 [(gogoproto.enumvalue_customname) = "UNORDERED"]; + // packets are delivered exactly in the order which they were sent + ORDER_ORDERED = 2 [(gogoproto.enumvalue_customname) = "ORDERED"]; +} + +// State defines if a channel or connection is in one of the following states: +// CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. +enum State { + option (gogoproto.goproto_enum_prefix) = false; + + // Default State + STATE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNINITIALIZED"]; + // A channel or connection end has just started the opening handshake. + STATE_INIT = 1 [(gogoproto.enumvalue_customname) = "INIT"]; + // A channel or connection end has acknowledged the handshake step on the counterparty chain. + STATE_TRYOPEN = 2 [(gogoproto.enumvalue_customname) = "TRYOPEN"]; + // A channel or connection end has completed the handshake. Open channels are + // ready to send and receive packets. + STATE_OPEN = 3 [(gogoproto.enumvalue_customname) = "OPEN"]; + // A channel end has been closed and can no longer be used to send or receive packets. + STATE_CLOSED = 4 [(gogoproto.enumvalue_customname) = "CLOSED"]; +} \ No newline at end of file